I would like to use Extended Kalman Filter for estimating output (GNP) gap in Eviews. The parameters of the system are time-varying. It is assumed that each time-varying parameter follows a random walk. Can someone recommend a solution for this problem in Eviews?

thanx.

## Extended Kalman Filter

**Moderators:** EViews Gareth, EViews Moderator

### Re: Extended Kalman Filter

Extended Kalman Filter (EKF) is used for solving nonlinear state space models. Unfortunately, there is no simple way to do it, since Eviews can only handle linear state space models. EKF works by linearizing the nonlinear states first and then apply the usual kalman filter to obtain the solution. You may try to formulate the intermediate steps of linearization and run the kalman filter thereafter. Although you can combine all steps via writing a program, I am still not sure whether EViews can provide you a feasible solution. You may also need to use the LogL object, which lacks computational power (

*i.e. insufficient number of optimization algorithms*) and some useful features (*e.g. matrix handling, constaint specification, etc.*).
Last edited by trubador on Sun Dec 07, 2008 9:43 am, edited 1 time in total.

### Re: Extended Kalman Filter

Thanks for your reply. I am just getting familiar with Eviews v.6 and it seems to me that it should be capable of handling nonlinear state space modeling. On page 392 of the User Guide, it mentions "recursive and random coefficients", which suggests to me that it may be possible to specify such a system in this application. However, the User Guide does not provide any details as to how to run such a procedure. Anyway, let me dig in some more, and I will let you know how it will turn out.

### Re: Extended Kalman Filter

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:

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...

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...

### Who is online

Users browsing this forum: Baidu [Spider], Yahoo [Bot] and 5 guests