*
*  HETERO.PRG
*  Manual Example 6.1
*
open data states.wks
allocate 50
data(org=obs,format=wks) / expend pcaid pop pcinc
order(all) pop
set pcexp = expend/pop
linreg pcexp / resids
# constant pcaid pcinc
*
*  Goldfeld-Quandt Test
*
linreg(noprint) pcexp 1 22
# constant pcaid pcinc
compute rss1=%rss,ndf1=%ndf
linreg(noprint) pcexp 29 50
# constant pcaid pcinc
compute rss2=%rss,ndf2=%ndf
*
compute fstat=(rss2/ndf2)/(rss1/ndf1)
cdf  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
compute chistat=%nobs*%rsquared
cdf chisqr chistat 1
linreg(noprint) ressqr
# constant logpop
compute chistat=%nobs*%rsquared
cdf chisqr chistat 1

