Page 1 of 1

Kalman Filter

Posted: Thu Dec 25, 2008 9:33 am
by ercan
I am trying to model a time-varying stock beta model. here is my Kalman Filter Model:

rstock=c(1)+sv1*rmarket+[ename=e1, var=exp(c(2))]

@state sv1=sv1(-1)+[ename=e2 , var=exp(c(3))]

@evar cov(e1, e2)=0


----where sv1 is time varying stock beta

------when I specify the following to set initial conditions (sv1=1.000 and initial variance=1), I get error messages. And also I would like to graph the entire beta (state) series as fitted by the model. How can I do that?

vector(1) svec0
svec0.fill 1.000
sym(1) svar0
svar0.fill 1

@mprior svec0
@vprior svar0

Re: Kalman Filter

Posted: Fri Dec 26, 2008 12:44 am
by trubador
You should provide more information on the error message in order to better understand the problem. Besides that the code you have written can be simplified. First of all, you do not need to specify zero covariance between error terms explicitly, since the model already assumes that. Initialization of kalman filter is theoratically sound and most of the time it works very well in practice. It may not be a good idea to intervene in the process, unless you have strict prior information. So, if I were you, I would use a much simpler version like the one below:

Code: Select all

@signal rstock = c(1) + sv1*rmarket + [var = exp(c(2))] @state sv1 = sv1(-1) + [var = exp(c(3))]
Once you estimate the model, you can retrieve the smoothed state values from within the object menu: Proc/Make State Series/Smoothed/State Estimates