On Thu, 5 Feb 2015, Alecos Papadopoulos wrote:
I have to evaluate the finite-sample performance of the ML estimator
in the
estimation of a 3-parameter distribution, based on simulated samples.
The "progressive loop" environment which is set for Monte Carlo studies does
not seem to support the mle command. I ended up using the index loop which
supports the mle command, while writing the coefficient vector obtained in
each loop that is grabbed by $coeff, to successive rows of a pre-defined
zero matrix. So far so good.
Your solution is perfectly ok. However, you can circumvent the above
limitation by wrapping mle into a function, as in
<hansl>
function scalar homemade_probit(series y, series x, scalar *b0, scalar *b1)
catch mle ll = ln(cnorm(z))
series ndx = b0 + b1*x
series z = y ? ndx : -ndx
params b0 b1
end mle --quiet
scalar err = $error > 0
return err
end function
nulldata 50
scalar H = 999
series x = normal()
loop H --progressive --quiet
series y = 1 + x > normal()
scalar b0 = 0
scalar b1 = 1
scalar err = homemade_probit(y, x, &b0, &b1)
print b0 b1 err
endloop
</hansl>
The problem is the following: the distribution appears difficult to
estimate
in small samples and rather often the convergence criterion for the mle is
not met (I don't mind that, this is part of the evaluation of the performance
of the MLE). But when this happens, /the loop stops. /The total number of
runs of the loop will possibly require some hours to run. If the loop stops
every time the mle does not converge, I will have to be constantly overseeing
the process for the duration, in order to re-ignite the loop. It would be
very convenient if the loop could continue irrespective of whether the mle in
a particular loop fails to converge.
Is there a way to tell Gretl not to stop the loop, even if the mle fails, to
write the container matrix with NANs, and to proceed to the next run;
You may want to use the $error accessor for that. The above script gives
you a rough example.
-------------------------------------------------------
Riccardo (Jack) Lucchetti
Dipartimento di Scienze Economiche e Sociali (DiSES)
Università Politecnica delle Marche
(formerly known as Università di Ancona)
r.lucchetti(a)univpm.it
http://www2.econ.univpm.it/servizi/hpp/lucchetti
-------------------------------------------------------