Tim,
Here is an example of estimating a two-way fixed effects using
1. time dummies and -xtreg ,fe-
2. demean the time dimension and use -xtreg ,fe-
3. demean both the time and cross-section dimensions and use -reg-
4. Use -xtdata, fe- to demean in both dimensions and use -reg-
All the methods produce the same estimated coefficients:
------------------------------------------------------------------
Variable | xtreg demeaned demeaned2 xtdata
-------------+----------------------------------------------------
mvalue | .11771585 .11771585
kstock | .35791627 .35791627
demean_mva~e | .11771585
demean_kst~k | .35791627
demean2_mv~e | .11771584
demean2_ks~k | .35791625
------------------------------------------------------------------
*********************************************************************
webuse grunfeld, clear
xi i.time, pre(D)
qui xtreg inv mval kstock D*, fe
est store xtreg
*Demean in time dimension
foreach var of varlist invest mvalue kstock {
egen mean_`var'_time = mean(`var'), by(time)
gen demean_`var' = mean_`var'_time - `var'
}
qui xtreg demean_invest demean_mvalue demean_kstock, fe
est store demeaned
*Demean in the time and cross-section dimensions
foreach var of varlist invest mvalue kstock {
egen mean_`var'_time_com = mean(demean_`var'), by(com)
gen demean2_`var' = mean_`var'_time_com - demean_`var'
}
qui reg demean2_invest demean2_mvalue demean2_kstock
est store demeaned2
*Use -xtdata,fe to demaean data
xtdata com year invest mvalue kstock time, fe clear
tsset time com
xtdata, fe clear
qui reg invest mval kst
est store xtdata
est table xtreg demeaned demeaned2 xtdata, ///
keep(mvalue kstock demean_mvalue demean_kstock ///
demean2_mvalue demean2_kstock )
Hope this helps,
Scott
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Tim R. Sass
Sent: Thursday, July 08, 2004 3:50 PM
To: [email protected]
Subject: st: Estimating Three-Way Fixed Effects
Dear List Members -
I have panel data on student achievement. I want to estimate a model that
includes fixed effects for students, schools and time:
Yijt = ai + bj + ct + dXijt + eijt
where i indexes students, j indexes schools and t indexes time. The number
of time periods is small so I can include explicit time dummies to control
for time:
(1) Yijt = ai + bj + c1T1 + .... + cnTn + dXijt + eijt
However, the numbers of students and schools are both large, thus running
OLS with dummy variables is not feasible.
According to Greene (Econometric Analysis, 2nd ed., pp. 468-469) a solution
to the problem is to estimate the following:
(2) Y*ijt = f1T1* + ... + fnTn* + gX*ijt + e*ijt
where Y*ijt = Yij - (student's mean Y over time) - (school's mean Y over
all students) + (mean Y averaged over all students and schools). Likewise
for T1*...Tn* and X*.
It would seem that this approach could be implemented in Stata in either of
the following ways:
(a) explicitly calculate the de-meaned variables, Y*, T1*...Tn* and X* and
run .reg using these de-meaned variables
(b) take the difference between each observation and the school mean (ie.
(Yijt - (school mean over all students)), etc.) and run xtreg or areg with
student fixed effects.
I have run both models (a) and (b) on a small data set where I can also
estimate the model with explicit student, school and time dummies.
Both methods (a) and (b) yield coefficient estimates that are different
from one another and different from the model with explicit dummy variables
for all three effects. Bob Bifulco (U. Conn.) has been working on the same
problem with a different data set and comes up with the same inconsistent
results. A copy of my .do file and results follows. Any suggestions would
be greatly appreciated.
Tim
<snip do file>
*
* 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/