* * Example 11.6 from pages 236-237 * Groupwise Heteroscedasticity * open data tablef7-1[1].txt calendar(panelobs=15) 1970 data(format=prn,org=columns) 1//1970:01 6//1984:01 id time c q pf lf * set logc = log(c) set logq = log(q) set logpf = log(pf) * set f2 = id==2 set f3 = id==3 set f4 = id==4 set f5 = id==5 set f6 = id==6 * linreg logc / resids # constant logpf lf logq f2 f3 f4 f5 f6 compute loglols=%logl * * ML by iterating on the calculation of the variance series. With this structure, * the group variances can be computed easily using the PANEL instruction with the * SPREADS option. * do iters=1,10 panel(spreads=firmvar) resids linreg(spread=firmvar,noprint) logc / resids # constant logpf lf logq f2 f3 f4 f5 f6 end do iters * * Do a final estimation of the WLS estimator, this time printing the output. * linreg(spread=firmvar) logc / resids # constant logpf lf logq f2 f3 f4 f5 f6 compute loglwls=%logl * cdf(title="Test of Homoscedasticity") chisqr -2*(loglols-loglwls) 5