Running Kalman filter with initial data
Moderators: EViews Gareth, EViews Moderator
Running Kalman filter with initial data
Hi everyone,
I'm sorry to post again a topic on Kalman Filter estimation but I'm really stuck...
I'm trying to estimate time varying betas with a kalman filter. I used to work with matlab but I have to use Eviews now and I'm new here...
Here is my workfile and the code :
@signal CON_AR = sv1*BONDS + sv2*CMDTY + sv3*CREDITS + sv4*EMMB + sv5*EMME + sv6*SP + sv7*USD + [var = exp(c(1))]
@state sv1 = sv1(1) + [var = exp(c(2))]
@state sv2 = sv2(1) + [var = exp(c(3))]
@state sv3 = sv3(1) + [var = exp(c(4))]
@state sv4 = sv4(1) + [var = exp(c(5))]
@state sv5 = sv5(1) + [var = exp(c(6))]
@state sv6 = sv6(1) + [var = exp(c(7))]
@state sv7 = sv7(1) + [var = exp(c(8))]
@mprior SVEC0
@vprior SVAR0
When I hit "estimate" a message error appears : "Initial state variance prior "SVAR0" is not defined or is not a Sym object"
I don't understand, I followed the step of the manual guide to define SVEC0 and SVAR0. In my case, SVAR0 has to be a matrix 7x7 full of zeros...
I don't know if someone could run this workfile and tell me if it works ? I updated Eviews 7 but still the same problem and if I don't specify SVAR0, I get : "Missing value found in state variance matrix"
Please help me
Thank you, I really appreciate your help!
I'm sorry to post again a topic on Kalman Filter estimation but I'm really stuck...
I'm trying to estimate time varying betas with a kalman filter. I used to work with matlab but I have to use Eviews now and I'm new here...
Here is my workfile and the code :
@signal CON_AR = sv1*BONDS + sv2*CMDTY + sv3*CREDITS + sv4*EMMB + sv5*EMME + sv6*SP + sv7*USD + [var = exp(c(1))]
@state sv1 = sv1(1) + [var = exp(c(2))]
@state sv2 = sv2(1) + [var = exp(c(3))]
@state sv3 = sv3(1) + [var = exp(c(4))]
@state sv4 = sv4(1) + [var = exp(c(5))]
@state sv5 = sv5(1) + [var = exp(c(6))]
@state sv6 = sv6(1) + [var = exp(c(7))]
@state sv7 = sv7(1) + [var = exp(c(8))]
@mprior SVEC0
@vprior SVAR0
When I hit "estimate" a message error appears : "Initial state variance prior "SVAR0" is not defined or is not a Sym object"
I don't understand, I followed the step of the manual guide to define SVEC0 and SVAR0. In my case, SVAR0 has to be a matrix 7x7 full of zeros...
I don't know if someone could run this workfile and tell me if it works ? I updated Eviews 7 but still the same problem and if I don't specify SVAR0, I get : "Missing value found in state variance matrix"
Please help me
Thank you, I really appreciate your help!
 Attachments

 kf.wf1
 (29.19 KiB) Downloaded 249 times
