I was trying to estimate a state space model, using MLE and I noticed that even though these can be saved to the session some models are lost when reopening the session. In the example below I'm trying to save the MLE estimation to the session with the name "model1", which is successful but then it's lost at reopening.

Any thoughts on why this happens and on an alternative to save the session?

<hansl>
clear
nulldata 200
set seed 101010
setobs 1 1 --special-time-series
/* set the true variance parameters */
true_s1 = 0.5
true_s2 = 0.25
/* and simulate some data */
v = normal() * sqrt(true_s1)
w = normal() * sqrt(true_s2)
mu = 2 + cum(v)
y = mu + w
/* starting values for variance estimates */
s1 = 1
s2 = 1
/* state-space model set-up */
bundle kb = ksetup(y, 1, 1, s1)
kb.obsvar = s2
kb.diffuse = 1
/* ML estimation of variances */
model1 <- mle ll = ERR ? NA : kb.llt
ERR = kfilter(&kb)
params kb.statevar kb.obsvar
end mle
/* compute the smoothed state */
ksmooth(&kb)
series muhat = kb.state

</hansl>