* PS8.6, using DATA8-2, to reproduce Example 8.7 read(data8-2) exptrav income pop ols exptrav income /resid=uhat * save absolute value of errors as absuhat1 genr absuhat1=abs(uhat) * auxiliary regression for the Glejer test ols absuhat1 pop * compute test statistic and p-value gen1 LM1=$n*$r2 distrib LM1 / type=chi df=1 * since heteroscedasticity is detected, divide model by pop and * estimate by OLS genr pcexp=exptrav/pop genr pcincm=income/pop genr invpop=1/pop * estimate transformed model -- note that there is no constant term ols pcexp invpop pcincm / resid=uhat noconstant * test for heteroscedasticity on the transformed model genr absuhat2=abs(uhat) ols absuhat2 pop gen1 LM2=$n*$r2 * the high p-value suggests that we cannot reject homoscedasticity and * hence OLS is acceptable distrib LM2 / type=chi df=1 * weight option in ols command is a short cut -- coeff., tstat, ess, * should be the same but Rsquared will be different genr wt=invpop*invpop ols exptrav income / weight=wt stop