Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: xtreg, xtdata with fixed effects in unbalanced panels


From   Scott Merryman <[email protected]>
To   [email protected]
Subject   Re: st: xtreg, xtdata with fixed effects in unbalanced panels
Date   Fri, 10 Jul 2009 15:35:31 -0500

On Fri, Jul 10, 2009 at 10:13 AM, Davide
Cantoni<[email protected]> wrote:
>
> (3) -xtdata,fe- still does not work properly with the unbalanced
> dataset, and I have not found out why. Any suggestions are still
> appreciated.
>

With unbalanced data, when -xtdata- detrends the year variable you end
up with a series of unique values:


. xtdata company year invest mvalue kstock time, fe clear

. tab year

       year |      Freq.     Percent        Cum.
------------+-----------------------------------
   1934.454 |          1        0.63        0.63
   1934.487 |          1        0.63        1.26
   1934.496 |          1        0.63        1.89
   1934.775 |          1        0.63        2.52
   1935.168 |          1        0.63        3.14
....

Here is one way around that (note - the random variable seed was set
as -set seed 12345-):

*** use -xtdata,fe to demean data
format year %9.0g
tsset company year
preserve
keep year
save foo,replace
restore

xtdata company year invest mvalue kstock time, fe clear
tab year

drop year
merge using foo

tsset year company
xtdata, fe clear

qui reg invest mval kst, r
est store xtdata

est table xtreg demeaned  xtdata , ///
       keep(mvalue kstock demean_mvalue demean_kstock) se


Which returns:
-----------------------------------------------------
    Variable |   xtreg       demeaned      xtdata
-------------+---------------------------------------
      mvalue |  .11547567                  .1155367
             |  .01224137                  .0182679
      kstock |  .39346621                 .39187308
             |   .0513649                   .050229
demean_mva~e |               .11547567
             |               .01984418
demean_kst~k |               .39346621
             |               .05353941
-----------------------------------------------------
                                         legend: b/se


Scott
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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