How do I set an initial coefficient value in a State Space object from a previously calculated scalar?

For technical questions regarding estimation of single equations, systems, VARs, Factor analysis and State Space Models in EViews. General econometric questions and advice should go in the Econometric Discussions forum.

Moderators: EViews Gareth, EViews Moderator

ohubert
Posts: 8
Joined: Thu Apr 21, 2022 2:21 am

How do I set an initial coefficient value in a State Space object from a previously calculated scalar?

Postby ohubert » Wed May 18, 2022 2:45 am

Dear all,

when creating a state space object, how can I set an initial value for a coefficient of the state space which comes from an object that already exists in my workfile? I know how to set an initial value in a state space, but I would like to use outside information to help/accelerate the maximum likelihood estimation.

For instance, consider that a sensible value for a coefficient in the state space comes from a regression. How could I reference this coefficient when I declare param in the state space?

Consider the two models below (they make no sense, they are simply there for the example):

Code: Select all

wfcreate(wf=annual, page=myproject) a 1950 2005
genr series1=nrnd
genr series2= 0.9*series1(-1)+ 0.1*nrnd

' Working state space
statespace locallevel ' Create and estimate the state space with initial values
locallevel.append @signal series2=mu +[ename = e1, var = exp(c(1))]
locallevel.append @state mu=mu(-1) +[ename = e2, var = exp(c(2))]
locallevel.append param c(1) -7 c(2) -8.5
locallevel.ml


and Model 2:

Code: Select all

' Not working state space
equation leastsquare ' estimate mock regression
leastsquare.ls series2 c series2(-1)
scalar coef1=leastsquare.@coefs(1)

statespace locallevelbis ' Create the state space
locallevelbis.append @signal series2=mu +[ename = e1, var = exp(c(1))]
locallevelbis.append @state mu=mu(-1) +[ename = e2, var = exp(c(2))]
locallevelbis.append param c(1) -7 c(2) coef1 ' append the scalar as initial value
locallevelbis.ml


Is model 2 possible? If so, how should I reference coef1?

Thanks a lot in advance.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13306
Joined: Tue Sep 16, 2008 5:38 pm

Re: How do I set an initial coefficient value in a State Space object from a previously calculated scalar?

Postby EViews Gareth » Wed May 18, 2022 12:31 pm

Code: Select all

' Not working state space
equation leastsquare ' estimate mock regression
leastsquare.ls series2 c series2(-1)
!coef1=leastsquare.@coefs(1)

statespace locallevelbis ' Create the state space
locallevelbis.append @signal series2=mu +[ename = e1, var = exp(c(1))]
locallevelbis.append @state mu=mu(-1) +[ename = e2, var = exp(c(2))]
locallevelbis.append param c(1) -7 c(2) {!coef1} ' append the scalar as initial value
locallevelbis.ml
Follow us on Twitter @IHSEViews

ohubert
Posts: 8
Joined: Thu Apr 21, 2022 2:21 am

Re: How do I set an initial coefficient value in a State Space object from a previously calculated scalar?

Postby ohubert » Thu May 19, 2022 12:01 am

Thank you.

However, I still get an error message:
!COEF1 is not a valid string or scalar name in "LOCALLEVELBIS.
APPEND PARAM C(1) -7 C(2) {!COEF1}" on line 59.



How can I solve this?


Thanks again.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13306
Joined: Tue Sep 16, 2008 5:38 pm

Re: How do I set an initial coefficient value in a State Space object from a previously calculated scalar?

Postby EViews Gareth » Thu May 19, 2022 7:36 am

My bad, try it without the braces.

Code: Select all

' Not working state space
equation leastsquare ' estimate mock regression
leastsquare.ls series2 c series2(-1)
!coef1=leastsquare.@coefs(1)

statespace locallevelbis ' Create the state space
locallevelbis.append @signal series2=mu +[ename = e1, var = exp(c(1))]
locallevelbis.append @state mu=mu(-1) +[ename = e2, var = exp(c(2))]
locallevelbis.append param c(1) -7 c(2) !coef1 ' append the scalar as initial value
locallevelbis.ml
Follow us on Twitter @IHSEViews

ohubert
Posts: 8
Joined: Thu Apr 21, 2022 2:21 am

Re: How do I set an initial coefficient value in a State Space object from a previously calculated scalar?

Postby ohubert » Thu May 19, 2022 8:00 am

Hi Gareth,

Unfortunately, still not working:
Error in Param statement in "LOCALLEVELBIS.ML" on line 77.



Thanks.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13306
Joined: Tue Sep 16, 2008 5:38 pm

Re: How do I set an initial coefficient value in a State Space object from a previously calculated scalar?

Postby EViews Gareth » Thu May 19, 2022 8:04 am

This program seems to run just fine for me:

Code: Select all

wfcreate(wf=annual, page=myproject) a 1950 2005
genr series1=nrnd
genr series2= 0.9*series1(-1)+ 0.1*nrnd

' Working state space
statespace locallevel ' Create and estimate the state space with initial values
locallevel.append @signal series2=mu +[ename = e1, var = exp(c(1))]
locallevel.append @state mu=mu(-1) +[ename = e2, var = exp(c(2))]
locallevel.append param c(1) -7 c(2) -8.5
locallevel.ml


' Not working state space
equation leastsquare ' estimate mock regression
leastsquare.ls series2 c series2(-1)
!coef1=leastsquare.@coefs(1)

statespace locallevelbis ' Create the state space
locallevelbis.append @signal series2=mu +[ename = e1, var = exp(c(1))]
locallevelbis.append @state mu=mu(-1) +[ename = e2, var = exp(c(2))]
locallevelbis.append param c(1) -7 c(2) !coef1 ' append the scalar as initial value
locallevelbis.ml
Follow us on Twitter @IHSEViews

ohubert
Posts: 8
Joined: Thu Apr 21, 2022 2:21 am

Re: How do I set an initial coefficient value in a State Space object from a previously calculated scalar?

Postby ohubert » Thu May 19, 2022 8:08 am

Thank you.


Return to “Estimation”

Who is online

Users browsing this forum: No registered users and 22 guests