*
* 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
*
cal(q) 1374:1
all 1392:1
open data Desktop\shima1.xls
data(org=col,format=xls) 1374:1 1392:1 inv expi resd labp tfpg CU imppr outg capin rip
*
set loginv = log(inv)
set logexpi = log(expi)
set logpresd = log(resd)
set loglabp = log(labp)
set logtfpg = log(tfpg)
set logcu = log(cu)
set logimppr = log(imppr)
set logoutg = log(outg)
set logcapin = log(capin)
set logrip = log(rip)
*
linreg logtfpg
# constant loginv logexpi logresd loglabp logcu logimppr logoutg logcapin logrip
*
*
*  Example 13.3 Breusch-Pagan test
*
linreg logtfpg / resids
# constant loginv logexpi logresd loglabp logcu logimppr logoutg logcapin logrip
*
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 loginv logexpi logresd loglabp logimppr logoutg logcapin logrip
*
* 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) logtfpg
# constant loginv logpexpi logresd loglabp logcu logimppr logcapin logrip
test(all,vector=betare,covmat=%xx*%seesq-varre,form=chisquared,title="Hausman Test for Random Effects")





