how to detrend a series?

Use this forum to post questions about syntax problems or general programming issues. Questions on implementing a particular aspect of econometrics should go in "Econometrics Issues" below.
applej
Posts: 20
Joined: Thu May 14, 2015 9:17 am

how to detrend a series?

Unread post by applej »

Dear Tom,

I want see the deviation from trend of my interested series, RRG. Thus, I want to detrend it first. My code is written as:

linreg rrg 1968:5 2014:12
# constant t

But I got error: ## SR3. Tried to Use Series Number 39, Only 32 Are Available

It would be good to know any of your suggestions.

Thank you,
J
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: how to detrend a series?

Unread post by TomDoan »

Do

set trend = t

and use TREND (not T) in the regression. T is a reserved variable used as a entry pointer in expressions.

You could also just do FILTER with the option REMOVE=TREND.
applej
Posts: 20
Joined: Thu May 14, 2015 9:17 am

Re: how to detrend a series?

Unread post by applej »

TomDoan wrote:Do

set trend = t

and use TREND (not T) in the regression. T is a reserved variable used as a entry pointer in expressions.

You could also just do FILTER with the option REMOVE=TREND.
Thank you for the above comments. :) I did the following and want to get the fitted dependent variable. :

lingreg rlogg 1968:4 2014:12
# constant trend

set rloggfit %regstart() %regend = %beta(1) + %beta(2)*trend

However, I got the error:

## SX22. Expected Type SERIES[REAL], Got RECTANGULAR[REAL] Instead
>>>>set loggfit <<<<

I wonder why it got "RECTANGULAR[REAL]"?
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: how to detrend a series?

Unread post by TomDoan »

applej wrote:
TomDoan wrote:Do

set trend = t

and use TREND (not T) in the regression. T is a reserved variable used as a entry pointer in expressions.

You could also just do FILTER with the option REMOVE=TREND.
Thank you for the above comments. :) I did the following and want to get the fitted dependent variable. :

lingreg rlogg 1968:4 2014:12
# constant trend

set rloggfit %regstart() %regend = %beta(1) + %beta(2)*trend

However, I got the error:

## SX22. Expected Type SERIES[REAL], Got RECTANGULAR[REAL] Instead
>>>>set loggfit <<<<

I wonder why it got "RECTANGULAR[REAL]"?
First, you can just do

prj rloggfit

to get the fitted values from the regression (any LINREG). The line you're showing as producing an error is different from the one that you showed originally, so I don't know if you use loggfit in some other way.
Post Reply