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

Re: st: egen and computing fixed effects


From   Mark Schaffer <[email protected]>
To   [email protected], "Tim R. Sass" <[email protected]>
Subject   Re: st: egen and computing fixed effects
Date   Tue, 22 Jun 2004 20:49:46 +0100 (BST)

Tim,

Quoting "Tim R. Sass" <[email protected]>:

> Statalisters -
> 
> I am trying to "manually" compute a fixed-effects estimator by
> taking the 
> differences from means of all variables and then running reg on the
> 
> demeaned data.  You may ask why in the world I would want to do
> that, but 
> that's for another post.
> 
> I have a panel of student-level data over three years.  I demean the
> data 
> as follows:
> 
> bysort student:egen nrtrgain_m = mean(nrtrgain);
> bysort student:egen charter_m = mean(charter);
> bysort student:egen nschools_m = mean(nschools);
> bysort student:egen chgschl_m = mean(chgschl);
> 
> gen d2_nrtrgain = nrtrgain - nrtrgain_m;
> gen d2_charter = charter - charter_m;
> gen d2_nschools = nschools - nschools_m;
> gen d2_chgschl = chgschl - chgschl_m;
> 
> I then run the following models:
> 
> areg  nrtrgain charter nschools chgschl,
>                   absorb(student) ;
> 
> reg   d2_nrtrgain d2_charter d2_nschools d2_chgschl ;
> 
> xtdata  nrtrgain charter nschools chgschl, fe clear;
> reg  nrtrgain charter nschools chgschl;
> 
> 
> The first and third models yield the same estimated coefficients
> (except 
> for the constant, of course), but the coefficients for the second
> model 
> (using reg on the demeaned variables) yields different results. 
> However, 
> when I eliminate all observations with missing values for any of the
> 
> variables in the model, all three models yield identical estimated
> slope 
> coefficients.
> 
> I'm guessing the problem has something to do with how egen computes
> the 
> mean for each student when there are missing observations.  I have
> read 
> through the manual and searched the archives, but still can't figure
> out 
> what is going on.  Any help would be greatly appreciated.

It's probably the following.  The means vary with the sample.  If you 
limit the sample to only observations for which you have no missings for 
any variable, you get one set of means.  If you calculate the means 
variable-by-variable, you get another set of means that will be based on 
larger samples.

For example, the first set of means for X and Y will be based only on obs 
for which X and Y are both available; the second set will be based on obs 
for which either X or Y are available.

xtreg and areg implicitly use the first set of means, whereas your manual 
fixed effects estimator uses the second set of means.

Hope this helps.

--Mark

> 
> Tim
> 
> 
> Tim R. Sass
> Professor                               Voice:   (850)644-7087
> Department of Economics         Fax:      (850)644-4535
> Florida State University                E-mail:  
> [email protected]
> Tallahassee, FL  32306-2180     Internet:
> http://garnet.acns.fsu.edu/~tsass
> 
> 
> *
> *   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/
> 



Prof. Mark Schaffer
Director, CERT
Department of Economics
School of Management & Languages
Heriot-Watt University, Edinburgh EH14 4AS
tel +44-131-451-3494 / fax +44-131-451-3008
email: [email protected]
web: http://www.sml.hw.ac.uk/ecomes
________________________________________________________________

DISCLAIMER:

This e-mail and any files transmitted with it are confidential
and intended solely for the use of the individual or entity to
whom it is addressed.  If you are not the intended recipient
you are prohibited from using any of the information contained
in this e-mail.  In such a case, please destroy all copies in
your possession and notify the sender by reply e-mail.  Heriot
Watt University does not accept liability or responsibility
for changes made to this e-mail after it was sent, or for
viruses transmitted through this e-mail.  Opinions, comments,
conclusions and other information in this e-mail that do not
relate to the official business of Heriot Watt University are
not endorsed by it.
________________________________________________________________
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index