BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
PG007
Calcite | Level 5

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 

1 ACCEPTED SOLUTION

Accepted Solutions
rselukar
SAS Employee

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

4 REPLIES 4
PG007
Calcite | Level 5

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 

Ksharp
Super User

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

rselukar
SAS Employee

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;

 

 

PG007
Calcite | Level 5

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 🙂

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

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