Page 1 of 1
One-sided Hodrick-Prescott filter
Posted: Mon Jul 07, 2014 8:20 am
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.
Re: One-sided Hodrick-Prescott filter
Posted: Mon Jul 07, 2014 10:28 am
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
Re: One-sided Hodrick-Prescott filter
Posted: Tue Jul 08, 2014 10:09 am
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.
Re: One-sided Hodrick-Prescott filter
Posted: Tue Jul 08, 2014 10:28 am
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).
Re: One-sided Hodrick-Prescott filter
Posted: Fri Jul 01, 2016 11:07 am
by luching
Is there is a complete example code that implements the one-sided HP filter?
Re: One-sided Hodrick-Prescott filter
Posted: Fri Jul 01, 2016 11:28 am
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).
Re: One-sided Hodrick-Prescott filter
Posted: Fri Jul 01, 2016 11:35 am
by luching
Thanks Tom