On Wed, May 22, 2024 at 3:36 PM Alecos Papadopoulos <papadopalex(a)aueb.gr> wrote:
When we combine the Kalman Filter with the mle command, we use the
"kfilter" or the "ksmooth" function as a success/failure check for
KF,
and if we're good, we tell the mle to have a look at the series with the
likelihood contributions, and proceed with parameter estimation.
We automate this by using a conditional statement on the mle line itself
(as shown e.g. in the user guide, p. 362).
In no-KF mle, this conditional statement is often used to impose
constraints on the parameters (like positivity of variances).
I understand that simple non-negative constraints can be imposed in
other indirect ways, but I have to impose bounds on the estimated
parameters like "0<alpha<1".
So can I somehow combine the naked mle "check" syntax with the
KF-success syntax into one, say
<hansl>
mle logl ERR && CHECK ? NA : kb.llt
....
ERR = kfilter(&kb)
scalar CHECK = (alpha>0) && (alpha<1)
params alpha
end mle
</hansl>
...or do I need something more elaborate? (maybe there is an issue with
the fact that good news for ERR is when ERR=0 while good news for CHECK
is when CHECK = 1, if I understand correctly?)
Yes, that would be an issue in the setup as given above, but it could
be circumvented by
mle logl (ERR || CHECK == 0)? NA : kb.llt
or, if you prefer, make the NA condition "(ERR || !CHECK)". However,
if you want to limit a parameter to (0,1) a more standard approach
would be to use a transformation that maps from (-inf, +inf) onto
(0,1) -- for example cnorm().
Allin Cottrell