*
* ONEBREAK.RPF
* Analysis of linear regression with single break in time sequence
*
* RATS User's Guide, Example from Section 11.3.
*
* This is based on an example from Stock & Watson, Introduction to
* Econometrics, 3rd edition, chapter 15.
*
* The model being estimated is a long distributed lag of the percentage
* change in the relative price of Orange Juice (OJ price divided by the
* overall PPI) on the "Freezing Degree Days", a measure of low
* temperatures in the growing region.
*
cal(m) 1947:1
*
open data ch15_oj.rat
data(format=rats) 1947:1 2001:12 ppioj pwfsa fdd
*
set poj = ppioj/pwfsa
set rpoj = log(poj)
set drpoj = rpoj-rpoj{1}
set drpoj = 100*drpoj
*
* APBreakTest will do a test for breaks in the specification, but can't
* do the test using the desired Newey-West correction.
*
@apbreaktest(graph) drpoj 1950:1 2000:12
# constant fdd{0 to 18}
*
* This is the regression of interest. To allow for the serial
* correlation in the residuals, this employs a Newey-West correction
* with 7 lags.
*
linreg(lags=7,lwindow=newey,define=baseeqn) drpoj 1950:1 2000:12
# constant fdd{0 to 18}
@regcorrs(number=36)
*
* This does the break test using F-statistics applied to the regressions
* with Newey-West corrections. Because the covariance matrix calculation
* needs residuals from more than one observation, there's no real
* alternative to brute force calculation of the regression with dummies.
*
compute lower=%regstart(),upper=%regend()
compute pi=.15
*
compute nobs =upper-lower+1
compute bstart=lower+fix(pi*nobs)
compute bend =upper-fix(pi*nobs)
*
* <> will be used for a graph of the test statistics.
*
set fstat lower upper = %na
*
* <> will have the dummied-out copies of the original
* regressors.
*
compute k=%nreg
dec vect[series] dummies(k)
*
compute maxf=%na
*
do time=bstart,bend
*
* Set up the dummies
*
do i=1,k
set dummies(i) = %eqnxvector(baseeqn,t)(i)*(t>time)
end do i
*
* Do the regression and get the F-statistic on the dummies.
*
linreg(noprint,lags=7,lwindow=newey) drpoj lower upper
# constant fdd{0 to 18} dummies
exclude(noprint)
# dummies
*
* EXCLUDE will give a chi-squared test with <> degrees of freedom.
* This is transformed into a approximate F statistic.
*
compute fac = float(%ndf)/float(%nobs)
compute fstat(time) = %cdstat*fac/k
if fstat(time)>maxf
compute maxf=fstat(time),bestbreak=time
end do
*
graph(grid=(t==bestbreak),header="Robust F-Statistics for Breakpoints")
# fstat