Kalman filter and NAIRU, declaring space/state
Moderators: EViews Gareth, EViews Moderator
Kalman filter and NAIRU, declaring space/state
Hi
I'm replicating a paper, which modelled the NAIRU like this:
equation 1 says output is equal to a tendency, h, and a cycle, x. Eq 2 says the tendency is explained by a tendency also, g, and a random error.
Eq 3 explains that tendency g. Eq4 says the cyclical component of output is defined by an AR(2). Eq 5,6,7 have similar explanations. Forget equation 8, i made a mistake repeating that one.
So, i'm a bit lost declaring the model under Kalman filter
The first matrix is the state, the second one the transition or signal
So how i do declare the state and space under Eviews? I've read example but nothing useful. Multiplying the matrix that generates the states i get
@state y=h+x
@state u=c(1)*x+ c(2)*x(1)+ c(3)*x(2)+ s+[var = exp(c(4))]
@signal h=h(1)+g(1)+[var = exp(c(5))]
@signal x=c(6) x(1)+c(7) x(2)+[var = exp(c(4))]
@signal x(1)=x(1) //@signal sv2=sv1(1)? i don't know how to express this correctly.
@signal s=s(1)+[var = exp(c(8))]
@signal g=g(1)+[var = exp(c(9))]
Please, give some help. I'm not used to work with Kalman filter. Thanks in advance for your time and interest.
I'm replicating a paper, which modelled the NAIRU like this:
equation 1 says output is equal to a tendency, h, and a cycle, x. Eq 2 says the tendency is explained by a tendency also, g, and a random error.
Eq 3 explains that tendency g. Eq4 says the cyclical component of output is defined by an AR(2). Eq 5,6,7 have similar explanations. Forget equation 8, i made a mistake repeating that one.
So, i'm a bit lost declaring the model under Kalman filter
The first matrix is the state, the second one the transition or signal
So how i do declare the state and space under Eviews? I've read example but nothing useful. Multiplying the matrix that generates the states i get
@state y=h+x
@state u=c(1)*x+ c(2)*x(1)+ c(3)*x(2)+ s+[var = exp(c(4))]
@signal h=h(1)+g(1)+[var = exp(c(5))]
@signal x=c(6) x(1)+c(7) x(2)+[var = exp(c(4))]
@signal x(1)=x(1) //@signal sv2=sv1(1)? i don't know how to express this correctly.
@signal s=s(1)+[var = exp(c(8))]
@signal g=g(1)+[var = exp(c(9))]
Please, give some help. I'm not used to work with Kalman filter. Thanks in advance for your time and interest.
Re: Kalman filter and NAIRU, declaring space/state
There are plenty of examples in the forum. Besides, you should read "Specifying a State Space Model in EViews" section in the manual, before going forward.
Higher order lag specifications can be handled through state augmentation. In your case, AR(2) process can be implemented as follows:
Higher order lag specifications can be handled through state augmentation. In your case, AR(2) process can be implemented as follows:
Code: Select all
@state x = c(6)*x(1) + c(7)*x1(1) + [var = exp(c(8))]
@state x1 = x(1)
Re: Kalman filter and NAIRU, declaring space/state
Thanks, i'll give a try to what you wrote.
Re: Kalman filter and NAIRU, declaring space/state
When i run this state/space specification
i get the following error
"H is not defined"
I uploaded the wfl where i'm working on. Help me please.
Code: Select all
@state y=h+x
@state u=c(1)*x+ c(2)*x(1)+ c(3)*x(2)+ s+[var = exp(c(4))]
@state x=c(5)*x(1)+c(6)*x1(1)+[var = exp(c(7))]
@state x1=x(1)
@signal h=h(1)+g(1)+[var = exp(c(8))]
@signal s=s(1)+[var = exp(c(9))]
@signal g=g(1)+[var = exp(c(10))]
i get the following error
"H is not defined"
I uploaded the wfl where i'm working on. Help me please.
 Attachments

 datos kalman.wf1
 Working file
 (17.69 KiB) Downloaded 106 times

 Nonnormality and collinearity are NOT problems!
 Posts: 2895
 Joined: Wed Sep 17, 2008 2:25 pm
