Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • how should I estimate time in a panel model using xthybrid?

    Hello all,

    I working with a panel design. I have data on the 50 U.S. states over 16 years. In the past, I used fixed-effects model (with xtreg, fe), but I've recently discovered the xthybrid command. I am interested in using it because I have some variables that vary little (if at all) within states. My problem is that I understand how to estimate time with xtreg, but I'm more confused when it comes to using xthybrid.

    I used two strategies:
    1) xi: xthybrid y x i.year
    2) xthybrid y x year yearsq

    In the 2nd approach I use year squared because my dependent variable has a slightly quadratic trend over time.

    I will post the output below. I initially ran the models with both within and between effects for all the variables, and I only asked them for the variables that show significantly different effects according to the Wald test.

    I have two questions:
    1) do you have any thoughts on which specification is preferable and why?
    2) do you know why the between effect of the year variables (in either specification) are omitted?


    Code:
    . * specification 1: xi: xthybrid y x i.year
    . 
    . xi: xthybrid y x x1 x2 x3 x4 x5 x6 i.year, clusterid(id) vce(robust) full test 
    i.year            _Iyear_2000-2015    (naturally coded; _Iyear_2000 omitted)
    
    
    -----------------------------------------------------------------------------------------------------
    Model model
    -----------------------------------------------------------------------------------------------------
    
    Mixed-effects GLM                               Number of obs     =        800
    Family:                Gaussian
    Link:                  identity
    Group variable:              id                 Number of groups  =         50
    
                                                    Obs per group:
                                                                  min =         16
                                                                  avg =       16.0
                                                                  max =         16
    
    Integration method: mvaghermite                 Integration pts.  =          7
    
                                                    Wald chi2(29)     =    3271.42
    Log pseudolikelihood = -1197.7914               Prob > chi2       =     0.0000
                                          (Std. Err. adjusted for 50 clusters in id)
    --------------------------------------------------------------------------------
                   |               Robust
                 y |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    ---------------+----------------------------------------------------------------
              W__x |   27.48495   6.561976     4.19   0.000     14.62371    40.34619
             W__x1 |   -.128807   .0519909    -2.48   0.013    -.2307074   -.0269067
             W__x2 |  -.7764989   1.333392    -0.58   0.560    -3.389898    1.836901
             W__x3 |   .0551888   .0633226     0.87   0.383    -.0689212    .1792988
             W__x4 |  -8.633653   6.936338    -1.24   0.213    -22.22863     4.96132
             W__x5 |   2.592232   4.944466     0.52   0.600    -7.098743    12.28321
             W__x6 |   23.33109   6.995832     3.33   0.001     9.619507    37.04266
    W___Iyear_2001 |   .3138501   .2144448     1.46   0.143    -.1064541    .7341543
    W___Iyear_2002 |   .6563101   .2037253     3.22   0.001     .2570158    1.055604
    W___Iyear_2003 |   .6809543   .2860453     2.38   0.017     .1203159    1.241593
    W___Iyear_2004 |   1.015131   .2775332     3.66   0.000     .4711755    1.559086
    W___Iyear_2005 |   1.098209    .357019     3.08   0.002     .3984651    1.797954
    W___Iyear_2006 |   1.331302   .4187316     3.18   0.001     .5106026       2.152
    W___Iyear_2007 |   1.599586   .4363303     3.67   0.000     .7443946    2.454778
    W___Iyear_2008 |   2.165149   .5064014     4.28   0.000     1.172621    3.157678
    W___Iyear_2009 |   2.321855   .6678414     3.48   0.001      1.01291      3.6308
    W___Iyear_2010 |   3.426708   .7355992     4.66   0.000      1.98496    4.868456
    W___Iyear_2011 |   3.795471   .8447231     4.49   0.000     2.139844    5.451097
    W___Iyear_2012 |   4.391039   .9418207     4.66   0.000     2.545104    6.236973
    W___Iyear_2013 |   4.904557   .8365469     5.86   0.000     3.264955    6.544158
    W___Iyear_2014 |   5.837984   .8030856     7.27   0.000     4.263965    7.412003
    W___Iyear_2015 |   6.919046   .9309145     7.43   0.000     5.094487    8.743605
              B__x |  -20.60284   10.90525    -1.89   0.059    -41.97673    .7710576
             B__x1 |  -.0982664   .1719508    -0.57   0.568    -.4352838     .238751
             B__x2 |    20.4087     2.8359     7.20   0.000     14.85044    25.96696
             B__x3 |   .3592356   .3220065     1.12   0.265    -.2718855    .9903567
             B__x4 |  -6.470888   10.29149    -0.63   0.530    -26.64184    13.70006
             B__x5 |   42.22544   8.847803     4.77   0.000     24.88407    59.56682
             B__x6 |  -4.399137   3.009327    -1.46   0.144    -10.29731    1.499035
    B___Iyear_2001 |          0  (omitted)
    B___Iyear_2002 |          0  (omitted)
    B___Iyear_2003 |          0  (omitted)
    B___Iyear_2004 |          0  (omitted)
    B___Iyear_2005 |          0  (omitted)
    B___Iyear_2006 |          0  (omitted)
    B___Iyear_2007 |          0  (omitted)
    B___Iyear_2008 |          0  (omitted)
    B___Iyear_2009 |          0  (omitted)
    B___Iyear_2010 |          0  (omitted)
    B___Iyear_2011 |          0  (omitted)
    B___Iyear_2012 |          0  (omitted)
    B___Iyear_2013 |          0  (omitted)
    B___Iyear_2014 |          0  (omitted)
    B___Iyear_2015 |          0  (omitted)
             _cons |  -18.69707   15.28658    -1.22   0.221    -48.65821    11.26407
    ---------------+----------------------------------------------------------------
    id             |
         var(_cons)|   3.116874    .669193                      2.046285    4.747579
    ---------------+----------------------------------------------------------------
           var(e.y)|   .9095621   .1635097                      .6394608    1.293751
    --------------------------------------------------------------------------------
    
    Tests of the random effects assumption:
      _b[B__x] = _b[W__x]; p-value: 0.0008
      _b[B__x1] = _b[W__x1]; p-value: 0.8419
      _b[B__x2] = _b[W__x2]; p-value: 0.0000
      _b[B__x3] = _b[W__x3]; p-value: 0.3530
      _b[B__x4] = _b[W__x4]; p-value: 0.8616
      _b[B__x5] = _b[W__x5]; p-value: 0.0000
      _b[B__x6] = _b[W__x6]; p-value: 0.0002
      _b[B___Iyear_2001] = _b[W___Iyear_2001]; p-value: 0.1433
      _b[B___Iyear_2002] = _b[W___Iyear_2002]; p-value: 0.0013
      _b[B___Iyear_2003] = _b[W___Iyear_2003]; p-value: 0.0173
      _b[B___Iyear_2004] = _b[W___Iyear_2004]; p-value: 0.0003
      _b[B___Iyear_2005] = _b[W___Iyear_2005]; p-value: 0.0021
      _b[B___Iyear_2006] = _b[W___Iyear_2006]; p-value: 0.0015
      _b[B___Iyear_2007] = _b[W___Iyear_2007]; p-value: 0.0002
      _b[B___Iyear_2008] = _b[W___Iyear_2008]; p-value: 0.0000
      _b[B___Iyear_2009] = _b[W___Iyear_2009]; p-value: 0.0005
      _b[B___Iyear_2010] = _b[W___Iyear_2010]; p-value: 0.0000
      _b[B___Iyear_2011] = _b[W___Iyear_2011]; p-value: 0.0000
      _b[B___Iyear_2012] = _b[W___Iyear_2012]; p-value: 0.0000
      _b[B___Iyear_2013] = _b[W___Iyear_2013]; p-value: 0.0000
      _b[B___Iyear_2014] = _b[W___Iyear_2014]; p-value: 0.0000
      _b[B___Iyear_2015] = _b[W___Iyear_2015]; p-value: 0.0000
    
    . 
    . xi: xthybrid y x x1 x2 x3 x4 x5 x6 i.year, clusterid(id) vce(robust) use (x x2 x5 x6 _Iyear_2002 _I
    > year_2003 _Iyear_2004 _Iyear_2005 _Iyear_2006 _Iyear_2007 _Iyear_2008 _Iyear_2009 _Iyear_2010 _Iyea
    > r_2011 _Iyear_2012 _Iyear_2013 _Iyear_2014 _Iyear_2015) full test 
    i.year            _Iyear_2000-2015    (naturally coded; _Iyear_2000 omitted)
    
    
    -----------------------------------------------------------------------------------------------------
    Model model
    -----------------------------------------------------------------------------------------------------
    
    Mixed-effects GLM                               Number of obs     =        800
    Family:                Gaussian
    Link:                  identity
    Group variable:              id                 Number of groups  =         50
    
                                                    Obs per group:
                                                                  min =         16
                                                                  avg =       16.0
                                                                  max =         16
    
    Integration method: mvaghermite                 Integration pts.  =          7
    
                                                    Wald chi2(26)     =    2217.47
    Log pseudolikelihood = -1198.5026               Prob > chi2       =     0.0000
                                          (Std. Err. adjusted for 50 clusters in id)
    --------------------------------------------------------------------------------
                   |               Robust
                 y |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    ---------------+----------------------------------------------------------------
             R__x1 |  -.1261339   .0532073    -2.37   0.018    -.2304183   -.0218495
             R__x3 |   .0633807   .0628135     1.01   0.313    -.0597316     .186493
             R__x4 |  -9.130167   5.568717    -1.64   0.101    -20.04465    1.784317
    R___Iyear_2001 |   .3156233   .2130639     1.48   0.139    -.1019742    .7332208
              W__x |   27.78369   6.505358     4.27   0.000     15.03342    40.53395
             W__x2 |  -.7374598   1.334721    -0.55   0.581    -3.353466    1.878546
             W__x5 |   2.735612   4.953238     0.55   0.581    -6.972556    12.44378
             W__x6 |    23.4502   7.004207     3.35   0.001     9.722207    37.17819
    W___Iyear_2002 |   .6509489   .2019093     3.22   0.001      .255214    1.046684
    W___Iyear_2003 |   .6750173    .279622     2.41   0.016     .1269682    1.223066
    W___Iyear_2004 |   1.011967   .2698932     3.75   0.000     .4829864    1.540948
    W___Iyear_2005 |   1.097031   .3487383     3.15   0.002     .4135163    1.780545
    W___Iyear_2006 |   1.331346   .4137273     3.22   0.001      .520455    2.142236
    W___Iyear_2007 |   1.601597    .426051     3.76   0.000     .7665522    2.436642
    W___Iyear_2008 |   2.158867   .4983493     4.33   0.000      1.18212    3.135614
    W___Iyear_2009 |   2.286841   .6604286     3.46   0.001     .9924242    3.581257
    W___Iyear_2010 |    3.38746   .7353506     4.61   0.000     1.946199    4.828721
    W___Iyear_2011 |   3.758626   .8416914     4.47   0.000     2.108941    5.408311
    W___Iyear_2012 |   4.361262   .9331158     4.67   0.000     2.532389    6.190135
    W___Iyear_2013 |   4.886226   .8309126     5.88   0.000     3.257667    6.514785
    W___Iyear_2014 |   5.836347   .7932212     7.36   0.000     4.281662    7.391032
    W___Iyear_2015 |   6.932657   .9024717     7.68   0.000     5.163845    8.701469
              B__x |  -20.73066   9.848327    -2.10   0.035    -40.03303   -1.428293
             B__x2 |   20.33603   2.720781     7.47   0.000      15.0034    25.66866
             B__x5 |   38.16482   9.565075     3.99   0.000     19.41762    56.91203
             B__x6 |  -5.235565   2.992847    -1.75   0.080    -11.10144    .6303082
    B___Iyear_2002 |          0  (omitted)
    B___Iyear_2003 |          0  (omitted)
    B___Iyear_2004 |          0  (omitted)
    B___Iyear_2005 |          0  (omitted)
    B___Iyear_2006 |          0  (omitted)
    B___Iyear_2007 |          0  (omitted)
    B___Iyear_2008 |          0  (omitted)
    B___Iyear_2009 |          0  (omitted)
    B___Iyear_2010 |          0  (omitted)
    B___Iyear_2011 |          0  (omitted)
    B___Iyear_2012 |          0  (omitted)
    B___Iyear_2013 |          0  (omitted)
    B___Iyear_2014 |          0  (omitted)
    B___Iyear_2015 |          0  (omitted)
             _cons |  -11.19267   13.47014    -0.83   0.406    -37.59365    15.20831
    ---------------+----------------------------------------------------------------
    id             |
         var(_cons)|   3.204795   .6627161                      2.136885    4.806393
    ---------------+----------------------------------------------------------------
           var(e.y)|   .9096307    .163521                      .6395105    1.293846
    --------------------------------------------------------------------------------
    
    Tests of the random effects assumption:
      _b[B__x] = _b[W__x]; p-value: 0.0005
      _b[B__x2] = _b[W__x2]; p-value: 0.0000
      _b[B__x5] = _b[W__x5]; p-value: 0.0006
      _b[B__x6] = _b[W__x6]; p-value: 0.0002
      _b[B___Iyear_2002] = _b[W___Iyear_2002]; p-value: 0.0013
      _b[B___Iyear_2003] = _b[W___Iyear_2003]; p-value: 0.0158
      _b[B___Iyear_2004] = _b[W___Iyear_2004]; p-value: 0.0002
      _b[B___Iyear_2005] = _b[W___Iyear_2005]; p-value: 0.0017
      _b[B___Iyear_2006] = _b[W___Iyear_2006]; p-value: 0.0013
      _b[B___Iyear_2007] = _b[W___Iyear_2007]; p-value: 0.0002
      _b[B___Iyear_2008] = _b[W___Iyear_2008]; p-value: 0.0000
      _b[B___Iyear_2009] = _b[W___Iyear_2009]; p-value: 0.0005
      _b[B___Iyear_2010] = _b[W___Iyear_2010]; p-value: 0.0000
      _b[B___Iyear_2011] = _b[W___Iyear_2011]; p-value: 0.0000
      _b[B___Iyear_2012] = _b[W___Iyear_2012]; p-value: 0.0000
      _b[B___Iyear_2013] = _b[W___Iyear_2013]; p-value: 0.0000
      _b[B___Iyear_2014] = _b[W___Iyear_2014]; p-value: 0.0000
      _b[B___Iyear_2015] = _b[W___Iyear_2015]; p-value: 0.0000
    
    . 
    . * specification 2: xthybrid y x year yearsq
    . 
    . gen yearsq = year*year
    
    . 
    . xthybrid y x x1 x2 x3 x4 x5 x6 year yearsq, clusterid(id) vce(robust) full test 
    
    
    -----------------------------------------------------------------------------------------------------
    Model model
    -----------------------------------------------------------------------------------------------------
    
    Mixed-effects GLM                               Number of obs     =        800
    Family:                Gaussian
    Link:                  identity
    Group variable:              id                 Number of groups  =         50
    
                                                    Obs per group:
                                                                  min =         16
                                                                  avg =       16.0
                                                                  max =         16
    
    Integration method: mvaghermite                 Integration pts.  =          7
    
                                                    Wald chi2(16)     =    1095.19
    Log pseudolikelihood = -1208.2773               Prob > chi2       =     0.0000
                                        (Std. Err. adjusted for 50 clusters in id)
    ------------------------------------------------------------------------------
                 |               Robust
               y |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
            W__x |   24.25765    5.35374     4.53   0.000     13.76451    34.75079
           W__x1 |  -.1344042   .0438872    -3.06   0.002    -.2204215   -.0483869
           W__x2 |  -1.516852   1.212306    -1.25   0.211    -3.892928    .8592233
           W__x3 |   .0599774   .0287017     2.09   0.037     .0037231    .1162317
           W__x4 |  -5.197346   6.734602    -0.77   0.440    -18.39692    8.002232
           W__x5 |  -1.778408   4.424572    -0.40   0.688    -10.45041    6.893594
           W__x6 |   24.38065   6.896454     3.54   0.000     10.86384    37.89745
         W__year |  -103.3558   13.86083    -7.46   0.000    -130.5225   -76.18905
       W__yearsq |   .0258488   .0034574     7.48   0.000     .0190725    .0326251
            B__x |  -20.60284   10.90525    -1.89   0.059    -41.97673    .7710575
           B__x1 |  -.0982663   .1719508    -0.57   0.568    -.4352837    .2387511
           B__x2 |    20.4087     2.8359     7.20   0.000     14.85044    25.96696
           B__x3 |   .3592355   .3220065     1.12   0.265    -.2718855    .9903566
           B__x4 |  -6.470888   10.29149    -0.63   0.530    -26.64184    13.70006
           B__x5 |   42.22545   8.847803     4.77   0.000     24.88407    59.56682
           B__x6 |  -4.399137   3.009327    -1.46   0.144    -10.29731    1.499035
         B__year |          0  (omitted)
       B__yearsq |          0  (omitted)
           _cons |  -18.69707   15.28658    -1.22   0.221    -48.65821    11.26407
    -------------+----------------------------------------------------------------
    id           |
       var(_cons)|    3.11528   .6690461                      2.044988    4.745735
    -------------+----------------------------------------------------------------
         var(e.y)|   .9353547   .1686279                       .656931    1.331781
    ------------------------------------------------------------------------------
    
    Tests of the random effects assumption:
      _b[B__x] = _b[W__x]; p-value: 0.0009
      _b[B__x1] = _b[W__x1]; p-value: 0.8165
      _b[B__x2] = _b[W__x2]; p-value: 0.0000
      _b[B__x3] = _b[W__x3]; p-value: 0.3517
      _b[B__x4] = _b[W__x4]; p-value: 0.9165
      _b[B__x5] = _b[W__x5]; p-value: 0.0000
      _b[B__x6] = _b[W__x6]; p-value: 0.0001
      _b[B__year] = _b[W__year]; p-value: 0.0000
      _b[B__yearsq] = _b[W__yearsq]; p-value: 0.0000
    
    . 
    . xthybrid y x x1 x2 x3 x4 x5 x6 year yearsq, clusterid(id) vce(robust) use(x x2 x5 x6 year yearsq) f
    > ull test 
    
    
    -----------------------------------------------------------------------------------------------------
    Model model
    -----------------------------------------------------------------------------------------------------
    
    Mixed-effects GLM                               Number of obs     =        800
    Family:                Gaussian
    Link:                  identity
    Group variable:              id                 Number of groups  =         50
    
                                                    Obs per group:
                                                                  min =         16
                                                                  avg =       16.0
                                                                  max =         16
    
    Integration method: mvaghermite                 Integration pts.  =          7
    
                                                    Wald chi2(13)     =     941.16
    Log pseudolikelihood =  -1209.133               Prob > chi2       =     0.0000
                                        (Std. Err. adjusted for 50 clusters in id)
    ------------------------------------------------------------------------------
                 |               Robust
               y |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
           R__x1 |  -.1317118   .0450499    -2.92   0.003    -.2200079   -.0434157
           R__x3 |   .0615175   .0289401     2.13   0.034      .004796     .118239
           R__x4 |  -6.474502   5.563331    -1.16   0.245    -17.37843    4.429427
            W__x |   24.01769   5.350782     4.49   0.000     13.53035    34.50503
           W__x2 |  -1.521848   1.205595    -1.26   0.207    -3.884771    .8410747
           W__x5 |  -1.805144    4.34951    -0.42   0.678    -10.33003    6.719739
           W__x6 |   24.44828   6.874908     3.56   0.000     10.97371    37.92285
         W__year |  -103.1623    13.8708    -7.44   0.000    -130.3486   -75.97603
       W__yearsq |   .0258013   .0034601     7.46   0.000     .0190198    .0325829
            B__x |  -18.55783   9.749117    -1.90   0.057    -37.66575    .5500894
           B__x2 |    20.9162   2.746813     7.61   0.000     15.53255    26.29985
           B__x5 |   37.08718   9.914084     3.74   0.000     17.65593    56.51843
           B__x6 |   -5.42266    3.01079    -1.80   0.072     -11.3237    .4783787
         B__year |          0  (omitted)
       B__yearsq |          0  (omitted)
           _cons |  -12.30471   13.61443    -0.90   0.366    -38.98849    14.37908
    -------------+----------------------------------------------------------------
    id           |
       var(_cons)|   3.220027   .6751044                      2.135002     4.85647
    -------------+----------------------------------------------------------------
         var(e.y)|   .9354643   .1686319                      .6570296    1.331893
    ------------------------------------------------------------------------------
    
    Tests of the random effects assumption:
      _b[B__x] = _b[W__x]; p-value: 0.0009
      _b[B__x2] = _b[W__x2]; p-value: 0.0000
      _b[B__x5] = _b[W__x5]; p-value: 0.0004
      _b[B__x6] = _b[W__x6]; p-value: 0.0001
      _b[B__year] = _b[W__year]; p-value: 0.0000
      _b[B__yearsq] = _b[W__yearsq]; p-value: 0.0000

  • #2
    1) do you have any thoughts on which specification is preferable and why?
    The year fixed effects are a vector of 1's so squaring this will just yield the same vector. Except, that you used the actual year so squaring the actual year (e.g.., 2020) yields a much larger value (i.e., 4,080,400). I don't think this is the correct approach so I would suggest you include year fixed effects and consider any non-linearity in your regressors, not the year dummies or actual year.

    2) do you know why the between effect of the year variables (in either specification) are omitted?
    I believe it is because they are collinear. The W_Iyear give you the year fixed effects.

    Comment


    • #3
      Thank you!

      I have some follow-up questions if you don't mind.

      The year fixed effects are a vector of 1's so squaring this will just yield the same vector.
      Correct! But I may have been unclear, because I didn't square the dummy year variables, I squared the continuous year variable.

      Except, that you used the actual year so squaring the actual year (e.g.., 2020) yields a much larger value (i.e., 4,080,400).
      Also correct! I'm not sure why it didn't occur to me. I created a time variable with the following code:
      Code:
      gen time = year-1999
      gen timesq = time*time
      When I replace "year yearsq" with "time timesq" the results hold. The coefficients of time and timesq are different from those of year and yearsq, but all the other coefficients and standard errors are the same.

      I don't think this is the correct approach so I would suggest you include year fixed effects and consider any non-linearity in your regressors, not the year dummies or actual year.
      A clarification: to include year fixed effects I should use the following code:
      Code:
      xi: xthybrid y x, i.year
      and then, the year fixed effects are all the coefficients starting with W___Iyear_, correct?

      As for considering non-linearity in my regressors, you mean for instance adding x^2, x1^2, etc.?

      Is there a rationale to use i.year instead of time and timesq? After all, also time is one of my regressors.

      I believe it is because they are collinear. The W_Iyear give you the year fixed effects.
      This makes sense. So I should ignore the B___Iyear_ coefficients, right?

      Again, thank you for your help!

      Comment

      Working...
      X