-----------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  C:\Users\Lee\Documents\panel_example.log
  log type:  text
 opened on:  12 Sep 2011, 16:12:29

. describe

Contains data from http://www.stata-press.com/data/r11/nlswork.dta
  obs:        28,534                          National Longitudinal Survey.  Young Women 14-26 years of
                                                age in 1968
 vars:            21                          7 Dec 2008 17:02
 size:     1,055,758 (98.0% of memory free)
-----------------------------------------------------------------------------------------------------------
              storage  display     value
variable name   type   format      label      variable label
-----------------------------------------------------------------------------------------------------------
idcode          int    %8.0g                  NLS ID
year            byte   %8.0g                  interview year
birth_yr        byte   %8.0g                  birth year
age             byte   %8.0g                  age in current year
race            byte   %8.0g                  1=white, 2=black, 3=other
msp             byte   %8.0g                  1 if married, spouse present
nev_mar         byte   %8.0g                  1 if never married
grade           byte   %8.0g                  current grade completed
collgrad        byte   %8.0g                  1 if college graduate
not_smsa        byte   %8.0g                  1 if not SMSA
c_city          byte   %8.0g                  1 if central city
south           byte   %8.0g                  1 if south
ind_code        byte   %8.0g                  industry of employment
occ_code        byte   %8.0g                  occupation
union           byte   %8.0g                  1 if union
wks_ue          byte   %8.0g                  weeks unemployed last year
ttl_exp         float  %9.0g                  total work experience
tenure          float  %9.0g                  job tenure, in years
hours           int    %8.0g                  usual hours worked
wks_work        int    %8.0g                  weeks worked last year
ln_wage         float  %9.0g                  ln(wage/GNP deflator)
-----------------------------------------------------------------------------------------------------------
Sorted by:  idcode  year

. 
. tabulate race

   1=white, |
   2=black, |
    3=other |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |     20,180       70.72       70.72
          2 |      8,051       28.22       98.94
          3 |        303        1.06      100.00
------------+-----------------------------------
      Total |     28,534      100.00

. tabulate occ_code

 occupation |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |      3,008       10.59       10.59
          2 |      1,494        5.26       15.84
          3 |     10,974       38.62       54.47
          4 |      1,323        4.66       59.12
          5 |        438        1.54       60.67
          6 |      4,309       15.17       75.83
          7 |        571        2.01       77.84
          8 |      4,300       15.13       92.98
          9 |          6        0.02       93.00
         10 |        144        0.51       93.50
         11 |        194        0.68       94.19
         12 |          7        0.02       94.21
         13 |      1,645        5.79      100.00
------------+-----------------------------------
      Total |     28,413      100.00

. 
. summarize 2.race

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
      2.race |     28534    .2821546    .4500561          0          1

. by race, sort : summarize ln_wage grade collgrad

-----------------------------------------------------------------------------------------------------------
-> race = 1

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
     ln_wage |     20180    1.714338    .4765987          0   5.263916
       grade |     20179    12.77382     2.24853          0         18
    collgrad |     20180    .1906838    .3928501          0          1

-----------------------------------------------------------------------------------------------------------
-> race = 2

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
     ln_wage |      8051    1.571552    .4648369   .0044871   4.029306
       grade |      8050     11.9164    2.346935          0         18
    collgrad |      8051    .1074401    .3096912          0          1

-----------------------------------------------------------------------------------------------------------
-> race = 3

    Variable |       Obs        Mean    Std. Dev.       Min        Max
-------------+--------------------------------------------------------
     ln_wage |       303    1.795009    .5054575   .5911255   3.912023
       grade |       303    12.83828    3.390225          0         18
    collgrad |       303    .2706271    .4450187          0          1


. global xlist age c.age#c.age ttl_exp c.ttl_exp#c.ttl_exp tenure c.tenure#c.tenure 2.race not_smsa south

. 
. qui xtreg ln_w $xlist, fe

. estimates store fe

. xtreg ln_w $xlist, fe vce(cluster idcode)
note: 2.race omitted because of collinearity

Fixed-effects (within) regression               Number of obs      =     28093
Group variable: idcode                          Number of groups   =      4699

R-sq:  within  = 0.1727                         Obs per group: min =         1
       between = 0.3500                                        avg =       6.0
       overall = 0.2625                                        max =        15

                                                F(8,4698)          =    273.86
corr(u_i, Xb)  = 0.1935                         Prob > F           =    0.0000

                              (Std. Err. adjusted for 4699 clusters in idcode)
------------------------------------------------------------------------------
             |               Robust
     ln_wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         age |   .0359987   .0052407     6.87   0.000     .0257244     .046273
             |
 c.age#c.age |   -.000723   .0000845    -8.56   0.000    -.0008887   -.0005573
             |
     ttl_exp |   .0334668    .004069     8.22   0.000     .0254896    .0414439
             |
   c.ttl_exp#|
   c.ttl_exp |   .0002163   .0001763     1.23   0.220    -.0001294    .0005619
             |
      tenure |   .0357539   .0024683    14.49   0.000     .0309148     .040593
             |
    c.tenure#|
    c.tenure |  -.0019701   .0001696   -11.62   0.000    -.0023026   -.0016376
             |
      2.race |  (omitted)
    not_smsa |  -.0890108   .0137629    -6.47   0.000    -.1159925    -.062029
       south |  -.0606309   .0163366    -3.71   0.000    -.0926583   -.0286035
       _cons |   1.037301   .0739644    14.02   0.000      .892296    1.182306