Re: Running Kalman filter with initial data
Initial state variance matrix (SVAR0 in your case) has to be a sym object not an ordinary matrix. If you have initial values for state variances as a vector (e.g. vars), then you can create a symmetric matrix as follows:
Code: Select all
sym SVAR0 = @makediagonal(vars)
Re: Running Kalman filter with initial data
Thank you for your answer.
If I'm right, I have to create a Vector with initial values of the variance (zeros in my case) and then insert the the code you gave me instead of "SVAR0" ?
My last row of code will be : @vprior sym SVAR0 = @makediagonal(vars) ?
Thank you again
If I'm right, I have to create a Vector with initial values of the variance (zeros in my case) and then insert the the code you gave me instead of "SVAR0" ?
My last row of code will be : @vprior sym SVAR0 = @makediagonal(vars) ?
Thank you again
Re: Running Kalman filter with initial data
The code is for generating the symmetric matrix outside (in the command window). Do not place it into State Space object. You do not have to change the specification of your state space, since the only problem is the type of your SVAR0 matrix.
Re: Running Kalman filter with initial data
I'm sorry, I did what you told me but I still get the error message "Missing value found in state variance matrix"...
Can you help me ? I'm really lost.
Thank you very much
Can you help me ? I'm really lost.
Thank you very much
Re: Running Kalman filter with initial data
Initialize the coefficents as well and fix them at the start of each estimation. Otherwise, in each estimation EViews will use the stored values in the coefficient vector from the previous estimation. Add the following line to State Space specification below your code:
Of course, you can assign different values if you have a priori information.
Code: Select all
param c(1) .0 c(2) .0 c(3) .0 c(4) .0 c(5) .0 c(6) .0 c(7) .0 c(8) .0
Of course, you can assign different values if you have a priori information.
Re: Running Kalman filter with initial data
I'm truly sorry but I get the same error message... "Missing value found in state variance matrix". Here is my code :
@signal CON_AR = sv1*BONDS + sv2*CMDTY + sv3*CREDITS + sv4*EMMB + sv5*EMME + sv6*SP + sv7*USD + [var = exp(c(1))]
@state sv1 = sv1(1) + [var = exp(c(2))]
@state sv2 = sv2(1) + [var = exp(c(3))]
@state sv3 = sv3(1) + [var = exp(c(4))]
@state sv4 = sv4(1) + [var = exp(c(5))]
@state sv5 = sv5(1) + [var = exp(c(6))]
@state sv6 = sv6(1) + [var = exp(c(7))]
@state sv7 = sv7(1) + [var = exp(c(8))]
@mprior svec0
@vprior svar0
param c(1) .0 c(2) .0 c(3) .0 c(4) .0 c(5) .0 c(6) .0 c(7) .0 c(8) .0
and I computed sym SVAR0 = @makediagonal(vars) in the command window as you told me...
I'm sorry but could you check if it works on your system ?
Thank you trubador
@signal CON_AR = sv1*BONDS + sv2*CMDTY + sv3*CREDITS + sv4*EMMB + sv5*EMME + sv6*SP + sv7*USD + [var = exp(c(1))]
@state sv1 = sv1(1) + [var = exp(c(2))]
@state sv2 = sv2(1) + [var = exp(c(3))]
@state sv3 = sv3(1) + [var = exp(c(4))]
@state sv4 = sv4(1) + [var = exp(c(5))]
@state sv5 = sv5(1) + [var = exp(c(6))]
@state sv6 = sv6(1) + [var = exp(c(7))]
@state sv7 = sv7(1) + [var = exp(c(8))]
@mprior svec0
@vprior svar0
param c(1) .0 c(2) .0 c(3) .0 c(4) .0 c(5) .0 c(6) .0 c(7) .0 c(8) .0
and I computed sym SVAR0 = @makediagonal(vars) in the command window as you told me...
I'm sorry but could you check if it works on your system ?
Thank you trubador
 Attachments

 kf.wf1
 (29.29 KiB) Downloaded 278 times

 Nonnormality and collinearity are NOT problems!
 Posts: 3507
 Joined: Wed Sep 17, 2008 2:25 pm
Re: Running Kalman filter with initial data
I opened the workfile, doubleclicked on SS01, and hit Estimate. It ran with no problem, although it did report WARNING: Singular covariance.
Re: Running Kalman filter with initial data
I don't understand why it doesn't work ?!?
Can I abuse of your kindness and ask you the results you get ? Could you post them ?
Thank you very much
Can I abuse of your kindness and ask you the results you get ? Could you post them ?
Thank you very much

 Nonnormality and collinearity are NOT problems!
 Posts: 3507
 Joined: Wed Sep 17, 2008 2:25 pm
Re: Running Kalman filter with initial data
Glad to lend a bit of a hand. Here's the estimate using EViews 7.1 and the latest update.
Re: Running Kalman filter with initial data
Thank you very much for all your help!
Have a nice day
Have a nice day

 Nonnormality and collinearity are NOT problems!
 Posts: 3507
 Joined: Wed Sep 17, 2008 2:25 pm
Re: Running Kalman filter with initial data
king_luca wrote:Thank you very much for all your help!
Have a nice day
I wish I could be more helpful.
You may have already answered this, but are you using the most uptodate version of EViews?
Re: Running Kalman filter with initial data
Yes I do, I updated it... But the workfile seems to work on the system of a friend of mine.
However, I'd have one last question : how can I specify that my 7 regressors must sum to 1 ?
Thank you again for your help!
However, I'd have one last question : how can I specify that my 7 regressors must sum to 1 ?
Thank you again for your help!
Re: Running Kalman filter with initial data
I have 2 other, maybe silly, questions : are the results of the estimation for the coefficient c(1) to c(8) in percent ? and how can I constraint the coefficient c(1) to c(8) to be positiv ?
Thank you for all your help
Thank you for all your help
Last edited by king_luca on Fri Aug 06, 2010 10:32 am, edited 2 times in total.

 Nonnormality and collinearity are NOT problems!
 Posts: 3507
 Joined: Wed Sep 17, 2008 2:25 pm
Re: Running Kalman filter with initial data
king_luca wrote:Yes I do, I updated it... But the workfile seems to work on the system of a friend of mine.
However, I'd have one last question : how can I specify that my 7 regressors must sum to 1 ?
Thank you again for your help!
If you mean the coefficients on the variables, replace SV7 with (1SV1SV2SV3SV4SV5SV6)
Who is online
Users browsing this forum: No registered users and 6 guests