One-sided Hodrick-Prescott filter

Questions and discussions on Time Series Analysis
Kraus
Posts: 8
Joined: Tue Apr 29, 2014 8:41 am

One-sided Hodrick-Prescott filter

Unread post by Kraus »

I am struggeling with the end-point problem of the Hodrick-Prescott filter. Using a strictly one-sided HP filter seems to be a solution. Is there an easy way to implement this in the FILTER instruction? Any other suggestions to deal with the problem?
Thank you.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: One-sided Hodrick-Prescott filter

Unread post by TomDoan »

You would use DLM to do the local trend model that underlies the H-P filter and filter rather than smooth.

Code: Select all

*
* The HP filter is a local trend model. The system matrices for this can
* be generated using the procedure LOCALDLM with TYPE=TREND and
* SHOCKS=TREND.
*
@localdlm(type=trend,shocks=trend,a=ahp,c=chp,f=fhp)
*
* This is the relative variance of the measurement error to trend rate
* disturbance.
*
compute lambda = 1600.0
*
dlm(a=ahp,c=chp,f=fhp,sv=1.0,sw=1.0/lambda,presample=diffuse,$
  type=FILTER,var=concentrate,y=lgdp) / hpstates
Kraus
Posts: 8
Joined: Tue Apr 29, 2014 8:41 am

Re: One-sided Hodrick-Prescott filter

Unread post by Kraus »

Thank you. Do I get that right that in your example the equivalent of the one-sided HP filter results is to be found in the first entry of the series hpstates (series of vectors)? What is the second entry? It's non-zero. Thanks again.
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: One-sided Hodrick-Prescott filter

Unread post by TomDoan »

Kraus wrote:Thank you. Do I get that right that in your example the equivalent of the one-sided HP filter results is to be found in the first entry of the series hpstates (series of vectors)? What is the second entry? It's non-zero. Thanks again.
Correct. In this setup for the local trend model, the second state is the trend rate (i.e. local estimate of the rate of increase).
luching
Posts: 64
Joined: Mon Jun 07, 2010 4:05 pm

Re: One-sided Hodrick-Prescott filter

Unread post by luching »

Is there is a complete example code that implements the one-sided HP filter?
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: One-sided Hodrick-Prescott filter

Unread post by TomDoan »

Take HPFILTER.RPF and change TYPE=SMOOTH to TYPE=FILTER on the DLM instruction. (The FILTER instruction only does the two-sided HP Filter which is why you do the local trend model using DLM).
luching
Posts: 64
Joined: Mon Jun 07, 2010 4:05 pm

Re: One-sided Hodrick-Prescott filter

Unread post by luching »

Thanks Tom
Post Reply