Re: Kalman filter and NAIRU, declaring space/state
You need data for the signal variables. You don't have any for h.
Re: Kalman filter and NAIRU, declaring space/state
But in the paper, the author says h and x are unknown. He clearly says those equations represent states. But under eviews, they should represent @signal? I want to declare i really don't know Kalman implementation. The only data i have is Y and U, which are gdp and unemployment. The paper illustrates the other values, like tendency and cycle. The fist equation shows gdp=h(tendency)+x(cycle). The rest of the equations are similar. That's why i don't have more data. I'm not sure if i express myself in the right way.
Re: Kalman filter and NAIRU, declaring space/state
Your specification does not correctly match that of authors. You should have only two signal equations (i.e. y and u), the rest will be state equations.
Last edited by trubador on Fri Feb 17, 2012 1:08 am, edited 1 time in total.
Re: Kalman filter and NAIRU, declaring space/state
Code: Select all
@signal pib=h+x
@signal u=c(1)*x+ c(2)*x(1)+ c(3)*x1(1)+ s+[var = exp(c(4))]
@state h=h(1)+g(1)+[var = exp(c(5))]
@state x=c(6)*x(1)+c(7)*x1(1)+[var = exp(c(8))]
@state x1=x(1)
@state s=s(1)+[var = exp(c(9))]
@state g=g(1)+[var = exp(c(10))]
It didn't work:
Invalid lags or leads for state variables in signal equation
"@signal u=c(1)*x+ c(2)*x(1)+ c(3)*x1(1)+ s+[var = exp(c(4))]"
From the theory, i recall that an estimation like the one i'm trying, i'd should give starting values for the h,x,s,g,and so and also for variances. That's what i remember, am i right?
Re: Kalman filter and NAIRU, declaring space/state
The following specification should work:
EViews handles the inital conditions by default. However, when it is not possible to solve for the initial conditions, state levels are initialized to zero and state variances are initialized to a very large number to represent the great uncertainty surrounding the initial values (i.e. diffuse priors). If you want to use your own values, you should create appropriate vectors/matrices and supply them via @mprior and/or @vprior. Initialization of coefficients (e.g. c(1), c(2), ...), on the other hand, can be handled by param command.
Given the complexity of your model, I am pretty sure that you will experience other estimation problems. So, I suggest you to go through the examples in the forum and the manual, before going forward...
Code: Select all
@signal pib=h+x
@signal u=c(1)*x+ c(2)*x1+ c(3)*x2+ s+[var = exp(c(4))]
@state h=h(1)+g(1)+[var = exp(c(5))]
@state x=c(6)*x(1)+c(7)*x1(1)+[var = exp(c(8))]
@state x1=x(1)
@state x2 = x1(1)
@state s=s(1)+[var = exp(c(9))]
@state g=g(1)+[var = exp(c(10))]
EViews handles the inital conditions by default. However, when it is not possible to solve for the initial conditions, state levels are initialized to zero and state variances are initialized to a very large number to represent the great uncertainty surrounding the initial values (i.e. diffuse priors). If you want to use your own values, you should create appropriate vectors/matrices and supply them via @mprior and/or @vprior. Initialization of coefficients (e.g. c(1), c(2), ...), on the other hand, can be handled by param command.
Given the complexity of your model, I am pretty sure that you will experience other estimation problems. So, I suggest you to go through the examples in the forum and the manual, before going forward...
Re: Kalman filter and NAIRU, declaring space/state
Ok, it runs flawless. I haven't check the accuracy of the estimation. But, if i want to declare initial states for the variables, how do i make it? can you give me a link? By the way, thanks for your help. Not even in weeks i'd would have made it. Thanks again.
Re: Kalman filter and NAIRU, declaring space/state
EViews' help files, users guide and Startz's "EViews Illustrated" would be good places to begin with. Other than that, you can search this forum for discussions and solutions on similar issues...
Re: Kalman filter and NAIRU, declaring space/state
i've been searching and i found a code @mprior or @vprior, but neither the manual nor on the forum detail how to use those functions.

 EViews Developer
 Posts: 2434
 Joined: Wed Oct 15, 2008 9:17 am
Re: Kalman filter and NAIRU, declaring space/state
EViews 7 User's Guide II
Chapter 33. State Space Models and the Kalman Filter
Specifying Initial Conditions, p. 497498.
Chapter 33. State Space Models and the Kalman Filter
Specifying Initial Conditions, p. 497498.
Who is online
Users browsing this forum: No registered users and 2 guests