Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Programming question


From   "Antonio Rodrigues Andres" <ara@sam.sdu.dk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: Programming question
Date   Thu, 25 Dec 2003 12:44:14 +0100

Dear STATA users

I am trying to replicate the same results using the HT command in STATA. I follow Baltagi´s textbook, first estimating the fixed effects model, and then regressing within residuals on the time invariant variables using as instruments the exogenous variables (X1, Z1). The next step would be to estimate the variance components. Sigma eta is based on the square sum of within residuals

sigmaeta= sum(sqrwithin)/(NT-N)
and sigma1=(yi-Xi.Betawithin-Zi. gamma)' (yi-Xi.Betawithin-Zi. gamma)/N

However, I think that I computed wrongly sigma1

Someone could help me

Regards

Toni


DO file


*HAUSMAN TAYLOR APPROACH;

tsset pid wavenum, yearly
xthtaylor $yvar $exoght $endht if male==1, endog($endht)
xthtaylor $yvar $exoght $endht if female==1, endog ($endht)

* GENERATE LIST OF VARIABLES (Xit);

global xvars "nonwhite hhsize age age2 age3
selfemp unemp retired matleave famcare student ltsick widowed divsep nvrmar deghdeg hndalev ocse 
nch04 nch511 nch1218 sahex sahgood lninc"; 


*ENDOGENOUS VARIABLE;

global yvar "lnh"

* CREATE VECTOR OF EXOG. VARS ("X1" "Z1");

global exoght "nonwhite hhsize age age2 age3 widowed divsep nvrmar nch04 nch511 nch1218"

* CREATE VECTOR OF ENDOGENOUS VARIABLES ("X2" "Z2"), correlated with indiv. effects;

global endht "deghdeg hndalev ocse lninc sahex sahgood selfemp unemp retired matleave famcare student ltsick"

* CREATE VECTOR OF INSTRUMENTS;

global ivht "mdlninc mdsahex mdsahgood mdselfemp mdunemp mdretired mdmatleave mdfamcare mdstudent mdltsick mage mage2 mage3 mwid mdivsep mnvrmar mnch04 mnch511 mnch1218"


*WITHIN REGRESSION;

*FIRST STAGE; CONSISTENT ESTIMATES FOR TIME VARYING VARIABLES
*FOR MALES

xtreg $yvar $xvars if male==1, fe i(pid)
matrix bfix=get(_b)
matrix list bfix

predict rw, res 
gen sqrw=rw*rw
egen sumsqrw=sum(sqrw)
sort pid wavenum
egen mrw=mean(rw), by(pid)

2STEP. REGRESS WITHIN RESIDUALS AVERAGED OVER TIME ON TIME INVARIANT VARIABLES (Z) USING X1 AND Z1 AS INSTRUMENTS

regress  mrw nonwhite deghdeg hndalev ocse ( hhsize age age2 age3 widowed divsep nvrmar nch04 nch511 nch1218 nonwhite)
matrix gamma=get(_b)
matrix list gamma

*CALCULATION OF THE VARIANCE COMPONENTS

gen sigmav=(sumsqrw)/(27817-4662)
gen sigma1= (yi-xi*bw-zi*gamma)'*(yi-xi*bw-zi*gamma)****


*TRANSFORM THE VARIABLES, etc

gen =(y-theta*my)



*
*   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/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index