Dear Stata users
I have this incomplete HT STATA code. I post this message some days ago
but I havent received any answer. I would like to know if someone is
able to help me.
**Model yit=Xit*b + Zi *gamma + alpha_{i} + uit
*GENERATE LIST OF ENDOGENOUS VARIABLE;
global yvar "lwage"; dependent variable
* GENERATE LIST OF EXPLANATORY VARIABLES (Xit and Zi);
global z1 "fem blk" exogenous time invariant variables
global z2 "ed" endogenous time invariant variables
global x1 "wks south smsa ms" exogenous time variant variables
global x2 "occ ind union exp exp2" endogenous time invariant variables
**FIRST STEP- WITHIN REGRESSION (consistent estimates for beta)
*WITHIN REGRESSION;
regress devlwage devwks devsouth devsmsa devms devocc devind devunion
devexp2 devmy76 devmy77 devmy78 devmy79 devmy80 devmy81 devmy82,
noconstant
*WITHIN RESIDUALS;
predict residu, residuals
ge sqresidu=residu*residu
*SQUARED SUM OF WITHIN RESIDUALS;
egen sumsqru=sum(sqresidu)
*CREATE SIGMA2ETA (Hausman Taylor p. 1384). consistent
estimate of sigma2eta;
gen sigmau=sumsqru/(4164-595) */ NT=4164 N=595
su sumsqru sqresidu sigmau
**using within residuals we get a consistent estimate
**2STEP- get within residuals and average them over time
*GENERATE di (group means of within residuals);
egen mresidu=mean(residu), by (id)
*2SLS Regressing group means of the within residuals on the exogenous
and endogenous time invariant using as instruments x1 and z1. We get
consistent estimates for gamma***
ivreg mresidu fem blk (ed= wks south smsa ms)
**3 step -get consistent estimates for sigma_{alpha}. Expression given
in HT article published in Econometrica, pag 1384. I think that there is
a mistake here.
( yi-Xi*beta(within)-Zi*gamma(2sls))'
(yi-Xi*beta(within)-Zi*gamma(2sls))
where yi Xi are the group means of y and X respectively
As di=yi-Xi*beta(within) then di-Zi*gamma(2sls) are the residuals from
the 2sls above
*save residuals
predict resiv, residuals
gen sqresiv=resiv*resiv
* squared sum of 2SLS residuals
egen sumresiv=sum(sqresiv)
*gammav is obtained from the above 2SLS regression
gen sigmat=sumresiv/N N=NUMBER OF INDIVIDUALS
>>>>>>>>>>>>>>>>>>>>>>
But this last estimate seems to be wrong. Do you know what is wrong?
FINAL STEP- RUN 2SLS ON THE TRANSFORMED MODEL using as instruments for
Z2 the mean of the exogenous time variant variables and for the
endogenous time variant variables we use their mean deviations
This should give the same results as
xthtaylor $yvar $exog $endog, endog(Z2 x2)
All the best
Antonio
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/