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

RE: st: Two-way random and fixed effect model for Panel Data


From   "Gustavo Sanchez" <[email protected]>
To   <[email protected]>
Subject   RE: st: Two-way random and fixed effect model for Panel Data
Date   Mon, 28 Feb 2005 11:04:12 -0600

On Sunday, Daniel asked:

> I hope I'll find somebady which is able to get through a specification
> problem with panel data.
>
> I want to compute a two-way random and fixed effect model like this one:
>
> yi,t= a0+consi+const+ b1Xi,t+epsiloni,t
>
> where a0 is a common constant and consi is a country specific constant
> and const is a specific time constant.
>
> I used xtreg y x dummy (for time period),re (fe) i(country) but I'm not
> sure that it's the correct way to formulate this two-way model...

Svetlana suggested:

> You can try
>
> xi: reg y i.firm i.time x1
> or
> xi: reg y i.firm i.time x1, robust
>
> for the robust version.

You can certainly used -xtreg,fe- and include the time dummies. You will get
the same results as the ones obtained using -xi:regress- See the example
below

. clear

. set mem 10m
(10240k)

. webuse nlswork
(National Longitudinal Survey.  Young Women 14-26 years of age in 1968)

. keep if id<=20
(28357 observations deleted)

. tsset idcode year
       panel variable:  idcode, 1 to 20
        time variable:  year, 68 to 88, but with gaps

. xi:xtreg ln_w age tenure  i.year, fe i(idcode)
i.year            _Iyear_68-88        (naturally coded; _Iyear_68 omitted)

Fixed-effects (within) regression               Number of obs      =
175
Group variable (i): idcode                      Number of groups   =
18

R-sq:  within  = 0.3069                         Obs per group: min =
2
       between = 0.0696                                        avg =
9.7
       overall = 0.0312                                        max =
15

                                                F(16,141)          =
3.90
corr(u_i, Xb)  = -0.7785                        Prob > F           =
0.0000

----------------------------------------------------------------------------
--
     ln_wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf.
Interval]
-------------+--------------------------------------------------------------
--
         age |   .2163456   .1259685     1.72   0.088    -.0326854
.4653766
      tenure |    .029208   .0080542     3.63   0.000     .0132854
.0451307
   _Iyear_69 |  -.0610705   .2066732    -0.30   0.768    -.4696492
.3475083
   _Iyear_70 |  -.4496718   .2829069    -1.59   0.114    -1.008959
.1096159
   _Iyear_71 |  -.6838077   .3932548    -1.74   0.084    -1.461245
.09363
   _Iyear_72 |  -.8756372   .5113781    -1.71   0.089    -1.886597
.1353222
   _Iyear_73 |  -1.005979   .6235475    -1.61   0.109     -2.23869
.2267316
   _Iyear_75 |  -1.471403   .8757545    -1.68   0.095     -3.20271
.2599033
   _Iyear_77 |  -1.941271   1.122908    -1.73   0.086    -4.161183
.2786407
   _Iyear_78 |  -2.076393   1.248898    -1.66   0.099    -4.545379
.3925926
   _Iyear_80 |  -2.601959   1.497365    -1.74   0.084    -5.562148
.3582295
   _Iyear_82 |  -3.131761   1.746915    -1.79   0.075    -6.585293
.321771
   _Iyear_83 |  -3.135278    1.87198    -1.67   0.096    -6.836054
.5654988
   _Iyear_85 |  -3.441114   2.120773    -1.62   0.107    -7.633738
.7515099
   _Iyear_87 |  -4.010854   2.372786    -1.69   0.093     -8.70169
.6799811
   _Iyear_88 |  -4.251622   2.571628    -1.65   0.100    -9.335555
.8323111
       _cons |    -2.3679   2.420624    -0.98   0.330    -7.153307
2.417507
-------------+--------------------------------------------------------------
--
     sigma_u |  .51542996
     sigma_e |  .25797362
         rho |  .79967882   (fraction of variance due to u_i)
----------------------------------------------------------------------------
--
F test that all u_i=0:     F(17, 141) =    12.34             Prob > F =
0.0000

. xi:regres ln_w age tenure  i.year i.idcode
i.year            _Iyear_68-88        (naturally coded; _Iyear_68 omitted)
i.idcode          _Iidcode_1-20       (naturally coded; _Iidcode_1 omitted)

      Source |       SS       df       MS              Number of obs =
175
-------------+------------------------------           F( 33,   141) =
9.45
       Model |  20.7606901    33   .62911182           Prob > F      =
0.0000
    Residual |  9.38360513   141  .066550391           R-squared     =
0.6887
-------------+------------------------------           Adj R-squared =
0.6159
       Total |  30.1442952   174  .173243076           Root MSE      =
.25797

----------------------------------------------------------------------------
--
     ln_wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf.
Interval]
-------------+--------------------------------------------------------------
--
         age |   .2163456   .1259685     1.72   0.088    -.0326854
.4653766
      tenure |    .029208   .0080542     3.63   0.000     .0132854
.0451307
   _Iyear_69 |  -.0610705   .2066732    -0.30   0.768    -.4696492
.3475083
   _Iyear_70 |  -.4496718   .2829069    -1.59   0.114    -1.008959
.1096159
   _Iyear_71 |  -.6838077   .3932548    -1.74   0.084    -1.461245
.09363
   _Iyear_72 |  -.8756372   .5113781    -1.71   0.089    -1.886597
.1353222
   _Iyear_73 |  -1.005979   .6235475    -1.61   0.109     -2.23869
