*
* Enders, Applied Econometric Time Series, 4th edition
* Example from Section 2.12, Pages 106-108
* Recursive Least Squares
*
open data y_break.xls
data(format=xls,org=columns) 1 150 entry y_break
*
linreg y_break
# constant y_break{1}
*
* RLS is similar to LINREG, but does recursive least squares estimates.
* The residuals are the recursive residuals, and you can get the
* histories of the coefficient and standard error estimates through the
* sample.
*
rls(cohistory=coh,sehistory=seh) y_break
# constant y_break{1}
*
set rresids = %resids
*
spgraph(vfields=3,footer="Recursive Estimates")
graph(header="Panel(a): The series")
# y_break
set lower = coh(1)-2*seh(1)
set upper = coh(1)+2*seh(1)
graph(header="Panel(b): Intercept") 3
# coh(1) 4 *
# lower 4 * 2
# upper 4 * 2
set lower = coh(2)-2*seh(2)
set upper = coh(2)+2*seh(2)
graph(header="Panel(c): AR(1) coefficient") 3
# coh(2) 4 *
# lower 4 * 2
# upper 4 * 2
spgraph(done)
*
* The @CusumTests procedure does both the CUSUM test shown in figure
* 2.10, and the CUSUMSQ test, which uses a normalized sum of squared
* recursive residuals.
*
@CusumTests rresids
*
* Create a dummy for the last 50 data points (101-150) and include in the
* regression to check for a break in the intercept.
*
set d100 = t>100
*
linreg y_break
# constant y_break{1} d100
*
* Create a dummied version of the regressor, add that to the regression and do a
* joint test of the pair of dummied variables.
*
set d100ylag = d100*y_break{1}
*
linreg y_break
# constant y_break{1} d100 d100ylag
exclude(title="Test of dummies")
# d100 d100ylag
*
* This estimates the best break using "time" as the threshold and does
* 100 bootstrap replications.
*
@threshtest(graph,nreps=100) y_break
# constant y_break{1}