Page 1 of 1

how to detrend a series?

Posted: Sat Nov 19, 2016 1:24 am
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

Re: how to detrend a series?

Posted: Sat Nov 19, 2016 8:21 am
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.

Re: how to detrend a series?

Posted: Mon Nov 21, 2016 5:55 pm
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]"?

Re: how to detrend a series?

Posted: Mon Nov 21, 2016 7:27 pm
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.