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
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;
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
It is time series analysis, Plz post it at Forecast Forum .
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;
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 🙂
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.