* * Example 13.1 from page 286 * Example 13.2 from page 292 * Example 13.3 from page 299 * Example 13.4 from page 299 * Example 13.5 from page 302 * open data tablef7-1[1].txt calendar(panelobs=15) all 6//15 data(format=prn,org=columns) 1//1 6//15 id time c q pf lf * set logc = log(c) set logq = log(q) set logpf = log(pf) * linreg logc # constant logq logpf lf * * Example 13.2 * Create dummies for 6 individuals and 15 time periods * dec vect[series] idummies(6) dec vect[series] tdummies(15) * do i=1,6 set idummies(i) = (id==i) end do i do i=1,15 set tdummies(i) = (time==i) end do i * * Regression with individual dummies * linreg logc # logq logpf lf idummies * * Regression with time dummies * linreg logc # logq logpf lf tdummies * * Regression with both set of dummies * linreg logc # constant logq logpf lf idummies tdummies * * Group means * preg(method=between) logc # constant logq logpf lf * * Example 13.3 Breusch-Pagan test * linreg logc / resids # constant logq logpf lf * panel(isum=1.0,compress) resids / mresids compute bpstat=%nobs/(2.0*(15-1))*(%normsqr(mresids)/%rss-1)**2 cdf(title="Breusch-Pagan Test") chisqr bpstat 1 * * Example 13.4 Random Effects * There's a typo in the text for the vindiv. It should be .0119... not .0199... * RATS calculates the component variances without the degrees of freedom * correction. We're feeding in the variances to reproduce the results in the text * pregress(method=random,effects=indiv,vrandom=.0036126,vindiv=.0119158) logc # constant logq logpf lf * * Example 13.5 Hausman Test. This is included in the RE output. This shows how you * would compute the test statistic if you needed to. * * Save the coefficients and covariance matrix from RE. * compute betare=%beta,varre=%xx * * Estimate Fixed Effects model. We include the CONSTANT (which washes out to a * zero coefficient with zero standard error) to simplify the calculation of the * test statistic * pregress(method=fixed,effects=indiv) logc # constant logq logpf lf test(all,vector=betare,covmat=%xx*%seesq-varre,form=chisquared,title="Hausman Test for Random Effects")