* * HETEROTEST.RPF * RATS Version 8, User's Guide, Example 3.1. * open data states.wks data(org=obs,format=wks) 1 50 expend pcaid pop pcinc set pcexp = expend/pop linreg pcexp / resids # constant pcaid pcinc * * Goldfeld-Quandt Test. The first 22 and last 22 are included in the two * halves, with the middle 6 omitted. * order(ranks=popr) pop linreg(smpl=popr<=22) pcexp # constant pcaid pcinc compute rss1=%rss,ndf1=%ndf linreg(smpl=popr>=29) pcexp # constant pcaid pcinc compute rss2=%rss,ndf2=%ndf * compute fstat=(rss2/ndf2)/(rss1/ndf1) cdf(title="Goldfeld-Quandt Test") ftest fstat ndf2 ndf1 * * Breusch-Pagan Tests, with POP and log(POP) * set ressqr = resids^2 set logpop = log(pop) * linreg(noprint) ressqr # constant pop cdf(title="Breusch-Pagan Test (Levels)") chisqr %trsquared 1 linreg(noprint) ressqr # constant logpop cdf(title="Breusch-Pagan Test (Logs)") chisqr %trsquared 1 * * Harvey test * set logusq = log(ressqr) linreg(noprint) logusq # constant logpop cdf(title="Harvey Test") chisqr %trsquared 1