.2267316
   _Iyear_75 |  -1.471403   .8757545    -1.68   0.095     -3.20271
.2599033
   _Iyear_77 |  -1.941271   1.122908    -1.73   0.086    -4.161183
.2786407
   _Iyear_78 |  -2.076393   1.248898    -1.66   0.099    -4.545379
.3925926
   _Iyear_80 |  -2.601959   1.497365    -1.74   0.084    -5.562148
.3582295
   _Iyear_82 |  -3.131761   1.746915    -1.79   0.075    -6.585293
.321771
   _Iyear_83 |  -3.135278    1.87198    -1.67   0.096    -6.836054
.5654988
   _Iyear_85 |  -3.441114   2.120773    -1.62   0.107    -7.633738
.7515099
   _Iyear_87 |  -4.010854   2.372786    -1.69   0.093     -8.70169
.6799811
   _Iyear_88 |  -4.251622   2.571628    -1.65   0.100    -9.335555
.8323111
  _Iidcode_2 |  -.4052557   .1065452    -3.80
0.000    -.6158883   -.1946231
  _Iidcode_3 |  -1.779763   .7502473    -2.37
0.019     -3.26295   -.2965755
  _Iidcode_4 |  -1.367843    .762298    -1.79   0.075    -2.874854
.1391677
  _Iidcode_5 |  -1.435239   .7573151    -1.90   0.060    -2.932399
.0619212
  _Iidcode_6 |  -1.471493   .6282069    -2.34
0.021    -2.713415   -.2295713
  _Iidcode_7 |  -1.251497   .3362335    -3.72
0.000    -1.916208   -.5867862
  _Iidcode_9 |  -.1895229   .1203334    -1.57   0.118    -.4274137
.0483679
 _Iidcode_10 |  -.6424414   .1163439    -5.52
0.000    -.8724453   -.4124375
 _Iidcode_12 |  -.3507719   .4964787    -0.71   0.481    -1.332276
.6307325
 _Iidcode_13 |  -.6464649   .5042873    -1.28   0.202    -1.643406
.3504766
 _Iidcode_14 |  -.8292302   .5097123    -1.63   0.106    -1.836897
.1784361
 _Iidcode_15 |  -.2628088   .3821977    -0.69   0.493    -1.018388
.49277
 _Iidcode_16 |  -.6522392   .3865861    -1.69   0.094    -1.416494
.1120152
 _Iidcode_17 |  -.4976363   .3920352    -1.27   0.206    -1.272663
.2773905
 _Iidcode_18 |  -1.359985   .4139419    -3.29
0.001     -2.17832   -.5416504
 _Iidcode_19 |  -.7293873   .3909297    -1.87   0.064    -1.502228
.0434539
 _Iidcode_20 |  -.6100004   .3804356    -1.60   0.111    -1.362096
.1420947
       _cons |  -1.534948   2.045132    -0.75   0.454    -5.578033
2.508138
----------------------------------------------------------------------------
--

You can also use the -areg- command and include the time dummies. -xtreg,fe-
does not support the robust option but -areg- does. See the example below,
which produces the same output as the previous two estimation results.

. xi:areg ln_w age tenure  i.year, absorb(idcode)
i.year            _Iyear_68-88        (naturally coded; _Iyear_68 omitted)

                                                       Number of obs =
175
                                                       F( 16,   141) =
3.90
                                                       Prob > F      =
0.0000
                                                       R-squared     =
0.6887
                                                       Adj R-squared =
0.6159
                                                       Root MSE      =
.25797

----------------------------------------------------------------------------
--
     ln_wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf.
Interval]
-------------+--------------------------------------------------------------
--
         age |   .2163456   .1259685     1.72   0.088    -.0326854
.4653766
      tenure |    .029208   .0080542     3.63   0.000     .0132854
.0451307
   _Iyear_69 |  -.0610705   .2066732    -0.30   0.768    -.4696492
.3475083
   _Iyear_70 |  -.4496718   .2829069    -1.59   0.114    -1.008959
.1096159
   _Iyear_71 |  -.6838077   .3932548    -1.74   0.084    -1.461245
.09363
   _Iyear_72 |  -.8756372   .5113781    -1.71   0.089    -1.886597
.1353222
   _Iyear_73 |  -1.005979   .6235475    -1.61   0.109     -2.23869
.2267316
   _Iyear_75 |  -1.471403   .8757545    -1.68   0.095     -3.20271
.2599033
   _Iyear_77 |  -1.941271   1.122908    -1.73   0.086    -4.161183
.2786407
   _Iyear_78 |  -2.076393   1.248898    -1.66   0.099    -4.545379
.3925926
   _Iyear_80 |  -2.601959   1.497365    -1.74   0.084    -5.562148
.3582295
   _Iyear_82 |  -3.131761   1.746915    -1.79   0.075    -6.585293
.321771
   _Iyear_83 |  -3.135278    1.87198    -1.67   0.096    -6.836054
.5654988
   _Iyear_85 |  -3.441114   2.120773    -1.62   0.107    -7.633738
.7515099
   _Iyear_87 |  -4.010854   2.372786    -1.69   0.093     -8.70169
.6799811
   _Iyear_88 |  -4.251622   2.571628    -1.65   0.100    -9.335555
.8323111
       _cons |    -2.3679   2.420624    -0.98   0.330    -7.153307
2.417507
-------------+--------------------------------------------------------------
--
      idcode |        F(17, 141) =     12.342   0.000          (18
categories)


-- Gustavo
[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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index