Page 1 of 2
State Space model
Posted: Thu Aug 18, 2011 5:52 am
by statespace1
Hi,
I need help in setting the Nelson Siegel model interpreted by Diebold and(2006) and then set up in state space framework Diebold,Rudebusch and Arouba (2006). The paper is called ' The macroeconomy and the yield curve: a dynamic latent factor approach ‘ , Journal of Econometrics 309-338.
I’ve start setting up the signal equations, since I have 17 maturities I need 17 signal equations, but I am confused on how to write them correctly for example the signal equation yield to maturity 3 months:
@signal m3=c(1)sv1+c(2)*sv2+c(3)*sv3+[var=exp(c(4))]
Hence for each maturity I have to write a signal equation, How do I write the signal equation correctly with the λ and according to the model? how do I write the next signal equation ? In total I should have 36 parameters to estimate.
Then the state equations should be like this ?
@state sv1=sv1(-1)+ [var=exp(c(31))]
@state sv2=sv2(-1)+ [var=exp(c(32))]
@state sv3=sv3(-1)+ [var=exp(c(33))]
Also I have to write the three covariance terms.
Regards,
I.D.
Re: State Space model
Posted: Thu Aug 18, 2011 6:27 am
by trubador
You can continue to write other signal equations in a similar manner:
Code: Select all
@signal m3=c(1)*sv1+c(2)*sv2+c(3)*sv3+[var=exp(c(4))]
@signal m6=c(1)*sv1+c(2)*sv2+c(3)*sv3+[var=exp(c(5))]
@signal m9=c(1)*sv1+c(2)*sv2+c(3)*sv3+[var=exp(c(6))]
...
@signal m30=c(1)*sv1+c(2)*sv2+c(3)*sv3+[var=exp(c(15))]
Covariance terms are quite easy to define:
Code: Select all
@state sv1=sv1(-1)+ [ename=e1,var=exp(c(31))]
@state sv2=sv2(-1)+ [ename=e2,var=exp(c(32))]
@state sv3=sv3(-1)+ [ename=e3,var=exp(c(33))]
@evar cov(e1,e2) = c(34)
@evar cov(e1,e3) = c(35)
@evar cov(e2,e3) = c(36)
This is the way how EViews handles state space equations. Please refer to manual for more information on the specification and estimation of these models in EViews.
I also would like to suggest that the coefficients in the signal equations should be defined as an exponential function of a single parameter (λ) and the maturity. Otherwise, you'll end up with 51 additional coefficients to estimate. The state equations are the factors themselves, so I am not sure if they should be defined as pure random walk.
Before moving on the estimation step, I suggest you to read the article carefully and then study the manual to learn more about state space modeling in EViews...
Re: State Space model
Posted: Thu Aug 18, 2011 6:53 am
by statespace1
Thank you Trubador for your replay, I have all the other signal equations but I need to write them according to my model , since the factor loadings are an exponential factor of the parameter lambda and maturity t ,and is there where I am not quite sure how should I handle it. I've already read the Eviews help guide on state space modeling but still can figure it out. Could you just give me an ideea of how to write the signal equation with the exponential function of lambda and t ?
I know that I wrote the state equation as a random walk. The factors should follow a var process of first order.
Regards,
I.D.
Re: State Space model
Posted: Thu Aug 18, 2011 7:20 am
by trubador
For the 3-month, you can replace the c(2) with:
A VAR process of first order should take into account the lagged values of other factors:
Code: Select all
@state sv1 = c(4)*sv1(-1) + c(5)*sv2(-1) + c(6)*sv3(-1) + [ename = e1, var = exp(c(7))]
...
Re: State Space model
Posted: Thu Aug 18, 2011 9:26 am
by statespace1
I am adding an Eviews file with just the sspace and the variables for you to have a look and tell me what u think. I still have to add 3 parameters, I am not sure if are the mean state vector µ (3x1) or the Q matrix which contains 6 parameters - 3 disturbance for each factor I think I have that and 3 covariance which also I think I have .Thank you for your time and I greatly appreciate your help.
Regards,
I.D.
Re: State Space model
Posted: Thu Aug 18, 2011 10:44 pm
by trubador
You do not have to define variances of state disturbance explicitly again. For instance, the following two are referring to the same thing, so you can drop one of them:
Code: Select all
[ename=e1,var =exp(c(28))]
@evar cov(e1,e1) = c(31)
I believe you need to specify the mean state vector as well. So, simply add each state equation a constant.
Re: State Space model
Posted: Fri Aug 19, 2011 2:12 am
by statespace1
Yes, I have also to add a constant to the VAR (1) , the mean state vector μ (3x1) , hence all 36 parameters are there.
Thank you.
Regards,
I.D.
Re: State Space model
Posted: Tue Aug 23, 2011 4:42 am
by statespace1
Hi Trubador,
I specified the sspace with all the parameters in place, 36 of them, I was trying to estimate the sspace and a message appeared -WARNING: Singular covariance - coefficients are not unique. I try looking again at the equations and I don't know what I've did wrong. The Kalman filter should be initialized using unconditional mean and unconditional covariance matrix of the state vector. The non negativity for the estimated variances is imposed by using the exponential variances. I think is the initial values. I’ve attached the file for you to have a look and give me some insights regarding setting up the model correctly. Thank you for your time and I appreciate your quick response.
Regards,
I.D.
Re: State Space model
Posted: Tue Aug 23, 2011 5:17 am
by trubador
This is a very generic problem that anybody come across at some point when using State Space modeling. There are possible remedies for the problem, which I prefer not to re-iterate here since you can find plenty of them via searching the forum...
Re: State Space model
Posted: Sun Oct 23, 2011 2:39 am
by ssym
Hi,
I' ve been reading your posts, as I have almost the same problem.
I need help in estimating Diebold, Rudebusch and Arouba (2006) yields-macro model. I managed to obtain same results as in their yields-only model, but failed to replicate their yields-macro model. My suspect is that this is due to different initial values.
I would be very grateful if you could send me the initial calibration parameters or advise on what would be the best strategy to employ.
Thank you very much in advance. Looking forward to your replay.
Re: State Space model
Posted: Sun Oct 23, 2011 7:50 am
by startz
Try using the final published coefficients as the starting values.
Re: State Space model
Posted: Thu Nov 03, 2011 2:37 am
by rodneyleshaba
I have the formula below I am trying to estimate the Nelson Siegel model using state space, it is giving me errors but I cant seem to find out what exatcly is the problem.
@signal _91_days = c(1)*sv1+sv2*((1-exp(-3*c(1))))/(c(1)*3))+sv3*(((1-exp(-3*c(1)))/c(1)*3)-exp(-c(1)*3)))+[var=exp(c(4))]
@signal _183_days = c(1)*sv1+sv2*((1-exp(-6*c(1))))/(c(1)*6))+sv3*(((1-exp(-6*c(1)))/c(1)*6)-exp(-c(1)*6)))+[var=exp(c(5))]
@signal _1yr = c(1)*sv1+sv2*((1-exp(-12*c(1))))/(c(1)*12))+sv3*(((1-exp(-12*c(1)))/c(1)*12)-exp(-c(1)*12)))+[var=exp(c(6))]
@signal _3yr = c(1)*sv1+sv2*((1-exp(-36*c(1))))/(c(1)*36))+sv3*(((1-exp(-36*c(1)))/c(1)*36)-exp(-c(1)*36)))+[var=exp(c(7))]
@signal _5yr = c(1)*sv1+sv2*((1-exp(-60*c(1))))/(c(1)*60))+sv3*(((1-exp(-60*c(1)))/c(1)*60)-exp(-c(1)*60)))+[var=exp(c(8))]
@signal _10yr = c(1)*sv1+sv2*((1-exp(-120*c(1))))/(c(1)*120))+sv3*(((1-exp(-120*c(1)))/c(1)*120)-exp(-c(1)*120)))+[var=exp(c(9))]
@signal _15yr = c(1)*sv1+sv2*((1-exp(-180*c(1))))/(c(1)*180))+sv3*(((1-exp(-180*c(1)))/c(1)*180)-exp(-c(1)*180)))+[var=exp(c(10))]
@signal _20yr = c(1)*sv1+sv2*((1-exp(-240*c(1))))/(c(1)*240))+sv3*(((1-exp(-240*c(1)))/c(1)*240)-exp(-c(1)*240)))+[var=exp(c(11))]
@signal _30yr = c(1)*sv1+sv2*((1-exp(-360*c(1))))/(c(1)*360))+sv3*(((1-exp(-360*c(1)))/c(1)*360)-exp(-c(1)*360)))+[var=exp(c(12))]
@state sv1=c(13)+c(14)*sv1(-1)+c(15)*sv2(-1)+c(16)*sv3(-1)+[ename=e1,var=exp(c(17))]
@state sv2 = c(18)+c(19)*sv1(-1)+c(20)*sv2(-1)+c(21)*sv3(-1)+[ename=e2,var=exp(c(22))]
@state sv3 = c(23)+c(24)*sv1(-1)+c(25)*sv2(-1)+c(26)*sv3(-1)+[ename=e2,var=exp(c(27))]
@evar cov(e1,e2)=c(28)
@evar cov(e1,e3)=c(29)
@evar cov(e2,e3)=c(30)
My other problem is understanding and using the output that comes out of the state space output? How does one move from the output to estimation of yields at different points or to fitting the yield curve
Re: State Space model
Posted: Fri Nov 04, 2011 6:28 pm
by ssym
Thank you startz, that did give me their final values, but it also gave me large standard errors. Do you have any advice?
rodneyleshaba, try to estimate the model without c(1) next to sv1 in your signal equation and then make state series.
To better understand the output I suggest you to read original Diebold, Rudebusch and Arouba (2006) paper and Eviews manual.
Re: State Space model
Posted: Sun Nov 06, 2011 5:14 am
by rodneyleshaba
@ssym thank you it worked but why did I have to remove it?
Re: State Space model
Posted: Thu Nov 10, 2011 10:09 am
by EViews Glenn
A quick glance at the spec suggests that it's just a scaling factor for the states. You should be able to get the same likelihood value for different values of C(1) by scaling the states accordingly...