ROLLREG - rolling (linear) regressions

Use this forum to post complete RATS "procedures". Please be sure to include instructions on using the procedure and detailed references where applicable.

ROLLREG - rolling (linear) regressions

Postby TomDoan » Fri Jun 25, 2010 1:25 pm

Attached is a revision (modernization) of the Bank of Canada's ROLLREG procedure, which was written originally for version 4. This does three types of "rolling" linear regressions; the most important of which is done with the MOVE option; that does a moving window of a fixed width. (The ADD option can be done more efficiently and with more options using the RLS instruction).

rollreg.src
(7.67 KiB) Downloaded 214 times

Revised May 2011 to allow saving the history of F-statistics

This is an example of its use (using the same data set as the CONSTANT example)

testrollreg.rpf
(1.42 KiB) Downloaded 313 times


Syntax (except for options, similar to LINREG):

@ROLLREG( options ) depvar first last
# list of regressors


You choose which of the three modes with:

ADD=end of initial period.
Starting with a regression from first to ADD, adds one observation at a time to the end of the range until it does a regression from first to last

DROP=start of last regression range
Starting with a regression from first to last, drops one observation at a time from the beginning of the range until it does a regression from DROP to last

MOVE=width of moving window
Starting with a regression from first to first+MOVE-1 adds observations to the end and drops them from the start one at a time until it does a regression from last-MOVE+1 to last (i.e. there are MOVE observations in each regression)

Other options:

ROBUST/[NOROBUST]Uses the ROBUSTERRORS option to calculate the standard errors.
LAGS = number of lags to use with the ROBUST option [0]This does **not** vary with the degrees of freedom.
LWINDOW=[NEWEY]/BARTLETT/DAMPED/PARZEN/QUADRATICChooses lag window type if LAGS>0.

Output Options:

COHISTORY = VECT[SERIES] for the coefficients
SEHISTORY = VECT[SERIES] for the standard errors of the coefficients
SIGHISTORY = SERIES for the regression standard errors
(These are all similar to the options for the RLS instruction)

FHISTORY = SERIES with regression F's

PRINT]/[NOPRINT] prints the coefficient estimates
WINDOW = title for print window
GRAPH/[NOGRAPH] graphs the coefficients with two standard error bands.
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Re: ROLLREG - rolling (linear) regressions

Postby iloverats » Tue Apr 12, 2011 1:53 am

dear all
in the rolling regression
y=c+a*x1+b*x2
null hypothesis a=b=0
how can i get the" F test" series when i use the "rollreg.src" :?:

thanks :D
iloverats
 
Posts: 45
Joined: Thu Dec 02, 2010 11:32 am

Re: ROLLREG - rolling (linear) regressions

Postby TomDoan » Tue Apr 12, 2011 9:05 am

The calculations are all being done with LINREG instructions, each of which computes the %FSTAT variable. You just need to save those into a series, similar to what's being done with the SIGHISTORY option.
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Re: ROLLREG - rolling (linear) regressions

Postby challenges » Thu Apr 14, 2011 1:16 pm

Dear all,
I have tried to implement, without succeeding, the F-test mentioned by iloverats in the rollreg.src given above. In fact, I have problems with storing the F-statistics for the joint null hypothesis testing (of a and b in the example of iloverats). I used the "exlude" command in the "Moving sample regression" part of the rollreg.src, but I do not know how to save the F-stats for each window. Could you please help me to implement the F-test for this joint null hypothesis in the rollreg.src ? Thank you in advance for your help.
challenges
 
Posts: 11
Joined: Thu Apr 14, 2011 12:29 pm

Re: ROLLREG - rolling (linear) regressions

Postby TomDoan » Thu Apr 14, 2011 3:55 pm

challenges wrote:Dear all,
I have tried to implement, without succeeding, the F-test mentioned by iloverats in the rollreg.src given above. In fact, I have problems with storing the F-statistics for the joint null hypothesis testing (of a and b in the example of iloverats). I used the "exlude" command in the "Moving sample regression" part of the rollreg.src, but I do not know how to save the F-stats for each window. Could you please help me to implement the F-test for this joint null hypothesis in the rollreg.src ? Thank you in advance for your help.


The procedure posted above now has an option for this:

FHISTORY=series of regression F's
Attachments
rollreg.src
(7.67 KiB) Downloaded 166 times
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Re: ROLLREG - rolling (linear) regressions

Postby challenges » Fri Apr 15, 2011 12:28 pm

Dear Tom,

Thank you very much for your help and your quick answer. I have tried to use the rollreg.src that you provided but it gives me the following error message "## SX11. Identifier %FSTAT is Not Recognizable. Incorrect Option Field or Parameter Order? >>>>istory(cut)=%fstat<<<<" I use the 6.2 version of Rats, if you need this information. Moreover, I need to implement a specific F-test that would test the null hypothesis b=c=0 in the equation y=a+b*x1+c*x2+d*x3+e*x4. The f-test must concern only the coefficients of the two first regressors and not all the coefficients. I suppose the "exclude" command must be used in the "Moving sample regression" part of the rollreg.src.Thank you again for your help.
challenges
 
Posts: 11
Joined: Thu Apr 14, 2011 12:29 pm

Re: ROLLREG - rolling (linear) regressions

Postby TomDoan » Fri Apr 15, 2011 2:41 pm

challenges wrote:Dear Tom,

