*
* Enders, Applied Econometric Time Series, 4th edition
* Example from Chapter 4, pages 226-227
* HEGY test
*
open data quarterly.xls
calendar(q) 1960:1
data(format=xls,org=columns) 1960:01 2012:04 m1nsa m2nsa cpinsa
*
set trend = t
*
set y = log(m1nsa)
set ysdiff = y-y{4}
set y1t = y+y{1}+y{2}+y{3}
set y2t = -y+y{1}-y{2}+y{3}
set y3t = -y+y{2}
seasonal seasons
*
* Pick the lag length on the seasonal differences by general-to-specific
* with maximum lags of 12 and a significance level of .05.
*
stwise(method=gtos,force=9,slstay=.05) ysdiff
# constant trend y1t{1} y2t{1} y3t{1 2} seasons{0 to -2} ysdiff{1 to 12}
*
* Rerun with the chosen number of lags. (The estimates will be slightly
* different because the previous regression uses the range that allows
* for 12 lags). Note that the coefficients on the deterministic
* variables depend upon the precise way in which the seasonal dummies
* are generated; that will not, however, have any effect on the other
* coefficients.
*
linreg ysdiff
# constant trend y1t{1} y2t{1} y3t{1 2} seasons{0 to -2} ysdiff{1 to 8}
compute forunit=%tstats(3)
compute forsemiannual=%tstats(4)
exclude(noprint)
# y3t{1 2}
compute forseasonal=%cdstat
*
disp "HEGY Test Statistics"
disp "Non-Seasonal Unit Root" @30 ###.### forunit
disp "Semi-Annual Unit Root" @30 ###.### forsemiannual
disp "Annual Unit Root" @30 ###.### forseasonal
*
* The @HEGY procedure will do the test. Each line in the output has a
* different set of deterministic variables. The one which matches the
* result above is the last line (Intercept, Seassonal Dummies and Trend).
*
@hegy(lags=8) y