Forecasting using SAS Forecast Server, SAS/ETS, and more

Hodrick-Prescott Filter Comparison

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

Hodrick-Prescott Filter Comparison

Dear All,

 

I'm looking into different ways of applying the Hodrick-Prescott Filter and I'm getting different results between the procedures below. I have not been able to understand these differences based on the online documentation and was hoping you might have some insight.

 

The first approach uses proc expand:

proc expand data=Int_qtr_l out=filter_data_out

method=none;

id Year_quarter2;

Convert ODR_l=ODR_l_hpt/transformout=(hp_t 1600);

Convert ODR_l=ODR_l_hpc/transformout=(hp_c 1600);

run;

 

While the 2nd uses proc UCM:

proc ucm data=Int_qtr_l ;

id Year_quarter2 interval=qtr;

model ODR_l;

irregular plot=smooth print=smooth;

level var=0 noest plot=smooth print=filter;

slope var=0.000625 noest print=filter;

estimate PROFILE;

forecast plot=(decomp);

run;

 

I was expecting the smoothed irregular component from proc ucm to match the cyclical HP series from proc expand, but there seems to be fairly large differences.

 

Any ideas?

 

Thanks 


Accepted Solutions
Solution
‎10-12-2016 10:06 AM
SAS Employee
Posts: 57

Re: Hodrick-Prescott Filter Comparison

Your expectation is reasonable.  Even if UCM and EXPAND use quite different algorithms (UCM is based on Kalman Filtering/Smoothing, while EXPAND computes HP filter by inverting a suitable matrix) the results should be close.  In my test case (shown below) this indeed happens.  Of course, numerical difference can arise for a variety of reasons when different algorithms are used.  Anyway, here is the test case (your program with a SASHEL data set).  In this case the differences are of the order 10^(-10):

 

proc ucm data=sashelp.gnp;

id date interval=qtr;

model gnp;

irregular ;

level var=0 noest ;

slope var=0.000625 noest;

estimate PROFILE;

forecast outfor=fucm lead=0;

run;

proc expand data=sashelp.gnp(keep=date gnp) out=fexp

method=none;

id date;

Convert gnp=hpt/transformout=(hp_t 1600);

Convert gnp=hpc/transformout=(hp_c 1600);

run;

data out;

merge fexp fucm(keep=date gnp s_irreg s_level);

by date;

label hpt = "HP_Trend";

label hpc = "HP_Cycle";

hptMucmt = hpt-s_level;

hpcMucmc = hpc-s_irreg;

run;

proc print data=out;

var date hptMucmt hpcMucmc;

run;

 

 

View solution in original post


All Replies
New Contributor
Posts: 3

Hodrick-Prescott Filter Comparison

Dear All,

 

I'm looking into different ways of applying the Hodrick-Prescott Filter and I'm getting different results between the procedures below. I have not been able to understand these differences based on the online documentation and was hoping you might have some insight.

 

The first approach uses proc expand:

proc expand data=Int_qtr_l out=filter_data_out

method=none;

id Year_quarter2;

Convert ODR_l=ODR_l_hpt/transformout=(hp_t 1600);

Convert ODR_l=ODR_l_hpc/transformout=(hp_c 1600);

run;

 

While the 2nd uses proc UCM:

proc ucm data=Int_qtr_l ;

id Year_quarter2 interval=qtr;

model ODR_l;

irregular plot=smooth print=smooth;

level var=0 noest plot=smooth print=filter;

slope var=0.000625 noest print=filter;

estimate PROFILE;

forecast plot=(decomp);

run;

 

I was expecting the smoothed irregular component from proc ucm to match the cyclical HP series from proc expand, but there seems to be fairly large differences.

 

Any ideas?

 

Thanks 

Super User
Posts: 10,020

Re: Hodrick-Prescott Filter Comparison

It is time series analysis, Plz post it at Forecast Forum .

Solution
‎10-12-2016 10:06 AM
SAS Employee
Posts: 57

Re: Hodrick-Prescott Filter Comparison

Your expectation is reasonable.  Even if UCM and EXPAND use quite different algorithms (UCM is based on Kalman Filtering/Smoothing, while EXPAND computes HP filter by inverting a suitable matrix) the results should be close.  In my test case (shown below) this indeed happens.  Of course, numerical difference can arise for a variety of reasons when different algorithms are used.  Anyway, here is the test case (your program with a SASHEL data set).  In this case the differences are of the order 10^(-10):

 

proc ucm data=sashelp.gnp;

id date interval=qtr;

model gnp;

irregular ;

level var=0 noest ;

slope var=0.000625 noest;

estimate PROFILE;

forecast outfor=fucm lead=0;

run;

proc expand data=sashelp.gnp(keep=date gnp) out=fexp

method=none;

id date;

Convert gnp=hpt/transformout=(hp_t 1600);

Convert gnp=hpc/transformout=(hp_c 1600);

run;

data out;

merge fexp fucm(keep=date gnp s_irreg s_level);

by date;

label hpt = "HP_Trend";

label hpc = "HP_Cycle";

hptMucmt = hpt-s_level;

hpcMucmc = hpc-s_irreg;

run;

proc print data=out;

var date hptMucmt hpcMucmc;

run;

 

 

New Contributor
Posts: 3

Re: Hodrick-Prescott Filter Comparison

Thanks for the help! 

 

In case this helps anyone else, I believe the differences were due to a single missing value in the series I hadn't noticed Smiley Happy

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 563 views
  • 0 likes
  • 3 in conversation