* PS8.8, using DATA8-3, for Application in Section 8.4 read(data8-3) exphlth income pop seniors genr y=exphlth/pop genr x=income/pop * estimate model and save absolute residuals, squared residuals, and * their logs ols y x seniors / resid=uhat genr absuhat=abs(uhat) genr usq=uhat*uhat genr lnusq=log(usq) * generate square and cross product variables; the flag -o generates cross * product genr sq_x=x*x genr sq_senio=seniors*seniors genr x_seni=x*seniors * ---------- Testing and estimation for the Glesjer approach -------- ols absuhat x seniors sq_x sq_senio / resid=uhat * estimate residual s.d. from the auxiliary regression genr sigmahat=absuhat-uhat * compute LM test statistic and its p-value gen1 LM1=$n*$r2 distrib LM1 / type=chi df=4 * print sigmahat and note that only one estimate is negative print sigmahat * replace negative value with original sigmahat and get weights genr d1=dum(sigmahat) genr sigma2=(d1*sigmahat)+((1-d1)*absuhat) genr wt1=1/(sigma2*sigma2) * Estimate model by FGLS which is the same as WLS ols y x seniors / weight=wt1 * ------- Testing and estimation for the Breusch-Pagan approach ------ ols usq x seniors sq_x sq_senio / resid=uhat * estimate residual s.d. from the auxiliary regression genr usqhat1=usq-uhat * compute LM test statistic and its p-value gen1 LM2=$n*$r2 distrib LM2 / type=chi df=4 * print usqhat and note that several estimates are negative print usqhat1 * replace negative values with original usqhat and get weights genr d2=dum(usqhat1) genr usqhat2=(d2*usqhat1)+((1-d2)*usq) genr wt2=1/usqhat2 * Estimate model by FGLS which is the same as WLS ols y x seniors / weight=wt2 * ---------- Testing and estimation for White's procedure --------- ols usq x seniors sq_x sq_senio x_seni / resid=uhat genr usqhat3=usq-uhat * compute LM test statistic and its p-value gen1 LM3=$n*$r2 distrib LM3 / type=chi df=5 * print usqhat and note that several estimates are negative print usqhat3; * replace negative values with original usqhat and get weights genr d3=dum(usqhat3) genr usqhat4=(d3*usqhat3)+((1-d3)*usq) genr wt3=1/usqhat4 * Estimate model by FGLS which is the same as ols ols y x seniors / weight=wt3 * ------- Test using the Harvey-Godfrey approach ------ ols lnusq x seniors sq_x sq_senio * compute LM test statistic and its p-value gen1 LM4=$n*$r2 * since the p-value is high, we do not reject homoscedasticity distrib LM4 / type=chi df=4 * Because the coefficients for x and x-squared are significant, another LM * test is done with just these ols lnusq x sq_x / resid=uhat genr lnusqhat=lnusq-uhat * compute LM test statistic and its p-value gen1 LM5=$n*$r2 distrib LM5 / type=chi df=2 * since the p-value is acceptable, we reject homoscedasticity and * procede with WLS estimation genr usqhat5=exp(lnusqhat) genr wt4=1/usqhat5 ols y x seniors / weight=wt4 stop