Thank you very much for your help and your quick answer. I have tried to use the rollreg.src that you provided but it gives me the following error message "## SX11. Identifier %FSTAT is Not Recognizable. Incorrect Option Field or Parameter Order? >>>>istory(cut)=%fstat<<<<" I use the 6.2 version of Rats, if you need this information. Moreover, I need to implement a specific F-test that would test the null hypothesis b=c=0 in the equation y=a+b*x1+c*x2+d*x3+e*x4. The f-test must concern only the coefficients of the two first regressors and not all the coefficients. I suppose the "exclude" command must be used in the "Moving sample regression" part of the rollreg.src.Thank you again for your help.


%FSTAT isn't defined by 6.2, and you're correct that it won't give you the result from a partial exclusion. You would need to replace

if %defined(fhistory) ; compute fhistory(cut)=%fstat

with

exclude(noprint)
# X1 X2 (whatever they're actually called)
if %defined(fhistory) ; compute fhistory(cut)=%cdstat

every place the first line occurs in the revised ROLLREG,
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Re: ROLLREG - rolling (linear) regressions

Postby challenges » Sat Apr 16, 2011 3:04 am

Dear Tom,
Thank you very much for your help and your quick reply. I would like to know what are the instructions to be used in order to display in a column only the F-stats for each window (without displaying the marginal significance) stemming from the "Exclude" command. I have tried to define the Fhistory like a vector series with all the implications in the programme, but it doesn't work. Thank you in advance.
challenges
 
Posts: 11
Joined: Thu Apr 14, 2011 12:29 pm

Re: ROLLREG - rolling (linear) regressions

Postby TomDoan » Sat Apr 16, 2011 9:14 am

challenges wrote:Dear Tom,
Thank you very much for your help and your quick reply. I would like to know what are the instructions to be used in order to display in a column only the F-stats for each window (without displaying the marginal significance) stemming from the "Exclude" command. I have tried to define the Fhistory like a vector series with all the implications in the programme, but it doesn't work. Thank you in advance.


What I described should work. You would just run rollreg with the fhistory option, then do a PRINT on the series you generated. If you couldn't adapt it to your problem, you'll have to send what you've done to support@estima.com and we'll take a look.
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Re: ROLLREG - rolling (linear) regressions

Postby challenges » Fri May 27, 2011 11:39 am

Dear all,

I have to implement in the rollreg.src a normality test of Jarque-Bera on the residuals of my regression at each iteration inside my loop. I do not need to save my residuals, but I need to print the statistics of my test as well as the p-values associated to the test. Could you please help me? I have tried to do it myself but I got errors in my program.
Thank you in advance.
challenges
 
Posts: 11
Joined: Thu Apr 14, 2011 12:29 pm

Re: ROLLREG - rolling (linear) regressions

Postby TomDoan » Mon Jun 06, 2011 9:04 am

challenges wrote:Dear all,

I have to implement in the rollreg.src a normality test of Jarque-Bera on the residuals of my regression at each iteration inside my loop. I do not need to save my residuals, but I need to print the statistics of my test as well as the p-values associated to the test. Could you please help me? I have tried to do it myself but I got errors in my program.
Thank you in advance.


If you do a STATISTICS instruction on the residuals, it will produce %JBSTAT and %JBSIGNIF as the J-B statistic and p-value. You would just need to save those into a series the way the F-statistics are saved in the revised procedure that I posted.
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Re: ROLLREG - rolling (linear) regressions

Postby challenges » Mon Jun 06, 2011 3:01 pm

Dear Tom,

Thank you very much for your quick reply and your help. It works.
Rats is great ! :wink:
challenges
 
Posts: 11
Joined: Thu Apr 14, 2011 12:29 pm

Re: ROLLREG - rolling (linear) regressions

Postby basher » Mon Jul 09, 2012 8:35 am

Hi Tom,

I am using your revised rollreg procedure for a regression of "y" on "x". As I also want to perform a hypothesis test on the slope of "x" (i.e. b=1), I replaced

if %defined(fhistory) ; compute fhistory(cut)=%fstat

with

test(noprint)
# 2
# 1
if %defined(fhistory) ; compute fhistory(cut)=%fstat

every place the first line occurs in the revised ROLLREG. However, when I write "print FHISTORY", I get error message. Also, how can I obtain the associated standard errors for the slope coefficients (along with the f-stat)? Thank you.
basher
 
Posts: 12
Joined: Tue Mar 08, 2011 7:11 am

Re: ROLLREG - rolling (linear) regressions

Postby moderator » Mon Jul 09, 2012 10:20 am

Are you are writing the PRINT command exactly as

PRINT FHISTORY

If so, that's not the correct syntax. PRINT is expecting "start" and "end" parameters before the list of series, or a / symbol telling it to use the full range of the series. For example, try

print / fhistory

Regards,
Tom Maycock
Estima
moderator
Site Admin
 
Posts: 306
Joined: Thu Oct 19, 2006 4:33 pm

Re: ROLLREG - rolling (linear) regressions

Postby TomDoan » Mon Jul 09, 2012 12:13 pm

basher wrote:Also, how can I obtain the associated standard errors for the slope coefficients (along with the f-stat)? Thank you.


Instead of trying to adapt the ROLLREG procedure to do so many other things, you're probably better off just doing the rolling regression as described in the User's Guide and doing whatever additional calculations you want after each regression.
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Next

Return to RATS Procedures

Who is online

Users browsing this forum: No registered users and 1 guest

cron