-------------+----------------------------------------------------------------
     sigma_u |  .35561054
     sigma_e |  .29068923
         rho |  .59944731   (fraction of variance due to u_i)
------------------------------------------------------------------------------

. estimates store fe_cluster

. qui xtreg ln_w $xlist, be

. estimates store be

. qui xtreg ln_w $xlist, re

. predict alpha, u
(441 missing values generated)

. summarize alpha, detail

                          u[idcode]
-------------------------------------------------------------
      Percentiles      Smallest
 1%    -.5961989      -1.341182
 5%    -.4000508      -1.341182
10%    -.3044341      -1.341182       Obs               28093
25%    -.1790428      -1.341182       Sum of Wgt.       28093

50%    -.0275422                      Mean          -.0066589
                        Largest       Std. Dev.      .2600524
75%     .1501835       1.304894
90%     .3285468       1.304894       Variance       .0676272
95%     .4447758       1.304894       Skewness       .3167209
99%      .691463       1.304894       Kurtosis       3.927976

. xttest0

Breusch and Pagan Lagrangian multiplier test for random effects

        ln_wage[idcode,t] = Xb + u[idcode] + e[idcode,t]

        Estimated results:
                         |       Var     sd = sqrt(Var)
                ---------+-----------------------------
                 ln_wage |   .2283214       .4778299
                       e |   .0845002       .2906892
                       u |   .0846774       .2909938

        Test:   Var(u) = 0
                             chibar2(01) = 18433.56
                          Prob > chibar2 =   0.0000

. estimates store re

. qui reg ln_w grade $xlist, vce(cluster idcode)

. estimates store ols

. estimates table fe fe_cluster be re ols, t(%12.3f) b(%12.5f) stats(r2 rss aic)  

-----------------------------------------------------------------------------------------
    Variable |      fe         fe_cluster         be             re            ols       
-------------+---------------------------------------------------------------------------
         age |      0.03600        0.03600        0.06685        0.03848        0.03860  
             |       10.630          6.869          7.064         12.131          7.753  
             |
 c.age#c.age |     -0.00072       -0.00072       -0.00113       -0.00076       -0.00071  
             |      -13.575         -8.555         -7.272        -15.049         -8.443  
             |
     ttl_exp |      0.03347        0.03347        0.04422        0.03656        0.02113  
             |       11.286          8.225          7.234         14.695          5.786  
             |
   c.ttl_exp#|
   c.ttl_exp |      0.00022        0.00022       -0.00039        0.00011        0.00045  
             |        1.693          1.227         -1.098          0.903          2.117  
             |
      tenure |      0.03575        0.03575        0.06946        0.03840        0.04737  
             |       19.340         14.485         10.462         21.579         16.380  
             |
    c.tenure#|
    c.tenure |     -0.00197       -0.00197       -0.00272       -0.00199       -0.00203  
             |      -15.762        -11.616         -6.076        -16.479        -10.215  
             |
      2.race |    (omitted)      (omitted)       -0.10805       -0.11063       -0.06994  
             |                                     -9.521        -10.148         -7.078  
    not_smsa |     -0.08901       -0.08901       -0.23538       -0.14761       -0.17205  
             |       -9.339         -6.467        -19.325        -19.734        -18.057  
       south |     -0.06063       -0.06063       -0.11881       -0.09620       -0.10034  
             |       -5.546         -3.711        -10.736        -12.462        -11.382  
       grade |                                                                  0.06292  
             |                                                                   30.311  
       _cons |      1.03730        1.03730        0.50068        1.04977        0.24728  
             |       21.364         14.024          3.786         23.256          3.511  
-------------+---------------------------------------------------------------------------
          r2 |      0.17267        0.17267        0.38909                       0.37454  
         rss |   1976.12232     1976.12232      517.51194                    4011.63592  
         aic |   5172.87252     5170.87252     2988.85008              .    25068.69251  
-----------------------------------------------------------------------------------------
                                                                              legend: b/t

. 
. hausman fe re

                 ---- Coefficients ----
             |      (b)          (B)            (b-B)     sqrt(diag(V_b-V_B))
             |       fe           re         Difference          S.E.
-------------+----------------------------------------------------------------
         age |    .0359987       .03848       -.0024813        .0011859
 c.age#c.age |    -.000723    -.0007634        .0000404        .0000162
     ttl_exp |    .0334668     .0365569       -.0030901        .0016138
c.ttl_exp#~p |    .0002163     .0001068        .0001094        .0000483
      tenure |    .0357539     .0383994       -.0026455        .0005012
c.tenure#c~e |   -.0019701    -.0019915        .0000214        .0000319
    not_smsa |   -.0890108    -.1476143        .0586036        .0059076
       south |   -.0606309    -.0961963        .0355654        .0077411
------------------------------------------------------------------------------
                           b = consistent under Ho and Ha; obtained from xtreg
            B = inconsistent under Ha, efficient under Ho; obtained from xtreg

    Test:  Ho:  difference in coefficients not systematic

                  chi2(8) = (b-B)'[(V_b-V_B)^(-1)](b-B)
                          =      478.67
                Prob>chi2 =      0.0000

. log close
      name:  <unnamed>
       log:  C:\Users\Lee\Documents\panel_example.log
  log type:  text
 closed on:  12 Sep 2011, 16:12:31
-----------------------------------------------------------------------------------------------------------

