------------------------------------------------------------------------------- help forrollreg-------------------------------------------------------------------------------

Rolling regression estimates

rollreg[depvar varlist] [ifexp] [inrange],move(#)|add(#)|dropfirst(#)stub(abbrev)[robustbw(#) kernel(choice)noconstant graph(summary|full)]

rollregis for use with time-series data. You musttssetyour data before using these routines.depvarandvarlistmay contain time-series operators. The data may be defined as panel data, in which case the rolling regression estimates will be estimated for each time series in the panel.

Description

rollregcomputes three different varieties of rolling regression estimates. With themove()option, moving-window estimates of the specified window width are computed for the available sample period. With theadd()option, that number of periods are initially used for estimation, and the sample is extended one period at a time through the remaining sample. With thedropfirst()option, the regression is estimated for the entire sample, and then repeated, dropping initial observations until that number of observations have been excluded. All three forms of the command generate timeseries of R^2s, RMSEs, coefficient estimates and their estimated standard errors for each period.

OptionsOne (and only one) of the options

move,add, ordropfirstmust be specified.

move(#)specifies the width of the moving window for which the regression is to be estimated. It must be less than the sample size and greater than the number of regressors (including the constant term). When themoveoption is used, the generated timeseries are aligned with the last period of the window: e.g.move(24)would define an R^2 series starting in observation 24 of the defined sample.

add(#)specifies the initial size of the window for which the regression is to be estimated. It must be less than the sample size and greater than the number of regressors (including the constant term). The regression will be run over the firstadd()observations of the defined sample, then run again adding the following period, and so on, until the full sample has been employed. When theaddoption is used, the generated timeseries are aligned with the last period of the window: e.g.add(24)would define an R^2 series starting in observation 24 of the defined sample.

dropfirst(#)specifies the maximum number of periods to be omitted from the regression. It must be less than the sample size. The regression will be run over the entire defined sample, then run again dropping the first period, and so on, until the initialdropfirst()observations have been omitted from the regression. When thedropfirstoption is used, the generated timeseries are aligned with the first period of the window: e.g.dropfirst(24)would define an R^2 series of 24 observations starting in observation 1 of the defined sample.

stub(abbrev), which must be provided, specifies the "stub" from which new variable names will be created. Three summary variables are created:stub_r2,stub_RMSEandstub_N, containing the R^2, RMSE and N for each set of estimates. Two additional variables are created for each regressor:stub_varnameandstub_se_varnamefor the point estimate and estimated standard error, respectively. Ifrobustis employed, the standard errors are labelledstub_Rob_se_varname; if thebwoption is employed, the standard errors are labelledstub_AC_se_varname; and if bothrobustandbwoptions are employed, the standard errors are labelledstub_HAC_se_varname. Variables created bystubmust be new variables. If thevarlistcontains time-series operators, the dots in their names are replaced by underscores so that the resulting new variables' names are legal.

robustspecifies that the rolling regressions are to be estimated with therobustoption ofregress. That is, the estimated standard errors are to be robust to arbitrary heteroskedasticity in the error distribution.

bw(#)specifies the bandwidth to be employed in estimating the standard errors of the coefficients using autocorrelation-robust techniques. The user-written routineivreg2must be installed (viassc install ivreg2) if this option is to be employed. Please seehelp ivreg2for details of the bandwidth option. For the default (Bartlett) kernel,bw(n)corresponds toneweywithlag(n-1). If bothrobustandbwoptions are specified, the estimated standard errors are "HAC": heteroskedasticity- and autocorrelation-consistent, per Newey-West (help newey). However, other kernels may be employed (see below), and unlikenewey,ivreg2can calculate "AC" errors without a correction for heteroskedasticity. However, in that case the covariance matrix is not guaranteed to be positive definite.

kernel()Selects the kernel to be employed in autocorrelation-consistent standard error estimation (requires specification oflag()). If not specified, defaults to the Bartlett kernel. For more details, please seehelp ivreg2.

noconstantSpecifies that no constant term is to be included in the regression.

graph()with option valuesummaryspecifies that a graph of the R^2 and RMSE values be displayed and saved asstub__summ.gph. The R^2 and RMSE values resulting from a single regression over the entire sample will also be displayed on the graph. Option valuefullrequests this graph, and in addition requests a graph containing each regressor's sequence of coefficient estimates with standard error bands. The width of the confidence interval is that specified as the defaultlevel. The coefficient estimates, and standard error bands, resulting from a single regression over the entire sample will also be displayed on the graph. This additional graph will be displayed and saved asstub_coeff.gph. Prior graphs with these names will be discarded. Graphics are not available when multiple units of a panel are included in the defined sample.

Examples. webuse wpi1 . g t2 = t^2

. rollreg D.wpi t t2, move(24) stub(wpiM) graph(summary)

. rollreg D.wpi t t2, add(24) stub(wpiA)

. rollreg D.wpi t t2, dropfirst(48) stub(wpiD) bw(3) graph(summary)

. rollreg D2.wpi LD.wpi LD2.wpi t, move(48) stub(wpiM2) robust graph(full)

. webuse invest2 . tsset company time

. rollreg market L(0/1).invest time, move(8) stub(mktM)

ReferencesAmano, Robert, Gable, Jeff and Simon van Norden, 1993. "ROLLREG.SRC: A RATS procedure for rolling OLS regressions." Bank of Canada. http://ideas.repec.org/c/boc/bocode/r852701.html

AuthorChristopher F. Baum (baum@bc.edu), Boston College

AcknowledgementsThis module was adapted from RATS code cited above. I thank Nicholas J. Cox and Vince Wiggins for their useful suggestions, and Cameron Hooper for pointing out a bug in the code.

help for ivreg2 (SSC)Also see