Output Gap with Dynamic HP Filter

For technical questions regarding estimation of single equations, systems, VARs, Factor analysis and State Space Models in EViews. General econometric questions and advice should go in the Econometric Discussions forum.

Moderators: EViews Gareth, EViews Moderator

gip
Posts: 1
Joined: Thu Oct 08, 2015 4:35 am

Output Gap with Dynamic HP Filter

Postby gip » Thu Oct 08, 2015 7:41 am

Dear all,

I am new to Eviews and I am trying to estimate output gap using a "dynamic" HP filter as in this paper http://www.bis.org/publ/work442.htm

The signal equation is Y(t) = Y*(t) + β( Y(t-1) - Y*(t-1) ) +ε(1,t)
The state equation is: ∆Y*(t+1) = ∆Y*(t)+ ε(0,t+1)

In a standard HP filter we set the relative weight (λ) of the variance of ε(1,t) to that of ε(0,t+1) equal to 1600 (for quarterly frequency). In this paper, in order to account for the fact that Y* depends also on β and to avoid small sample problems, they iterate over different values of λ until:

VAR[Y(t) - Y*(hp, t)] / VAR[∆Y*(hp, t) - ∆Y*(hp, t-1)] = VAR[Y(t) - Y*(alt, t)] / VAR[∆Y*(alt, t) - ∆Y*(alt, t-1)]

where Y*(hp, t) is the potential output estimated from the standard HP filter and Y*(alt, t) is potential output estimated using the equations above.

I have 2 problems implementing this methodology:

1) My code is not being able to impose the state equation at t+1 (although, given the constraint and some other writings in the paper, it might be a typo and they actually use a standard [∆Y*(t) = ∆Y*(t-1)+ ε(0,t)]

2) I don't know how to specify the constraint for λ.

Below is what I have written so far using the standard constraint of λ=1600, but it is not working as the state equation is not accepted.

Code: Select all

@signal y = ystar + c(2)*(y(-1) - ystar1) + [var=1600*exp(c(1))]

@state ystar(1) = ystar + dystar

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

@state ystar1 = ystar(-1)


Any hint for solving problem 1 and especially 2?

Many thanks,

gip

xprimexinverse
Posts: 39
Joined: Fri Sep 18, 2015 11:41 am
Location: Dublin, Ireland
Contact:

Re: Output Gap with Dynamic HP Filter

Postby xprimexinverse » Fri Mar 17, 2017 9:59 pm

Hi,

Regarding (1), you don't actually need to include a lead term in the state vector. In the paper that you provide a link to, the authors have written the model using a "future version" of the state-space form. In a companion paper, the authors express the same model in the "contemporaneous version" of the state-space form. The companion paper is available here: http://www.bis.org/publ/work404.pdf. To circumvent the lead term problem that you've encountered, follow paper 404, instead of paper 442.

The "static" version of the HP filter is thus shown in the code below.

Code: Select all

' Measurement equation
  static_hp.append @signal Y = Y_STAR + EPS1
  static_hp.append @ename EPS1
  static_hp.append @evar var(EPS1) = 1
 
' State equation (Y_STAR)
  static_hp.append @state Y_STAR = 2 * Y_STAR(-1) - 1 * Y_STAR2(-1) + EPS0
  static_hp.append @ename EPS0
  static_hp.append @evar var(EPS0) = 1 / 1600
 
' State equation (Y_STAR2) - this is an "augmented" state variable
  static_hp.append @state Y_STAR2 = Y_STAR(-1)


Answering (2) is a little trickier, but let's try.

First, let's write the code for the "dynamic" version of the HP filter. This is shown in the code below.

Note that there is a constraint on the beta parameter such that 0 < beta < 0.95 and this is written in EViews code below as (0.95 - exp(c(1))). For more information about parameter constraints, see the following thread: viewtopic.php?t=48.

Code: Select all

' Measurement equation
  dynamic_hp.append @signal Y = Y_STAR + EPS2 + (0.95 - exp(c(1))) * (Y(-1) - Y_STAR2)
  dynamic_hp.append @ename EPS2
  dynamic_hp.append @evar var(EPS2) = 1
 
' State equation (Y_STAR)
  dynamic_hp.append @state Y_STAR = 2 * Y_STAR(-1) - 1 * Y_STAR2(-1) + EPS0
  dynamic_hp.append @ename EPS0
  dynamic_hp.append @evar var(EPS0) = 1 / 1600
 
' State equation (Y_STAR2) - this is an "augented" state variable
  dynamic_hp.append @state Y_STAR2 = Y_STAR(-1)


The final part involves introducing a scaling factor. I think you can do this by multiplying the variance of EPS0 by some number. To find the correct scaling factor requires iterating until the condition below holds. This is the same condition that you referred to.

VAR[Y(t) - Y*(hp, t)] / VAR[∆Y*(hp, t) - ∆Y*(hp, t-1)] = VAR[Y(t) - Y*(alt, t)] / VAR[∆Y*(alt, t) - ∆Y*(alt, t-1)]

You can calculate the left hand side of the condition as shown below, where HPT is a double differenced static HP trend (∆Y*(hp, t) - ∆Y*(hp, t-1)) and HPC is the cyclical component from the static HP model (Y(t) - Y*(hp, t)).

Code: Select all

  series DD_HPT = d(HPT,2)
  scalar STATIC_HP_RATIO = @stdev(HPC) / @stdev(DD_HPT)


The next step is to make the same calculations above using the trend and cycle from the dynamic HP filter. To do this, just replace HPT with the dynamic filter trend and HPC with the dynamic filter cycle. This will give you an estimate for the DYNAMIC_HP_RATIO. This is the right hand side of the condition.

Lastly, multiply the variance of EPS0 by some number which brings DYNAMIC_HP_RATIO in line with STATIC_HP_RATIO. In other words, change the lines of code below until this condition holds: DYNAMIC_HP_RATIO = STATIC_HP_RATIO.

Code: Select all

  scalar scale = 2    ' Keep changing this number until the two ratios are equal
  dynamic_hp.append @evar var(EPS0) = 1 / 1600 * scale


The same method seems to work when introducing financial variables. Note, however, that this method using EViews is classical in spirit whereas the authors use a Bayesian approach. For that reason, you may need to estimate the model parameters (beta and gamma(s)) a few times and then calibrate them once you find acceptable coefficients. In effect, you can do a poor man's Bayesian estimation to get the model to work.

Hope this helps.

Cheers,
Graeme


Return to “Estimation”

Who is online

Users browsing this forum: EViews Gareth and 41 guests