Announcement

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

  • Running separate regressions with "if" option versus creating time period dummies

    Hello, Stata users. This is my first time posting on this board. I will do my best to stick with the etiquette/format, but forgive me if I trip anything up this first time! Here we go...

    I am running regressions on panel data consisting of data on 50 states over 26 years. We have three dependent variables of interest, and we are running the data over two separate time periods (1990 - 2007, 2008 - 2015).

    Originally, I ran separate regressions for each of the above time periods, using year fixed-effects and state random effects within each of those models. See, for one of our dependent variables (budget cut):

    Code:
    xtreg budcut surplus deficit i.year if yrs90_07 == 1, re
    Code:
    xtreg budcut surplus deficit i.year if yrs08_15 == 1, re
    We ran the same regressions, with the same predictors for taxnxt and taxch (our two additional dependent variables).

    [Please note, we focused on random, instead of state fixed, effects because we have very little variation in our predictors of primary interest over time; our analysis mostly focuses on state budget institutions, like Balanced Budget Requirements, which may change only once or twice in our time period in a state, or not at all].

    However, the above analysis does not permit me to evaluate whether differences in the coefficients for the same predictor are statistically significant across time periods. Moreover, it also does not allow me to understand whether coefficients are equal across regressions for different dependent variables (within the same time period).

    The solution I have been experimenting with is two-pronged: 1) interact a time period dummy for the later period with my predictors, rather than running separate regressions (in order to see if differences are significant across time periods); and 2) Use the xtsur command (which I had to install separately) in order to test coefficient equality across regressions with the same predictors but different dependent variables.

    See my code below (*tab3 refers to Table 3 that we are producing in our report, yrs08_15 is coded 1 for where years are >= 2008 and <=2015, so the earlier period is my base):

    Code:
    tsset statenum year
    local tab3 surplus deficit yrs08_15 yrs08_15_s yrs08_15_d
        xtsur (budcut `tab3') (taxch `tab3') (taxnxt `tab3')
        
        test [budcut]deficit=[taxch]deficit
        test [budcut]deficit=[taxnxt]deficit
        test [taxch]deficit=[taxnxt]deficit
        
        test [budcut]yrs08_15_d=[taxch]yrs08_15_d
        test [budcut]yrs08_15_d=[taxnxt]yrs08_15_d
        test [taxch]yrs08_15_d=[taxnxt]yrs08_15_d
    Now that I have given background (and pasted a data sample for reference, below), my questions are:
    • Coefficients with period dummies/interaction terms are different from those in the separate regressions with "if" option. Why? Is this a problem? Does it mean I did something wrong? Which set of coefficients should I be using?
    Coefficients for "if" option from 1990 - 2007:
    Code:
    . **buduct (1990 - 2007, 2008 - 2015)
    .         xtreg budcut surplus deficit i.year if yrs90_07 == 1, re
    
    Random-effects GLS regression                   Number of obs     =        882
    Group variable: statenum                        Number of groups  =         49
    
    R-sq:                                           Obs per group:
         within  = 0.4886                                         min =         18
         between = 0.1932                                         avg =       18.0
         overall = 0.4705                                         max =         18
    
                                                    Wald chi2(19)     =          .
    corr(u_i, X)   = 0 (assumed)                    Prob > chi2       =          .
    
    ------------------------------------------------------------------------------
          budcut |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
         surplus |  -.0040978   .0141333    -0.29   0.772    -.0317986    .0236031
         deficit |  -.2900718    .014915   -19.45   0.000    -.3193045    -.260839
                 |
            year |
           1991  |   13.30751   5.815876     2.29   0.022     1.908598    24.70641
           1992  |   8.742808   5.766725     1.52   0.129    -2.559765    20.04538
           1993  |   3.654699   5.771098     0.63   0.527    -7.656445    14.96584
           1994  |  -5.663491   5.774264    -0.98   0.327    -16.98084     5.65386
           1995  |  -8.383182   5.771047    -1.45   0.146    -19.69423    2.927862
           1996  |   2.802369   5.774908     0.49   0.627    -8.516242    14.12098
           1997  |  -7.144714   5.794108    -1.23   0.218    -18.50096    4.211529
           1998  |  -10.82781   5.831358    -1.86   0.063    -22.25706     .601446
           1999  |  -11.73361   5.782554    -2.03   0.042    -23.06721   -.4000122
           2000  |  -9.771238   5.818878    -1.68   0.093    -21.17603    1.633554
           2001  |  -7.159106   5.765843    -1.24   0.214    -18.45995    4.141738
           2002  |   5.491668   6.012652     0.91   0.361    -6.292914    17.27625
           2003  |   23.85425   5.771127     4.13   0.000     12.54305    35.16546
           2004  |  -1.867533   5.780371    -0.32   0.747    -13.19685    9.461786
           2005  |  -7.386509   5.825723    -1.27   0.205    -18.80472    4.031699
           2006  |  -8.363212   5.897161    -1.42   0.156    -19.92143    3.195011
           2007  |  -12.48453   5.810038    -2.15   0.032    -23.87199   -1.097061
           2008  |          0  (empty)
           2009  |          0  (empty)
           2010  |          0  (empty)
           2011  |          0  (empty)
           2012  |          0  (empty)
           2013  |          0  (empty)
           2014  |          0  (empty)
           2015  |          0  (empty)
                 |
           _cons |   8.887196   4.224359     2.10   0.035     .6076039    17.16679
    -------------+----------------------------------------------------------------
         sigma_u |  4.7118651
         sigma_e |  28.448286
             rho |  .02670053   (fraction of variance due to u_i)
    ------------------------------------------------------------------------------
    And the coefficients using the xtsur command with the yrs_08_15 time period dummy and interaction terms:

    Code:
    tsset statenum year
           panel variable:  statenum (strongly balanced)
            time variable:  year, 1990 to 2015
                    delta:  1 year
    
    .         xtsur (budcut surplus deficit yrs08_15 yrs08_15_s yrs08_15_d) (taxch sur
    > plus deficit yrs08_15 yrs08_15_s yrs08_15_d) (taxnxt surplus deficit yrs08_15 yr
    > s08_15_s yrs08_15_d)
    (running multi-step estimates...)
    
    Calculating multi-step estimates...
    Iteration   1 : relative difference =  .63317634
    Iteration   2 : relative difference =  8.828e-08
    
    
    Seemingly unrelated regression (SUR) in panel data set
    
    One-way random effect estimation:
    ------------------------------------------------------------------------------
    Number of Group variable:    1                  Number of obs      =      1274
    Panel variable: statenum                        Number of eqn      =         3
    Time variable : year                            Number of panels   =         1
    
    Random effects u_i ~ Gaussian
    corr(u_i, e_it)    = 0 (assumed)
    Panel type         : strongly balanced
    
    ------------------------------------------------------------------------------
                 |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
    budcut       |
         surplus |  -.0219691    .014601    -1.50   0.132    -.0505866    .0066484
         deficit |  -.3325268   .0152926   -21.74   0.000    -.3624997    -.302554
        yrs08_15 |   8.543416   2.578459     3.31   0.001     3.489729     13.5971
      yrs08_15_s |   -.023256   .0254981    -0.91   0.362    -.0732314    .0267193
      yrs08_15_d |   .0044566   .0229495     0.19   0.846    -.0405237    .0494368
    -------------+----------------------------------------------------------------
    taxch        |
         surplus |  -.0293486   .0071248    -4.12   0.000     -.043313   -.0153841
         deficit |  -.0944483   .0081384   -11.61   0.000    -.1103993   -.0784972
        yrs08_15 |   2.690477   1.336243     2.01   0.044     .0714877    5.309466
      yrs08_15_s |  -.0398228   .0137497    -2.90   0.004    -.0667716   -.0128739
      yrs08_15_d |   .0554447   .0126783     4.37   0.000     .0305957    .0802938
    -------------+----------------------------------------------------------------
    taxnxt       |
         surplus |   -.156536   .0274122    -5.71   0.000    -.2102629   -.1028091
         deficit |  -.3364238   .0285285   -11.79   0.000    -.3923386    -.280509
        yrs08_15 |   3.866633   4.818974     0.80   0.422    -5.578382    13.31165
      yrs08_15_s |   .0752939   .0474971     1.59   0.113    -.0177987    .1683865
      yrs08_15_d |   .1376033   .0426799     3.22   0.001     .0539523    .2212543
    -------------+----------------------------------------------------------------
         sigma_u |   see e(sigma_u)
         sigma_e |   see e(sigma_e)
    ------------------------------------------------------------------------------
    Dependent variables:   budcut taxch taxnxt
    Independent variables: surplus deficit yrs08_15 yrs08_15_s yrs08_15_d
    ------------------------------------------------------------------------------
    • Include i.year or not? When I am including the yrs08_15 dummy and its interaction terms (above), should I continue to include i.year? I felt like this would produce some collinearity issues, but I wasn't able to get clarity on this.
    • Is there a better way to do any of this? I am a fairly new Stata user who is in a bit over my head, so if I'm barking up the wrong tree for any of this, I'd love to hear any other thoughts.
    Data example:
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str20 state float(surplus deficit yrs08_15 yrs08_15_s yrs08_15_d)
    "Alabama"    13.157997          0 0         0          0
    "Alabama"            0  -40.19884 0         0          0
    "Alabama"            0  -61.91863 0         0          0
    "Alabama"     31.58817          0 0         0          0
    "Alabama"     25.48999          0 0         0          0
    "Alabama"            0 -27.230835 0         0          0
    "Alabama"    10.891846          0 0         0          0
    "Alabama"    1.0253906          0 0         0          0
    "Alabama"      19.7511          0 0         0          0
    "Alabama"     8.807983          0 0         0          0
    "Alabama"    31.693726          0 0         0          0
    "Alabama"            0  -77.03255 0         0          0
    "Alabama"            0 -34.120426 0         0          0
    "Alabama"     .8310919          0 0         0          0
    "Alabama"     70.21131          0 0         0          0
    "Alabama"     137.1062          0 0         0          0
    "Alabama"    142.87372          0 0         0          0
    "Alabama"            0  -55.65601 0         0          0
    "Alabama"            0  -52.31865 1         0  -52.31865
    "Alabama"            0  -274.9464 1         0  -274.9464
    "Alabama"            0  -348.9378 1         0  -348.9378
    "Alabama"            0 -184.40778 1         0 -184.40778
    "Alabama"            0  -85.58302 1         0  -85.58302
    "Alabama"     28.27649          0 1  28.27649          0
    "Alabama"      2.06958          0 1   2.06958          0
    "Alabama"            0  -26.89168 1         0  -26.89168
    "Arizona"            0  -19.32152 0         0          0
    "Arizona"            0  -45.40803 0         0          0
    "Arizona"            0  -33.57552 0         0          0
    "Arizona"    36.428417          0 0         0          0
    "Arizona"     54.77623          0 0         0          0
    "Arizona"    111.43684          0 0         0          0
    "Arizona"    121.54735          0 0         0          0
    "Arizona"     138.7948          0 0         0          0
    "Arizona"      12.6167          0 0         0          0
    "Arizona"     39.49866          0 0         0          0
    "Arizona"    19.673584          0 0         0          0
    "Arizona"            0 -36.958984 0         0          0
    "Arizona"            0   -313.314 0         0          0
    "Arizona"            0  -97.19553 0         0          0
    "Arizona"     80.49805          0 0         0          0
    "Arizona"    179.80518          0 0         0          0
    "Arizona"    162.70276          0 0         0          0
    "Arizona"            0  -34.11145 0         0          0
    "Arizona"            0  -152.5368 1         0  -152.5368
    "Arizona"            0  -309.8741 1         0  -309.8741
    "Arizona"            0  -43.05322 1         0  -43.05322
    "Arizona"    75.935715          0 1 75.935715          0
    "Arizona"            0  -87.68625 1         0  -87.68625
    "Arizona"     71.50064          0 1  71.50064          0
    "Arizona"     7.663818          0 1  7.663818          0
    "Arizona"    24.932076          0 1 24.932076          0
    "Arkansas"           0          0 0         0          0
    "Arkansas"           0 -35.756756 0         0          0
    "Arkansas"           0  -14.60597 0         0          0
    "Arkansas"           0 -10.319755 0         0          0
    "Arkansas"           0          0 0         0          0
    "Arkansas"           0  -31.54308 0         0          0
    "Arkansas"           0  -58.16742 0         0          0
    "Arkansas"    60.38013          0 0         0          0
    "Arkansas"    38.48828          0 0         0          0
    "Arkansas"    36.84811          0 0         0          0
    "Arkansas"           0          0 0         0          0
    "Arkansas"           0 -3.8232265 0         0          0
    "Arkansas"           0  -83.51202 0         0          0
    "Arkansas"           0  -58.49155 0         0          0
    "Arkansas"           0  -50.11287 0         0          0
    "Arkansas"    1.229193          0 0         0          0
    "Arkansas"           0          0 0         0          0
    "Arkansas"    39.87108          0 0         0          0
    "Arkansas"           0  -2.308497 1         0  -2.308497
    "Arkansas"           0 -33.550426 1         0 -33.550426
    "Arkansas"           0  -92.24941 1         0  -92.24941
    "Arkansas"   2.0862823          0 1 2.0862823          0
    "Arkansas"           0          0 1         0          0
    "Arkansas"           0          0 1         0          0
    "Arkansas"           0          0 1         0          0
    "Arkansas"           0          0 1         0          0
    "California"         0  -22.08824 0         0          0
    "California"         0 -221.99594 0         0          0
    "California"         0  -228.2866 0         0          0
    "California"         0 -2.5009766 0         0          0
    "California"         0  -64.57263 0         0          0
    "California"         0 -1.4265137 0         0          0
    "California" 12.701416          0 0         0          0
    "California"         0 -10.180084 0         0          0
    "California"  125.4822          0 0         0          0
    "California"   47.2448          0 0         0          0
    "California" 263.18307          0 0         0          0
    "California"         0  -65.35864 0         0          0
    "California"         0 -103.27151 0         0          0
    "California"         0  -53.89476 0         0          0
    "California"         0  -158.6883 0         0          0
    "California" 130.44116          0 0         0          0
    "California" 239.21268          0 0         0          0
    "California"  40.99327          0 0         0          0
    "California"         0  -25.69075 1         0  -25.69075
    "California"         0 -598.88934 1         0 -598.88934
    "California"         0 -168.44196 1         0 -168.44196
    "California"         0  -197.9165 1         0  -197.9165
    end
    Last edited by megan randall; 24 Jul 2018, 16:08. Reason: Fixed typos

  • #2
    Well, your -xtsur- model does not include year indicators, whereas your separate -xtreg- models include them, so you cannot expect the results to be the same. They could be radically different, even with signs switched.

    That said, I am not familiar with -xtsur-. In fact, I never heard of it before your post. So it is possible that there are other problems with the way you have used it that I would not recognize.

    I would do this as a single -xtreg- with interaction terms, using factor variable notation:

    Code:
    xtreg budcut i.yrs08_15##c.(surplus deficit) /* perhaps also i.year*/, re
    Then I would get the marginal effects of surplus and deficit for both eras with:

    Code:
    margins yrs08_15, dydx(surplus deficit)
    And if you are specifically interested in testing the differences between the two ears, then the z-test that you get in the -xtreg- output for the corresponding interaction term gives you that. Everything done quickly and easily.

    When you use yrs08_15 in the same model with i.year you do, indeed, introduce some colinearity. But it is not a problem. All the information that is needed to estimate the model is there. Stata will omit something to break the colinearity (perhaps yrs08_15 itself, or perhaps an additional year indicator--it doesn't matter what). The -margins- results will still be correct, as well the coefficients of the interaction terms and their tests in the -xtreg- output. If you are troubled by Stata's choice of which variable to omit due to colinearity (though, as I say, it makes absolutely no difference for your purposes), you can "fix" that by changing the order in which variables are listed in the -xtreg- command's varlist.

    As for whether it is advisable to include i.year, that is a substantive question for which you need advice from a colleague in your field. It is not a statistical issue. I will make the generic comment that over a long interval like the 25+ years you are working with, most things are subject to time trends or intermittent yearly shocks or both. If that is true of your measures, then you are best off capturing that source of variation in your model. But if these outcome variables typically are static over time, then there is no need and they just complicate the model. So it's a factual question about your variables that you must answer in order to decide this.

    Thank you for correctly using both -dataex- and code delimiters on your very first post. I will make one suggestion to improve your posting for the future: when posting a data example, be sure to include relevant variables. Your example includes none of your outcome variables. It also omits your panel variable, statenum. (Yes, it includes state, which I assume is in 1-1 correspondence with statenum, but state cannot be used in an -xtset- or -tsset- command, so it is less helpful.) The closer you make your example to what you are actually doing, the better it helps others help you.

    Welcome to Statalist.

    Comment


    • #3
      Clyde, thank you for your helpful response, and for your guidance on how to better select a sample of my data for posting in the future. I actually have a follow-up question.

      I took your suggestion and ran the single -xtreg- with interaction terms, using factor variable notation. After running and making sure to keep i.year for consistency (and after some consideration, I think our research also calls for it), the coefficients that resulted were slightly different from the coefficients I got using the "if" option with -xtreg-. I just wanted to understand why it is different.

      If I run a set of regressions with the same dependent and independent variables using -reg-, all the coefficients are the same, and the only ones that are different are the interaction terms.

      My question is: why are the period dummy results different from the "if" results using -xtreg-? And why doesn't it function the same way as -reg- ? Which set of coefficients is more appropriate, given my data?

      I am posting my results below, so you can get a better idea of what I'm referring to, and I've posted another more relevant sample of my data below that.


      Here is my original code:
      Code:
       **Output with "if" command
          xtreg budcut surplus deficit i.year if yrs90_07 == 1, re 
      **Output with dummies and factor variable notation
          xtreg budcut i.yrs08_15##c.(surplus deficit) i.year, re    
      
      **Output with "if" command with reg
          reg budcut surplus deficit i.year if yrs90_07 == 1 
      **Output with dummies and factor variable notation with reg
          reg budcut i.yrs08_15##c.(surplus deficit) i.year

      And here are the results:
      Code:
      .        
      . **Output with "if" command
      .         xtreg budcut surplus deficit i.year if yrs90_07 == 1, re 
      
      Random-effects GLS regression                   Number of obs     =        864
      Group variable: statenum                        Number of groups  =         48
      
      R-sq:                                           Obs per group:
           within  = 0.4824                                         min =         18
           between = 0.1956                                         avg =       18.0
           overall = 0.4646                                         max =         18
      
                                                      Wald chi2(19)     =          .
      corr(u_i, X)   = 0 (assumed)                    Prob > chi2       =          .
      
      ------------------------------------------------------------------------------
            budcut |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
           surplus |  -.0028264   .0143199    -0.20   0.844    -.0308929    .0252402
           deficit |  -.2869863   .0150961   -19.01   0.000    -.3165741   -.2573984
                   |
              year |
             1991  |   13.77794   5.906338     2.33   0.020     2.201725    25.35415
             1992  |   8.943494   5.854199     1.53   0.127    -2.530526    20.41751
             1993  |   3.110374   5.858806     0.53   0.595    -8.372674    14.59342
             1994  |  -5.877191   5.862637    -1.00   0.316    -17.36775    5.613367
             1995  |   -8.63918   5.858983    -1.47   0.140    -20.12258    2.844216
             1996  |    2.76075   5.862874     0.47   0.638    -8.730272    14.25177
             1997  |  -7.453147   5.881998    -1.27   0.205    -18.98165    4.075357
             1998  |  -11.24208   5.918896    -1.90   0.058     -22.8429    .3587453
             1999  |  -12.09816   5.871641    -2.06   0.039    -23.60637   -.5899597
             2000  |  -10.15746   5.909432    -1.72   0.086    -21.73974    1.424812
             2001  |   -7.19722   5.854025    -1.23   0.219     -18.6709    4.276458
             2002  |   5.922449   6.093754     0.97   0.331     -6.02109    17.86599
             2003  |   22.71145    5.85469     3.88   0.000     11.23647    34.18643
             2004  |  -3.424145    5.87012    -0.58   0.560    -14.92937    8.081079
             2005  |  -7.743823   5.911846    -1.31   0.190    -19.33083    3.843183
             2006  |  -8.767104   5.985753    -1.46   0.143    -20.49896    2.964755
             2007  |  -12.91031   5.895957    -2.19   0.029    -24.46618   -1.354451
             2008  |          0  (empty)
             2009  |          0  (empty)
             2010  |          0  (empty)
             2011  |          0  (empty)
             2012  |          0  (empty)
             2013  |          0  (empty)
             2014  |          0  (empty)
             2015  |          0  (empty)
                   |
             _cons |   9.159548   4.290629     2.13   0.033       .75007    17.56903
      -------------+----------------------------------------------------------------
           sigma_u |  4.8129662
           sigma_e |  28.590343
               rho |  .02755818   (fraction of variance due to u_i)
      ------------------------------------------------------------------------------
      
      . **Output with dummies and factor variable notation
      .         xtreg budcut i.yrs08_15##c.(surplus deficit) i.year, re 
      note: 2015.year omitted because of collinearity
      
      Random-effects GLS regression                   Number of obs     =      1,248
      Group variable: statenum                        Number of groups  =         48
      
      R-sq:                                           Obs per group:
           within  = 0.5054                                         min =         26
           between = 0.2006                                         avg =       26.0
           overall = 0.4898                                         max =         26
      
                                                      Wald chi2(29)     =    1207.17
      corr(u_i, X)   = 0 (assumed)                    Prob > chi2       =     0.0000
      
      ------------------------------------------------------------------------------
            budcut |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
        1.yrs08_15 |   -9.76543   7.011748    -1.39   0.164     -23.5082    3.977343
           surplus |  -.0083066   .0167682    -0.50   0.620    -.0411718    .0245585
           deficit |  -.2831871   .0176085   -16.08   0.000    -.3176991   -.2486752
                   |
          yrs08_15#|
         c.surplus |
                1  |  -.0150631   .0258619    -0.58   0.560    -.0657516    .0356253
                   |
          yrs08_15#|
         c.deficit |
                1  |   .0599058   .0256963     2.33   0.020      .009542    .1102696
                   |
              year |
             1991  |   13.86723   6.879437     2.02   0.044     .3837841    27.35068
             1992  |   8.838486   6.818595     1.30   0.195    -4.525713    22.20269
             1993  |   3.033069   6.823918     0.44   0.657    -10.34156     16.4077
             1994  |  -5.869967    6.82842    -0.86   0.390    -19.25342    7.513489
             1995  |  -8.665818    6.82413    -1.27   0.204    -22.04087    4.709231
             1996  |   2.731266   6.828677     0.40   0.689     -10.6527    16.11523
             1997  |  -7.440635   6.851067    -1.09   0.277    -20.86848    5.987211
             1998  |  -11.03504   6.894562    -1.60   0.109    -24.54814    2.478052
             1999  |  -12.05405   6.838984    -1.76   0.078    -25.45821    1.350114
             2000  |   -10.0065   6.883374    -1.45   0.146    -23.49766    3.484666
             2001  |  -7.165701   6.818358    -1.05   0.293    -20.52944    6.198035
             2002  |   6.215553   7.098257     0.88   0.381    -7.696776    20.12788
             2003  |   22.72619   6.819117     3.33   0.001     9.360965    36.09141
             2004  |  -3.351343   6.837233    -0.49   0.624    -16.75207    10.04939
             2005  |  -7.606154   6.886177    -1.10   0.269    -21.10281    5.890505
             2006  |  -8.409447   6.973244    -1.21   0.228    -22.07675     5.25786
             2007  |  -12.75676   6.867596    -1.86   0.063      -26.217    .7034809
             2008  |   7.787338   6.815739     1.14   0.253    -5.571264    21.14594
             2009  |   58.83734    7.39747     7.95   0.000     44.33856    73.33611
             2010  |   59.80644   7.001592     8.54   0.000     46.08358    73.52931
             2011  |   19.71093    6.81963     2.89   0.004     6.344703    33.07716
             2012  |   .6654005   6.817608     0.10   0.922    -12.69687    14.02767
             2013  |   5.145241   6.824287     0.75   0.451    -8.230116     18.5206
             2014  |  -.3725975   6.813477    -0.05   0.956    -13.72677    12.98157
             2015  |          0  (omitted)
                   |
             _cons |   9.515136   5.031208     1.89   0.059    -.3458504    19.37612
      -------------+----------------------------------------------------------------
           sigma_u |  6.8866527
           sigma_e |  33.348493
               rho |  .04090041   (fraction of variance due to u_i)
      ------------------------------------------------------------------------------
      
      . 
      . **Output with "if" command with reg
      .         reg budcut surplus deficit i.year if yrs90_07 == 1 
      
            Source |       SS           df       MS      Number of obs   =       864
      -------------+----------------------------------   F(19, 844)      =     38.56
             Model |  619220.017        19  32590.5272   Prob > F        =    0.0000
          Residual |  713365.256       844  845.219498   R-squared       =    0.4647
      -------------+----------------------------------   Adj R-squared   =    0.4526
             Total |  1332585.27       863  1544.13126   Root MSE        =    29.073
      
      ------------------------------------------------------------------------------
            budcut |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
           surplus |   .0019853   .0137558     0.14   0.885    -.0250143    .0289849
           deficit |  -.2853708   .0150482   -18.96   0.000    -.3149071   -.2558346
                   |
              year |
             1991  |   13.97317   5.991537     2.33   0.020     2.213112    25.73324
             1992  |   9.028501   5.939911     1.52   0.129    -2.630229    20.68723
             1993  |   3.060708   5.944868     0.51   0.607    -8.607752    14.72917
             1994  |  -6.006742   5.948451    -1.01   0.313    -17.68223    5.668751
             1995  |  -8.731521   5.945018    -1.47   0.142    -20.40027    2.937233
             1996  |   2.651971   5.948825     0.45   0.656    -9.024255     14.3282
             1997  |  -7.652184   5.967212    -1.28   0.200     -19.3645    4.060131
             1998  |  -11.58996   6.000412    -1.93   0.054    -23.36744    .1875193
             1999  |  -12.27926   5.956941    -2.06   0.040    -23.97142   -.5871028
             2000  |  -10.47498    5.99216    -1.75   0.081    -22.23626    1.286308
             2001  |  -7.291033   5.940005    -1.23   0.220    -18.94995    4.367881
             2002  |   6.239883   6.176043     1.01   0.313    -5.882322    18.36209
             2003  |   22.78704   5.940801     3.84   0.000     11.12657    34.44752
             2004  |   -3.60958    5.95525    -0.61   0.545    -15.29842    8.079258
             2005  |  -8.063836   5.994664    -1.35   0.179    -19.83003    3.702362
             2006  |  -9.253365   6.061473    -1.53   0.127     -21.1507    2.643966
             2007  |  -13.19414   5.979207    -2.21   0.028       -24.93    -1.45828
                   |
             _cons |   9.065928   4.289503     2.11   0.035     .6465824    17.48527
      ------------------------------------------------------------------------------
      
      . **Output with dummies and factor variable notation with reg
      .         reg budcut i.yrs08_15##c.(surplus deficit) i.year       
      note: 2015.year omitted because of collinearity
      
            Source |       SS           df       MS      Number of obs   =     1,248
      -------------+----------------------------------   F(29, 1218)     =     40.35
             Model |  1359331.73        29  46873.5081   Prob > F        =    0.0000
          Residual |  1415062.91     1,218  1161.79221   R-squared       =    0.4900
      -------------+----------------------------------   Adj R-squared   =    0.4778
             Total |  2774394.65     1,247  2224.85537   Root MSE        =    34.085
      
      ------------------------------------------------------------------------------
            budcut |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
        1.yrs08_15 |  -9.293813    7.15421    -1.30   0.194    -23.32976    4.742129
           surplus |   .0019853   .0161275     0.12   0.902    -.0296554     .033626
           deficit |  -.2853708   .0176426   -16.18   0.000    -.3199842   -.2507575
                   |
          yrs08_15#|
         c.surplus |
                1  |  -.0247687   .0257195    -0.96   0.336    -.0752281    .0256907
                   |
          yrs08_15#|
         c.deficit |
                1  |   .0636821   .0259594     2.45   0.014      .012752    .1146121
                   |
              year |
             1991  |   13.97317   7.024538     1.99   0.047     .1916378    27.75471
             1992  |   9.028501    6.96401     1.30   0.195    -4.634285    22.69129
             1993  |   3.060708   6.969822     0.44   0.661    -10.61348     16.7349
             1994  |  -6.006742   6.974023    -0.86   0.389    -19.68917    7.675688
             1995  |  -8.731521   6.969997    -1.25   0.211    -22.40605    4.943012
             1996  |   2.651971   6.974461     0.38   0.704    -11.03132    16.33526
             1997  |  -7.652184   6.996018    -1.09   0.274    -21.37777    6.073398
             1998  |  -11.58996   7.034943    -1.65   0.100    -25.39191    2.211988
             1999  |  -12.27926   6.983977    -1.76   0.079    -25.98122    1.422699
             2000  |  -10.47498   7.025267    -1.49   0.136    -24.25794    3.307992
             2001  |  -7.291033    6.96412    -1.05   0.295    -20.95404    6.371969
             2002  |   6.239883   7.240854     0.86   0.389    -7.966046    20.44581
             2003  |   22.78704   6.965053     3.27   0.001     9.122211    36.45188
             2004  |   -3.60958   6.981994    -0.52   0.605    -17.30765    10.08849
             2005  |  -8.063836   7.028203    -1.15   0.251    -21.85256    5.724891
             2006  |  -9.253365   7.106531    -1.30   0.193    -23.19577    4.689035
             2007  |  -13.19414   7.010081    -1.88   0.060    -26.94731    .5590335
             2008  |   7.786288   6.961643     1.12   0.264    -5.871853    21.44443
             2009  |   59.10619   7.541297     7.84   0.000     44.31082    73.90156
             2010  |    59.9613   7.145255     8.39   0.000     45.94292    73.97967
             2011  |   19.69541   6.965273     2.83   0.005     6.030146    33.36067
             2012  |   .6422439   6.963442     0.09   0.927    -13.01943    14.30392
             2013  |   5.108698   6.970342     0.73   0.464    -8.566512    18.78391
             2014  |  -.3850354   6.959551    -0.06   0.956    -14.03907      13.269
             2015  |          0  (omitted)
                   |
             _cons |   9.065928   5.029056     1.80   0.072    -.8006454     18.9325
      ------------------------------------------------------------------------------
      Thank you for any additional insights you might be able to provide.

      Data example:
      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input str20 state float(budcut surplus deficit yrs90_07 yrs08_15 yrs08_15_s yrs08_15_d)
      "Alabama"            0 13.157997          0 1 0         0          0
      "Alabama"     77.23486         0  -40.19884 1 0         0          0
      "Alabama"     61.42675         0  -61.91863 1 0         0          0
      "Alabama"      9.39523  31.58817          0 1 0         0          0
      "Alabama"            0  25.48999          0 1 0         0          0
      "Alabama"            0         0 -27.230835 1 0         0          0
      "Alabama"            0 10.891846          0 1 0         0          0
      "Alabama"            0 1.0253906          0 1 0         0          0
      "Alabama"            0   19.7511          0 1 0         0          0
      "Alabama"            0  8.807983          0 1 0         0          0
      "Alabama"            0 31.693726          0 1 0         0          0
      "Alabama"     79.13228         0  -77.03255 1 0         0          0
      "Alabama"     5.858464         0 -34.120426 1 0         0          0
      "Alabama"     1.461633  .8310919          0 1 0         0          0
      "Alabama"            0  70.21131          0 1 0         0          0
      "Alabama"            0  137.1062          0 1 0         0          0
      "Alabama"            0 142.87372          0 1 0         0          0
      "Alabama"            0         0  -55.65601 1 0         0          0
      "Alabama"            0         0  -52.31865 0 1         0  -52.31865
      "Alabama"    162.30544         0  -274.9464 0 1         0  -274.9464
      "Alabama"    138.98369         0  -348.9378 0 1         0  -348.9378
      "Alabama"     90.99506         0 -184.40778 0 1         0 -184.40778
      "Alabama"     40.31349         0  -85.58302 0 1         0  -85.58302
      "Alabama"            0  28.27649          0 0 1  28.27649          0
      "Alabama"            0   2.06958          0 0 1   2.06958          0
      "Alabama"            0         0  -26.89168 0 1         0  -26.89168
      "Arkansas"           0         0          0 1 0         0          0
      "Arkansas"           0         0 -35.756756 1 0         0          0
      "Arkansas"    14.60597         0  -14.60597 1 0         0          0
      "Arkansas"           0         0 -10.319755 1 0         0          0
      "Arkansas"           0         0          0 1 0         0          0
      "Arkansas"           0         0  -31.54308 1 0         0          0
      "Arkansas"           0         0  -58.16742 1 0         0          0
      "Arkansas"           0  60.38013          0 1 0         0          0
      "Arkansas"           0  38.48828          0 1 0         0          0
      "Arkansas"           0  36.84811          0 1 0         0          0
      "Arkansas"           0         0          0 1 0         0          0
      "Arkansas"   3.9894536         0 -3.8232265 1 0         0          0
      "Arkansas"    83.51202         0  -83.51202 1 0         0          0
      "Arkansas"   34.653454         0  -58.49155 1 0         0          0
      "Arkansas"           0         0  -50.11287 1 0         0          0
      "Arkansas"           0  1.229193          0 1 0         0          0
      "Arkansas"           0         0          0 1 0         0          0
      "Arkansas"           0  39.87108          0 1 0         0          0
      "Arkansas"    2.308497         0  -2.308497 0 1         0  -2.308497
      "Arkansas"   24.851696         0 -33.550426 0 1         0 -33.550426
      "Arkansas"    92.24941         0  -92.24941 0 1         0  -92.24941
      "Arkansas"           0 2.0862823          0 0 1 2.0862823          0
      "Arkansas"           0         0          0 0 1         0          0
      "Arkansas"           0         0          0 0 1         0          0
      "Arkansas"           0         0          0 0 1         0          0
      "Arkansas"           0         0          0 0 1         0          0
      "Arizona"     5.444746         0  -19.32152 1 0         0          0
      "Arizona"     46.77717         0  -45.40803 1 0         0          0
      "Arizona"     10.12044         0  -33.57552 1 0         0          0
      "Arizona"            0 36.428417          0 1 0         0          0
      "Arizona"            0  54.77623          0 1 0         0          0
      "Arizona"            0 111.43684          0 1 0         0          0
      "Arizona"            0 121.54735          0 1 0         0          0
      "Arizona"            0  138.7948          0 1 0         0          0
      "Arizona"            0   12.6167          0 1 0         0          0
      "Arizona"            0  39.49866          0 1 0         0          0
      "Arizona"            0 19.673584          0 1 0         0          0
      "Arizona"            0         0 -36.958984 1 0         0          0
      "Arizona"    165.82265         0   -313.314 1 0         0          0
      "Arizona"     25.10252         0  -97.19553 1 0         0          0
      "Arizona"            0  80.49805          0 1 0         0          0
      "Arizona"            0 179.80518          0 1 0         0          0
      "Arizona"            0 162.70276          0 1 0         0          0
      "Arizona"            0         0  -34.11145 1 0         0          0
      "Arizona"     33.30938         0  -152.5368 0 1         0  -152.5368
      "Arizona"     96.98883         0  -309.8741 0 1         0  -309.8741
      "Arizona"     74.85289         0  -43.05322 0 1         0  -43.05322
      "Arizona"     19.53658 75.935715          0 0 1 75.935715          0
      "Arizona"            0         0  -87.68625 0 1         0  -87.68625
      "Arizona"            0  71.50064          0 0 1  71.50064          0
      "Arizona"            0  7.663818          0 0 1  7.663818          0
      "Arizona"    2.3096232 24.932076          0 0 1 24.932076          0
      "California"         0         0  -22.08824 1 0         0          0
      "California"         0         0 -221.99594 1 0         0          0
      "California"         0         0  -228.2866 1 0         0          0
      "California"         0         0 -2.5009766 1 0         0          0
      "California"         0         0  -64.57263 1 0         0          0
      "California"         0         0 -1.4265137 1 0         0          0
      "California"         0 12.701416          0 1 0         0          0
      "California"         0         0 -10.180084 1 0         0          0
      "California"         0  125.4822          0 1 0         0          0
      "California"         0   47.2448          0 1 0         0          0
      "California"         0 263.18307          0 1 0         0          0
      "California"         0         0  -65.35864 1 0         0          0
      "California"  70.77347         0 -103.27151 1 0         0          0
      "California"   77.6433         0  -53.89476 1 0         0          0
      "California"  24.48418         0  -158.6883 1 0         0          0
      "California"         0 130.44116          0 1 0         0          0
      "California"         0 239.21268          0 1 0         0          0
      "California"         0  40.99327          0 1 0         0          0
      "California"  44.03719         0  -25.69075 0 1         0  -25.69075
      "California"  320.0743         0 -598.88934 0 1         0 -598.88934
      "California"         0         0 -168.44196 0 1         0 -168.44196
      "California"  27.76083         0  -197.9165 0 1         0  -197.9165
      end

      Comment


      • #4
        The coefficients of surplus and deficit in the interaction models are the coefficients conditional on yrs_08_15 = 0. When you run the -reg- and condition on yrs_90_07 == 1, you are, again estimating the effects of surplus and deficit conditional on yrs_08_15 = 0 (since yrs_08_15 and yrs_90_07 are opposites). So those coefficients agree. The coefficient of the interaction term has no effect on the estimation of those pre-08 effects.

        Where the interaction coefficient comes into play is in the effects from 2008 through 2015. The effect of surplus (resp. deficit) in that era is the coefficient of surplus plus the interaction coefficient. Of course, nothing analogous to this will show up in the -reg- that excludes everything from 2008 through 2015.

        But you don't need to do the arithmetic yourself. -margins- does this for you. Run the -margins- command I suggested previously:

        Code:
        margins yrs08_15, dydx(surplus deficit)
        to have Stata calculate the pre- and post-08 effects of surplus and deficit You will see that in the pre-08 years they agree exactly with the -reg- results (and with the coefficients of surplus and deficit in the -xtreg- output0, whereas in the post-08 years they equal the sums of those coefficients plus the interaction coefficient.

        Comment


        • #5
          Thank you, Clyde. I am encountering an issue with the results of the -margins- command after running my regression with -xtreg- and the time period dummies. Stata is telling me that the results are "not estimable." See my output below. I am looking around for more information on the -margins-command to see what might be causing this, but if you are familiar off the top of your head with why this might happen, I would love your input.

          Output:
          Code:
          . **Output with dummies and factor variable notation
          .         xtreg budcut i.yrs08_15##c.(surplus deficit) i.year, re 
          note: 2015.year omitted because of collinearity
          
          Random-effects GLS regression                   Number of obs     =      1,248
          Group variable: statenum                        Number of groups  =         48
          
          R-sq:                                           Obs per group:
               within  = 0.5054                                         min =         26
               between = 0.2006                                         avg =       26.0
               overall = 0.4898                                         max =         26
          
                                                          Wald chi2(29)     =    1207.17
          corr(u_i, X)   = 0 (assumed)                    Prob > chi2       =     0.0000
          
          ------------------------------------------------------------------------------
                budcut |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
          -------------+----------------------------------------------------------------
            1.yrs08_15 |   -9.76543   7.011748    -1.39   0.164     -23.5082    3.977343
               surplus |  -.0083066   .0167682    -0.50   0.620    -.0411718    .0245585
               deficit |  -.2831871   .0176085   -16.08   0.000    -.3176991   -.2486752
                       |
              yrs08_15#|
             c.surplus |
                    1  |  -.0150631   .0258619    -0.58   0.560    -.0657516    .0356253
                       |
              yrs08_15#|
             c.deficit |
                    1  |   .0599058   .0256963     2.33   0.020      .009542    .1102696
                       |
                  year |
                 1991  |   13.86723   6.879437     2.02   0.044     .3837841    27.35068
                 1992  |   8.838486   6.818595     1.30   0.195    -4.525713    22.20269
                 1993  |   3.033069   6.823918     0.44   0.657    -10.34156     16.4077
                 1994  |  -5.869967    6.82842    -0.86   0.390    -19.25342    7.513489
                 1995  |  -8.665818    6.82413    -1.27   0.204    -22.04087    4.709231
                 1996  |   2.731266   6.828677     0.40   0.689     -10.6527    16.11523
                 1997  |  -7.440635   6.851067    -1.09   0.277    -20.86848    5.987211
                 1998  |  -11.03504   6.894562    -1.60   0.109    -24.54814    2.478052
                 1999  |  -12.05405   6.838984    -1.76   0.078    -25.45821    1.350114
                 2000  |   -10.0065   6.883374    -1.45   0.146    -23.49766    3.484666
                 2001  |  -7.165701   6.818358    -1.05   0.293    -20.52944    6.198035
                 2002  |   6.215553   7.098257     0.88   0.381    -7.696776    20.12788
                 2003  |   22.72619   6.819117     3.33   0.001     9.360965    36.09141
                 2004  |  -3.351343   6.837233    -0.49   0.624    -16.75207    10.04939
                 2005  |  -7.606154   6.886177    -1.10   0.269    -21.10281    5.890505
                 2006  |  -8.409447   6.973244    -1.21   0.228    -22.07675     5.25786
                 2007  |  -12.75676   6.867596    -1.86   0.063      -26.217    .7034809
                 2008  |   7.787338   6.815739     1.14   0.253    -5.571264    21.14594
                 2009  |   58.83734    7.39747     7.95   0.000     44.33856    73.33611
                 2010  |   59.80644   7.001592     8.54   0.000     46.08358    73.52931
                 2011  |   19.71093    6.81963     2.89   0.004     6.344703    33.07716
                 2012  |   .6654005   6.817608     0.10   0.922    -12.69687    14.02767
                 2013  |   5.145241   6.824287     0.75   0.451    -8.230116     18.5206
                 2014  |  -.3725975   6.813477    -0.05   0.956    -13.72677    12.98157
                 2015  |          0  (omitted)
                       |
                 _cons |   9.515136   5.031208     1.89   0.059    -.3458504    19.37612
          -------------+----------------------------------------------------------------
               sigma_u |  6.8866527
               sigma_e |  33.348493
                   rho |  .04090041   (fraction of variance due to u_i)
          ------------------------------------------------------------------------------
          
          .         margins yrs08_15, dydx(surplus deficit)
          
          Average marginal effects                        Number of obs     =      1,248
          Model VCE    : Conventional
          
          Expression   : Linear prediction, predict()
          dy/dx w.r.t. : surplus deficit
          
          ------------------------------------------------------------------------------
                       |            Delta-method
                       |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
          -------------+----------------------------------------------------------------
          surplus      |
              yrs08_15 |
                    0  |          .  (not estimable)
                    1  |          .  (not estimable)
          -------------+----------------------------------------------------------------
          deficit      |
              yrs08_15 |
                    0  |          .  (not estimable)
                    1  |          .  (not estimable)
          ------------------------------------------------------------------------------

          Comment


          • #6
            Re-run the -margins- command adding the -noestimcheck- option.

            Comment

            Working...
            X