turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- Analytics
- /
- Stat Procs
- /
- One-sided (rolling) HP filter

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-13-2014 01:23 PM

Dear all,

I have a following problem.

I would like to calculate a trend for some ratio, using one-sided Hodrick-Prescott filter. This means, I want to use rolling window and calculate the trend using only the data available up to the given period. For example

data have;

format period ddmmyy10.;

input period ddmmyy10. ratio;

datalines;

31/03/2000 7.7035308

30/06/2000 7.704633

30/09/2000 7.7113104

31/12/2000 7.7438095

31/03/2001 7.7623468

;

run;

In the output dataset I would like to have another variable with the trend for the ratio, where for the first period the trend is equal to the first value of the ratio (7.7035308), for the second period it is calculated on the basis of the first and the second value of the ratio (7.7035308 and 7.704633 respectively), for the third period – on the basis of the first, second and third value etc.

In the next step, I would like to do the same, but separately for each country A and B, using a panel dataset. For example

data have1;

format period ddmmyy10.;

input period :ddmmyy10. country :$1. ratio ;

datalines;

31/03/2000 A 7.7035308

30/06/2000 A 7.704633

30/09/2000 A 7.7113104

31/12/2000 A 7.7438095

31/03/2000 B 7.8334211

30/06/2000 B 7.8389886

30/09/2000 B 7.8344153

31/12/2000 B 7.8422493

31/03/2001 B 7.8409916

30/06/2001 B 7.8572007

;

run;

Again, I want to add another variable to the dataset with rolling HP trend, but calculated separately for country A and B.

Any ideas how to do this? I've looked at the proc timeseries but haven't found any option to include rolling window or set number of observations to be used to calculate the trend.

Best,

Chris

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-14-2014 09:10 AM

Hello Chris,

You can use the following program (based on PROC UCM in SAS/ETS):

proc ucm data=have;

id period interval=qtr;

model ratio;

irregular ;

level var=0 noest print=filter;

slope var=0.000625 noest;

estimate PROFILE;

forecast ;

run;

For more information see the UCM procedure documentation, particularly the example number 5(Trend Removal Using the Hodrick-Prescott Filter):

SAS/ETS(R) 13.2 User's Guidehttp://support.sas.com/documentation/cdl/en/etsug/67525/HTML/default/viewer.htm#etsug_ucm_examples05...

The FORECAST variable in the output data set FOR contains the one-step-ahead forecasts of RATIO that

you are looking for. Forecasts for first two quarters are missing by design because the first two observations

are needed for "initialization" (you can set them to some convenient values if you choose).

From third quarter on, the forecasts are one-sided Hodrick-Prescott filter based. For your second example,

you can use the same program with COUNTRY as a BY variable (you will need to sort your data by

COUNTRY and PERIOD).

Hope this helps.

Rajesh

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

10-15-2014 03:14 AM

Thank you. I'll look more closely at the proc ucm.

Best regards,

Chris