* * Numerical Illustration from section 4.4 * pp 121-126 * open data auto1.asc cal(q) 1959:1 data(format=prn,org=columns) 1959:1 1992:1 gcng gcngq gdc gydq pop16 x2 x3 y * * Figure 4.2 appears to show the series standardized, by subtracting the sample * mean and dividing by the sample standard deviation. You can do this * transformation with the instruction DIFF(STANDARDIZE). * diff(standardize) y 1959:1 1973:3 ys diff(standardize) x3 1959:1 1973:3 x3s diff(standardize) x2 1959:1 1973:3 x2s graph(key=attached,klabels=||"Gas","Price","Income"||,$ footer="Figure 4.2 Gasoline Consumption, Income and Price") 3 # ys # x2s # x3s * * The StabTest procedure does the Hansen test for parameter instability * @stabtest y 1959:1 1971:3 # constant x2 x3 * * Analysis of forecast errors * compute rss1=%rss,ndf1=%ndf prj(stderrs=fstderr) forecast 1971:4 1973:3 report(action=define,hlabels=||"Date","Actual","Forecast","Y-YHat","Forecast SE","t-Value"||) do time=1971:4,1973:3 report(row=new,atcol=1) %datelabel(time) y(time) forecast(time) y(time)-forecast(time) fstderr(time) (y(time)-forecast(time))/fstderr(time) end do time report(action=format,width=9) linreg(noprint) y 1959:1 1973:3 # constant x2 x3 report(row=new) report(row=new,atcol=1,span) "Tests of Parameter Constancy over:"+%datelabel(1971:4)+" to "+%datelabel(1973:3) compute f=((%rss-rss1)/8)/(rss1/ndf1) disp(store=chowtest) "Chow F(8,48) =" *.##### ((%rss-rss1)/8)/(rss1/ndf1) "[" %ftest(f,8,48) "]" report(row=new,atcol=1,span) chowtest report(action=show,window="Analysis of One-Step Forecasts") * * Recursive analysis. The recursive estimates are done with the instruction * RLS. The COHIST and SEHIST options provide a VECTOR[SERIES] with the "histories" * of the coefficients and the standard errors of the coefficient estimates, while * SIGHIST gives the standard errors of the regression. The CSQUARED option returns * the sum of squared recursive residuals, which will also be the sequence of sums of * squared residuals from the regressions. * rls(sehist=sehist,cohist=cohist,sighist=sighist,csquared=cusumsq) y 1959:1 1973:3 rresids # constant x2 x3 * set lower = -2*sighist set upper = 2*sighist graph(footer="Figure 4.3 Recursive Residuals and Standard Error Bands for the Gasoline Equation") 3 # rresids # lower # upper / 2 set lower = cohist(1)-2*sehist(1) set upper = cohist(1)+2*sehist(1) graph(footer="Recursive Estimates of Intercept") 3 # cohist(1) # lower # upper set lower = cohist(2)-2*sehist(2) set upper = cohist(2)+2*sehist(2) graph(footer="Recursive Estimates of Price Coefficient") 3 # cohist(2) # lower # upper set lower = cohist(3)-2*sehist(3) set upper = cohist(3)+2*sehist(3) graph(footer="Recursive Estimates of Income Coefficient") 3 # cohist(3) # lower # upper * * Do the sequential F-test graph shown in figure 4.4. Since the cusumsq series has the * RSS's, the F-tests themselves are fairly easy. The second stage takes the F-tests and * converts them into a ratio to the critical value, which changes with t, since the * denominator degrees of freedom changes. %invftest is used for that. * set seqf = (t-%nreg-%regstart())*(cusumsq-cusumsq{1})/cusumsq{1} set seqfcval %regstart()+%nreg+1 * = seqf/%invftest(.05,1,t-%nreg-%regstart()) graph(footer="Figure 4.4 Sequential F-Tests as Ratio to .05 Critical Value",vgrid=||1.0||) # seqfcval * * Do the RESET test. This uses the regression post-processor @RegRESET. You apply * this immediately after the regression that you want to test. * linreg y 1959:1 1973:3 # constant x2 x3 @regreset(h=2)