Statalist The Stata Listserver

[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: Re:st: Re: fixed effects vs random effects

From   "Rodrigo A. Alfaro" <>
To   <>
Subject   Re: Re:st: Re: fixed effects vs random effects
Date   Sat, 3 Feb 2007 23:28:54 -0500


(1) You are using IV in the third step of HT!! then you could use -ivreg2-
but the approach is different, FE or FD instead of RE!!

(2) Below it is an example of doing HT "by hand"... requires an improvement
for unbalanced case using the formulae of the manual, after that you could 
as instruments as you wish in the third step.

(3) I didn't ask for your R2's. I would like to know why you say that some X
has small within variation. Pretend x1 is that variable, then I would like 
to see
-xtsum x1- in order to understand what you mean by small variation.

(4) I would like to point you that merges are treated differently by 
For example, you have banks A and B, they merged and what you have...
bank A or B is not longer in the dataset, but this does not mean that B is 
in the market, also you are over-estimating the effect of A!!! I read long 
ago about this, it is not easy to think about it... but some authors suggest 
keep A and B separated dividing the new A, and depending of the case, maybe
considering a new C that hits the market. You should search how they deal
with mergers... it is not the same as randomly unbalanced panel.


/***************** Example *******************************/
/// Setting
qui {
webuse psidextract, clear
local tv "lwage wks south smsa ms exp exp2 occ ind union"
local ti "fem blk ed"
keep `tv' `ti' id t
sort id t
tsset id t
foreach i of varlist `tv' {
by id: egen double `i'_m=mean(`i')
gen double `i'_dm = `i'-`i'_m

/// First step
reg lwage_dm wks_dm south_dm smsa_dm ms_dm exp_dm exp2_dm ///
occ_dm ind_dm union_dm, noc
sca sig_e2=e(rss)/3570
mat beta=e(b)
mat colnames beta = wks_m south_m smsa_m ms_m exp_m exp2_m ///
occ_m ind_m union_m
mat score double xbm_w = beta
gen double di = lwage_m - xbm_w
mat colnames beta = wks south smsa ms exp exp2 occ ind union
mat score double xb_w = beta

/// Second step
reg di fem blk ed (wks south smsa ms fem blk)
predict double zg, xb
reg di fem blk ed (wks_m south_m smsa_m ms_m fem blk) if t==7
predict double zg2, xb

/// Error and theta
g double fit1=lwage - xb_w - zg2
by id: gen double fit2=sum(fit1)
by id: replace fit2=(fit2[_N]/7)^2
sum fit2, meanonly
sca s2=r(sum)/595
sca sig_u2=(s2-sig_e2)/7
gen double theta=1-sqrt(sig_e2/(sig_e2+7*sig_u2))

/// GLS
foreach i of varlist `tv' {
gen `i'_g=`i'-theta*`i'_m
foreach i of varlist `ti' {
gen `i'_g=(1-theta)*`i'

/// More Instruments (for AM)
foreach i of varlist wks south smsa ms exp exp2 occ ind union {
forvalues k=1/7 {
gen aux=0
replace aux=`i' if t==`k'
by id: egen `i'_t`k'=sum(aux)
drop aux

/// Third step
reg lwage_g wks_g south_g smsa_g ms_g exp_g exp2_g ///
occ_g ind_g union_g fem_g blk_g ed_g ///
(*_dm south_m smsa_m occ_m ind_m fem blk), nohead
xthtaylor lwage wks south smsa ms exp exp2 occ ind ///
union fem blk ed, endog(wks ms exp exp2 union ed)
reg lwage_g wks_g south_g smsa_g ms_g exp_g exp2_g ///
occ_g ind_g union_g fem_g blk_g ed_g ///
(*_dm south_t* smsa_t* occ_t* ind_t* fem blk), nohead
xthtaylor lwage wks south smsa ms exp exp2 occ ind ///
union fem blk ed, endog(wks ms exp exp2 union ed) am

/***************** End Example ****************************/

----- Original Message ----- 
From: "tabreez shams" <>
To: <>; <>
Sent: Saturday, February 03, 2007 7:50 AM
Subject: Re: Re:st: Re: fixed effects vs random effects

Dear All,
Thanks to all who have contributed to my query on FE
vs RE as means of addressing both unobserved effect
and endogeneity where regressors are less
time-variant. Some comments to your suggestions are in

Kit Baum: Presence of more than one endogenous
variable complicates estimating the equation using
xtivreg2 (which is considered to be single equation
model). An alternative resort could be estimating the
equations using 3sls with reg3. However, I am not sure
if this 3sls is recommended if the number of equations
increases. Moreover, the equations in the system need
to be identified and hence require adjustment to make
the system identifiable! Comments on this issue will
be helpful.

Daniel Hoechle: I was not aware of this Driscoll-Kraay
estimation procedure. Thanks for introducing this to
me. Much appreciate if I can avail a copy of the macro
including 2sls estimator.

Rodrigo: I am novice in programming stuffs and hence
may not be able to follow your suggestion in adjusting
HT for including instrument at the third step. Yet, I
tried with the standard one with xthataylor but this
requires at least one time-invariant endogenous and
exogenous variable where I have only one endogenous
time-invariant variable. For your interest, I am
including the following information regarding my data
and results:

1.The value of R-square with FE estimation is: within
= 0.4727 , between = 0.0628 , and sigma u =
0.39716817, sigma e = .21452491 and rho = .7741.

2.My sample is constructed on the basis of top 300 US
firms at the end of 2004 and the data is unbalanced as
the firms merged or acquired over the sample period
1997 to 2004.

Further query: I shall highly appreciate any comments
on: to what extent pooled-OLS with cluster by firm id
option able to address unobserved effect.

Thank you once again for your time and understanding
and helpful comments. Have a nice week end!

PhD candidate
Accounting and Finance Dept.
Monash University

--- Daniel Hoechle <> wrote:

> Hi,
> This is a really interesting discussion. I think
> Rodrigo is right in
> saying that the standard Fama-MacBeth procedure is
> not appropriate
> here because of the endogeneity problem. However,
> Antoni Sureda
> provides a version of the Fama-MacBeth approach
> which is based on the
> IV-estimator rather than on the OLS estimator. His
> -fmivreg- program
> is available from
> What could also be an interesting path to proceed is
> to estimate the
> regression model with Driscoll-Kraay standard
> errors. Why? If the
> panel is unbalanced then the panel might well be a
> microeconometric
> panel and these panels are likely to be
> cross-sectionally dependent
> (due to things like social norms, neighborhood
> effects, and all sorts
> of behavioral biases). Because Driscoll-Kraay
> standard errors are
> heteroscedasticity consistent and robust to very
> general forms of
> temporal and cross-sectional dependence, they might
> be interesting in
> this respect. I implemented the Driscoll-Kraay
> estimator for use with
> both balanced and unbalanced panels in my -xtscc-
> program (in Stata
> type -net search xtscc-). Unfortunately, however,
> the -xtscc- program
> currently does not allow for estimation of IV
> regression models but it
> would be straightforward to generalize the -xtscc-
> program such that
> it includes the 2SLS estimator. Please let me know
> if this would be of
> interest for anyone.
> Finally, if there is no cross-sectional dependence,
> then I think it
> could be a simple but tractable way to estimate the
> regression model
> by aid of the 2SLS estimator with panel-robust
> ("clustered" or Rogers)
> standard errors. Monte Carlo simulations have shown
> that panel-robust
> standard errors are robust to subject specific fixed
> effects.
> Best,
> Dan
> *
> *   For searches and help try:
> *
> *
> *

Yahoo! Music Unlimited
Access over 1 million songs.
*   For searches and help try:

*   For searches and help try:

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