*
* Dougherty, Introduction to Econometrics, 4th ed
* Example from Section 8.5
* Instrumental variables
*
open data eaef21c.xls
data(format=xls,org=columns) 1 540 id female male ethblack ethhisp ethwhite age s educprof educphd educmast $
educba educaa educhsd educdo single married divorced faithn faithp faithc faithj faitho asvab01 asvab02 $
asvab03 asvab04 asvab05 asvab06 asvabc height weight85 weight02 sm sf siblings library pov78 earnings $
hours tenure exper collbarg catgov catpri catse urban regne regnc regw regs
*
set lgearn = log(earnings)
*
linreg lgearn
# constant s exper
*
* Instrumental variables is done in RATS by creating an instruments list using the
* instruction INSTRUMENTS, then using the INST option on the LINREG instruction.
* Other than the INST option, the LINREG shows the equation that you're trying to
* estimate just as you do for least squares. The instrument list includes all the
* explanatory variables that don't need instruments (here CONSTANT and EXPER) and
* any instruments you need for the ones that do.
*
instruments constant exper sm
linreg(inst) lgearn
# constant s exper
*
* More instruments
*
instruments constant exper sm sf siblings library
linreg(inst) lgearn
# constant s exper
*
* More covariates
*
instruments constant exper asvabc male ethblack ethhisp sm sf siblings library
linreg(inst) lgearn
# constant s exper asvabc male ethblack ethhisp
compute xxiv=%xx,betaiv=%beta,sigsqiv=%seesq
*
* Durbin-Wu-Hausman test done using the @REGWUTEST procedure
*
@regwutest
*
* Test done using comparison of regressions. This is even more complicated than
* described in the text because the rank should actually be one (not six and not
* three, which is what RATS will come up with). The difficulty comes about because
* the covariance matrix of the difference is singular, but because of numerical
* roundoff, the program has to make a guess as to which of the eigenvalues are
* actually zero. The @REGWUTEST procedure does the calculation knowing exactly
* what is being tested, and so comes up with the correct degrees of freedom.
*
linreg lgearn
# constant s exper asvabc male ethblack ethhisp
compute xxols=%xx,betaols=%beta
*
test(title="Durbin-Wu-Hausman test",covmat=%seesq*(xxiv-xxols),vector=betaiv,form=chisquared,all)