I am trying to run a maximum-likelihood estimation in Mata using optimize(). However, I cannot get the maximum value of even quite simple functions, so there must be a programming error with my code. I have produced a minimum working example below, where I replaced my original function with a simple x^2, just to understand what is going on:
I get the following error, which I have difficulty making any sense of:
In my mind, I have not declared any arguments exept the one parameter for which I would like the optimal value, so I do not understand what this represents
Thank you in advance!
Best,
Richard
Code:
mata
mata clear
end
mata
function logit_mata2(costs_guess)
{
printf("control")
ll = -(costs_guess)^2
return(ll)
}
logit_mata2(10)
S2 = optimize_init()
optimize_init_evaluator(S2, &logit_mata2())
optimize_init_params(S2, 10 )
result = optimize(S2)
end
logit_mata2(): 3001 expected 1 arguments but received 5
opt__calluser0_d(): - function returned error
opt__d0_calluser(): - function returned error
deriv__call1user_d(): - function returned error
_deriv__compute_value(): - function returned error
_deriv(): - function returned error
opt__eval_nr_d0(): - function returned error
opt__eval(): - function returned error
opt__looputil_iter0_common(): - function returned error
opt__looputil_iter0_nr(): - function returned error
opt__loop_nr(): - function returned error
opt__loop(): - function returned error
optimize(): - function returned error
<istmt>: - function returned error
opt__calluser0_d(): - function returned error
opt__d0_calluser(): - function returned error
deriv__call1user_d(): - function returned error
_deriv__compute_value(): - function returned error
_deriv(): - function returned error
opt__eval_nr_d0(): - function returned error
opt__eval(): - function returned error
opt__looputil_iter0_common(): - function returned error
opt__looputil_iter0_nr(): - function returned error
opt__loop_nr(): - function returned error
opt__loop(): - function returned error
optimize(): - function returned error
<istmt>: - function returned error
Thank you in advance!
Best,
Richard

Comment