# RE: st: Panel FE vs. pooled OLS with demeaned variables

 From "Alice(Libo) Sun" <[email protected]> To <[email protected]> Subject RE: st: Panel FE vs. pooled OLS with demeaned variables Date Tue, 20 Sep 2005 10:41:22 -0500

```Thank you so much!

I was wondering how I am going to program with the degree of freedom
adjustment as Mark just pointed out too.

Alice

-----Original Message-----
From: [email protected]
[mailto:[email protected]]On Behalf Of May Boggess
Sent: Tuesday, September 20, 2005 10:24 AM
To: [email protected]
Subject: Re: st: Panel FE vs. pooled OLS with demeaned variables

On Tuesday morning, Alice Sun wrote:
>
> I need to run a two-step regression similar to the fixed effect model.
> (Xtreg, fe).
>
> I first replicate the fixed effect results by running pooled OLS with
> demeaned variables (demean by groups). Yet, I got same coefficients, but
> relative larger t statistics.
>

There is a degrees-of-freedom adjustment to be made. Here is an example
that shows how that is done. Here I am primarily interested in the
coefficient, and the standard error of that coefficient, of the
independent variable "length":

clear
sysuse auto
replace length=length/10
local df = r(r) - 1
by head: egen mean  = mean(mpg)
by head: gen newmpg = mpg-mean
drop mean
by head: egen mean  = mean(len)
by head: gen newlen = len-mean
drop mean

regress newmpg newlen
mat b=e(b)
scalar vadj = e(df_r)/(e(N)-1-(e(df_m) + `df'))

cap program drop change
program change, eclass
eret post b V
end
change
eret display

You should find that the last two sets of results show the same
coefficient and standard error for "length".

--May
[email protected]

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