This hits the nail on the head. To get the same sample,
egen nmiss = rmiss(nrtrgain charter nschools chgschl student)
and work with observations for which nmiss == 0
(unless -areg- can cope with missing -student-).
Nick
[email protected]
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]]On Behalf Of Michael
> Blasnik
> Sent: 22 June 2004 20:46
> To: [email protected]
> Subject: st: Re: egen and computing fixed effects
>
>
> The problem isn't how egen calculates the mean, the means are
> calculated as
> you would expect -- for all non-missing observations for each
> variable.
> These means will include observations that may be missing on
> other variables
> in your regression. You need to calculate the means only for
> the estimation
> sample (excluding observations with missing values on any of
> the variables)
> if you want the same answer.
>
> Michael Blasnik
> [email protected]
>
>
> ----- Original Message -----
> From: "Tim R. Sass" <[email protected]>
> To: <[email protected]>
> Sent: Tuesday, June 22, 2004 3:25 PM
> Subject: st: egen and computing fixed effects
>
>
> > 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.
> >
> > 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/
>
*
* 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/