* * CONSTANT.RPF * Example of tests for structural stability in a linear model. * * RATS User's Guide, example from Section 3.7. * open data auto1.asc cal(q) 1959:1 data(format=prn,org=columns) 1959:1 1973:3 x2 x3 y * * The StabTest procedure does the Hansen test for parameter instability * @stabtest y 1959:1 1973:3 # constant x2 x3 * * Chow predictive test over the next two years after 1971:3 * linreg(noprint) y 1959:1 1971:3 # constant x2 x3 compute rss1=%rss,ndf1=%ndf linreg(noprint) y 1959:1 1973:3 # constant x2 x3 compute f=((%rss-rss1)/8)/(rss1/ndf1) cdf(title="Chow Predictive Test") ftest f 8 ndf1 * * Tests and graphs based upon recursive estimation * rls(sehist=sehist,cohist=cohist,sighist=sighist,\$ csum=cusum,csquared=cusumsq) y 1959:1 1973:3 rresids # constant x2 x3 * * rstart is the first observation without a perfect fit * compute rstart=%regstart()+%nreg * * This graphs the recursive residuals with the upper and lower two * (recursively generated) standard error bands. * set lower = -2*sighist set upper = 2*sighist graph(header="Recursive Residuals and Standard Error Bands") 3 # rresids # lower / 2 # upper / 2 * * CUSUM test with upper and lower bounds (done directly) * set cusum = cusum/sqrt(%seesq) set upper5 rstart 1973:3 = .948*sqrt(%ndf)*\$ (1+2.0*(t-rstart+1)/%ndf) set lower5 rstart 1973:3 = -upper5 graph(header="CUSUM test") 3 # cusum # lower5 / 2 # upper5 / 2 * * Same thing done with @CUSUMTESTS * @cusumtests rresids * * Sequential F-Tests. These are generated quite easily using the * cumulated sum of squares from RLS. * set seqf = (t-rstart)*(cusumsq-cusumsq{1})/cusumsq{1} set seqfcval rstart+1 * = seqf/%invftest(.05,1,t-rstart) graph(vgrid=||1.0||,header=\$ "Sequential F-Tests as Ratio to .05 Critical Value") # seqfcval