On Wed, 23 Dec 2020, Riccardo (Jack) Lucchetti wrote:
> In some places I think he simply put in a misszero() conversion,
but
> only he can tell whether that was really the key.
I believe that Filipe's script ought to work. I'm trying to figure out what's
wrong.
OK, I got it now: Sven is right, the missing entries in the loglikelihood
should be turned into zeros. However, for doing this you need to be able
to turn the "llt" element of the Kalman bundle (which is a matrix) into a
series, and to do that, you need to ensure that they are the same length.
Therefore, to prevent gretl from dropping the rows with missing entries,
you need to set skip_missing to "off", as in (I'm only showing the
relevant part of the script):
<hansl>
set skip_missing off
/* ML estimation of intercept and the two variances */
mle LL = err ? NA : misszero(llik)
B.obsy = B.depvar - b0
B.obsvar = s_obs^2
B.statevar = s_state^2
err = kfilter(&B)
series llik = B.llt
params b0 s_obs s_state
end mle
</hansl>
Alternatively, you can emulate the behaviour of misszero() "by hand",
without using the "set" command, as in
<hansl>
mle LL = err ? NA : llik
B.obsy = B.depvar - b0
B.obsvar = s_obs^2
B.statevar = s_state^2
err = kfilter(&B)
series llik = ok(B.llt) ? B.llt : 0
params b0 s_obs s_state
end mle
</hansl>
Two questions for Allin:
(a) would you object to extending the misszero() function to matrix
arguments?
(b) some time ago, we discussed the possibility of allowing printf
statements inside mle blocks. How do you feel about that?
-------------------------------------------------------
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
-------------------------------------------------------