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).
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)
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.
