If you are trying to find a way to apply Extended Kalman Filter (EKF) in EViews, you will have to put too much effort to achieve it. However, I am sure such a work will be highly appreciated by other users and besides me they will also help you.

Putting this aside, you do not need to estimate the output gap with EKF if your specification is linear in states. For example, in the state space object you can type the following code and estimate the output gap as AR(2) process:

- Code: Select all
`@signal gdp = trend + gap + [var = exp(c(1))]`

@state trend = trend(-1) + dtrend(-1) + [var = exp(c(2))]

@state dtrend = dtrend(-1) + [var = exp(c(3))]

@state gap = c(5)*gap(-1) + c(6)*gap2(-1) + [var = exp(c(4))]

@state gap2 = gap(-1)

Please note that trend component is specified as a general form and therefore you can define any kind of trend with manipulating the first three error terms only (i.e. exp(c(1)), exp(c(2)), exp(c(3))). Dropping the second error term, for instance, will give you a smooth stochastic trend.

However, suppose that you have a prior belief that the AR coefficients (i.e. c(5) and c(6)) should also be time varying. Although it is quite simple to incorporate this into the model above, solution becomes complicated. In other words, you can define these coefficients as state variables as well, but then you will have two states interacting in a nonlinear fashion in the state equation of the "gap" variable. In such circumstances you will need Extended Kalman Filter...