Hi Sven
with the Script below which is for a time varying parameter. there are 2
things I wish to get from the output of this routine.
First in the final gnuplot command I have added, I want to include in the
graph of the dependent variable the estimated/smoothed level of the
system with its 95% CI
Second to get a printout of the values of tvar_ bhat and its 95% CI and
of the level of the system
Also with regard to StrucTiSM, it would be helpful have a printout of the
values of estimated level of the system (and its 95%CI)
Is there some simple script I can add to do these things.? The forecast
script you supplied works well thank you in StrucTism post estimation.
cheers
Brian
_________________________________________________________-
function void at_each_step(bundle *b)
b.obsymat = transp(b.mX[b.t,])
end function
open SevernDeeEggs.gdt --quiet
smpl 1998 2019
/* parameter initialization */
scalar b0 = mean(SEVERN_EGGS_UNADJ)
scalar s_obs = 0.1
scalar s_state = 0.1
/* bundle setup */
bundle B = ksetup(SEVERN_EGGS_UNADJ, 1, 1, 1)
matrix B.mX = {time}
matrix B.depvar = {SEVERN_EGGS_UNADJ}
B.timevar_call = "at_each_step"
B.diffuse = 1
set bfgs_maxiter 5000
/* ML estimation of intercept and the two variances */
mle LL = err ? NA : B.llt
B.obsy = B.depvar - b0
B.obsvar = s_obs^2
B.statevar = s_state^2
err = kfilter(&B)
params b0 s_obs s_state
end mle
/* display the smoothed time-varying slope */
ksmooth(&B)
series tvar_b1hat = B.state[,1]
series tvar_b1se = sqrt(B.stvar[,1])
gnuplot tvar_b1hat --time-series --with-lines --output=display \
--band=tvar_b1hat,tvar_b1se,1.96 --band-style=fill
*gnuplot SEVERN_EGGS_UNADJ --time-series --with-lines --output=display*
____________________________________________________________________
On Wed, 2 Dec 2020 at 16:04, Brian Revell <bjr.newmail(a)gmail.com> wrote:
Hi Sven
progress - I have managed to get the Script to run with *time *as indep
var -but MLE crashes on reaching max 500 interations . It didn't like the
year variable I defined in an earlier run eg 2002, 2003 I think because
it was a large magnitude different eg 10^3 to the dependent variable.
So is there a way to increase the max no. of iterations in the MLE
routine? see below for output..
? function void at_each_step(bundle *b)
> b.obsymat = transp(b.mX[b.t,])
> end function
? open WELSHEGGSCL.gdt --quiet
Read datafile C:\Users\Brian\Documents\gretl\WELSHEGGSCL.gdt
? smpl 2002 2019
Full data range: 2002 - 2024 (n = 23)
Current sample: 2002 - 2019 (n = 18)
/* parameter initialization */
? scalar b0 = mean(Severnadj)
Generated scalar b0 = 9.84213
? scalar s_obs = 0.1
Generated scalar s_obs = 0.1
? scalar s_state = 0.1
Generated scalar s_state = 0.1
/* bundle setup */
? bundle B = ksetup(Severnadj, 1, 1, 1)
? matrix B.mX = {time}
? matrix B.depvar = {Severnadj}
? B.timevar_call = "at_each_step"
? B.diffuse = 1
/* ML estimation of intercept and the two variances */
? mle LL = err ? NA : B.llt
? B.obsy = B.depvar - b0
? B.obsvar = s_obs^2
? B.statevar = s_state^2
? err = kfilter(&B)
? params b0 s_obs s_state
? end mle
Using numerical derivatives
Tolerance = 1.81899e-012
*Reached the maximum iterations (500)*
Error executing script: halting
> end mle
On Tue, 1 Dec 2020 at 17:10, Sven Schreiber <svetosch(a)gmx.net> wrote:
> Am 01.12.2020 um 17:20 schrieb Brian Revell:
>
> Hi Sven
> many thanks for your prompt feedback. Where did you paste it in? In the
> Model MLE option from the GUI -or under File -Script File-menu option?
>
> The latter, yes, so basically in the built-in script editor. The MLE area
> is meant for even lower-level access, without the predefined Kalman filter
> objects.
>
> know where to do this. The manual is not helpful in this respect.
>
> In later parts of the guide it is pretty much assumed that people know
> the scripting interface of gretl. However, at the beginning this is
> explained, please see section 3.1.
>
> (BTW, in my version of the guide the script listing is number 36.4 in ch.
> 36, I guess you have a slightly older version where some newer chapters do
> not exist yet. But this shouldn't make a difference in this context.)
>
> cheers
>
> sven
> _______________________________________________
> Gretl-users mailing list -- gretl-users(a)gretlml.univpm.it
> To unsubscribe send an email to gretl-users-leave(a)gretlml.univpm.it
> Website:
>
https://gretlml.univpm.it/postorius/lists/gretl-users.gretlml.univpm.it/
>