Announcement

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

  • First Differences with Indicator Variables

    Dear All,

    I am interested in estimating a linear regression model with first differenced panel data. My question relates to the interpretation of first-differenced indicator variables. In the made up example I use here, my hypothesis is that state unemployment rates will be higher when there is a Republican governor than they are when there is a Democratic governor. I am using both first difference and fixed effects estimators, but I am predominately concerned with the first difference specification for purposes of this post.

    Wooldridge in Introductory Economics and on the Stata forum has made the point that dummy variables are treated like any other variable. What I don't understand is that in cases where there are more than two periods a differenced (0/1) indicator variable can take on three possible values ( -1, 0, and 1). It seems as though differencing transforms an indicator into a three-category categorical variable.

    In the simulated example below (using Stata 14.2), I created the indicator variable repgov where 1 = Republican governor and 0 = Democrat/Independent governor. Differencing this indicator results in three possible scenarios:

    -1 = Change from Republican (t-1) to Democrat (t)
    0 = No change in party control from t-1 to t (Democrat to Democrat or Republican to Republican)
    1 = Change from Democrat (t-1) to Republican (t)

    In Example 1 below, I estimate a linear regression model, differencing the predictor repgov, a continuous control variable lnpcinc (LN per-capita income), and a continuous outcome variable unemp (% unemployed). It does not seem right to interpret the coefficient for D.repgov as though it is a continuous variable. In other words, I don't know that I can conclude from the results shown below that Republican governors are associated with a 0.48 percentage point increase in the unemployment rate.

    In an alternative specification (Example 2), I created three indicator variables corresponding to the possible values of D.repgov (-1, 0, 1). I then estimated a separate model using two of these indicators where no change in party control is the excluded category. I thought the interpretation of the second specification would indicate that relative to no change in party control, there is a 0.85 reduction in the unemployment rate when party control shifts from Republican to Democratic.

    I am starting to think that the first difference specification is not appropriate for addressing my hypothesis that Republican governors are associated with a higher unemployment rate than are Democratic governors because even the second specification using the dummy variables is really capturing the change in party control. Any advice on differencing indicators and interpretation of coefficients would be greatly appreciated.

    Code:
    regress D.(unemp lnpcinc repgov)
    Wooldridge, J. M. (2006). Introductory econometrics: A modern approach. Mason, OH: Thomson/South-Western.

    Code:
    clear all
    set obs 1000
    set seed 12345
    
    ********************************************************************************
    * Create simulated panel data set with t=10 and n = 100
    ********************************************************************************
    * generate year
    egen year = fill(1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10)
    
    * generate state
    bysort year: gen state = _n
    
    * indicate panel data
    xtset state year, yearly
    
    * generate indicator for Republican governor (1=Rep and 0=Dem/Ind)
    gen repgov = floor((1-0+1)*runiform() + 0)
    
    * generate unemployment rate
    gen unemp = rnormal(5.75, 3.6)
    
    * generate LN percapita income
    gen lnpcinc = rnormal(10.4, 0.04)
    
    * first difference Republican governor indicator
    
    gen Drepgov = D.repgov
    
    * generate three indicator variables for each of three D.repgov outcomes
    
    gen     RepToDem = 1 if Drepgov == -1
    replace RepToDem = 0 if Drepgov == 0 | Drepgov == 1
    
    gen     noChng   = 1 if Drepgov == 0
    replace noChng   = 0 if Drepgov == -1 | Drepgov == 1
    
    gen     DemToRep = 1 if Drepgov == 1
    replace DemToRep = 0 if Drepgov == -1 | Drepgov == 0
    
    * Example 0:
    * Tab Drepgov to show possible values are -1, 0, and 1
    tab Drepgov
    
    * Example 1:
    * First Differences Regression with D.repgov
    reg D.(unemp repgov lnpcinc)
    
    * Example 2:
    * First Differences Regression with indicators for values of D.repgov
    reg D.unemp RepToDem DemToRep D.lnpcinc
    
    ********************************************************************************
    * Example 0:
    * Tabulation of Differenced Republican Governor Indicator
    ********************************************************************************
    
        Drepgov |      Freq.     Percent        Cum.
    ------------+-----------------------------------
             -1 |        220       24.44       24.44
              0 |        467       51.89       76.33
              1 |        213       23.67      100.00
    ------------+-----------------------------------
          Total |        900      100.00
    
    ********************************************************************************
    * Example 1:
    * First Differences Regression with D.repgov
    ********************************************************************************
    
          Source |       SS           df       MS      Number of obs   =       900
    -------------+----------------------------------   F(2, 897)       =      1.91
           Model |  103.053302         2  51.5266509   Prob > F        =    0.1489
        Residual |   24217.407       897   26.998224   R-squared       =    0.0042
    -------------+----------------------------------   Adj R-squared   =    0.0020
           Total |  24320.4603       899  27.0527923   Root MSE        =     5.196
    
    ------------------------------------------------------------------------------
         D.unemp |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
          repgov |
             D1. |   .4840804   .2497188     1.94   0.053    -.0060208    .9741815
                 |
         lnpcinc |
             D1. |  -.7564374   3.135607    -0.24   0.809    -6.910418    5.397543
                 |
           _cons |   .0570528   .1732557     0.33   0.742     -.282981    .3970866
    ------------------------------------------------------------------------------
    
    ********************************************************************************
    * Example 2:
    * First Differences Regression with indicators for values of D.repgov
    ********************************************************************************
    
          Source |       SS           df       MS      Number of obs   =       900
    -------------+----------------------------------   F(3, 896)       =      1.66
           Model |  134.715057         3  44.9050191   Prob > F        =    0.1733
        Residual |  24185.7452       896  26.9930192   R-squared       =    0.0055
    -------------+----------------------------------   Adj R-squared   =    0.0022
           Total |  24320.4603       899  27.0527923   Root MSE        =    5.1955
    
    ------------------------------------------------------------------------------
         D.unemp |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
        RepToDem |  -.8564403   .4249167    -2.02   0.044    -1.690388   -.0224923
        DemToRep |   .1054057   .4296481     0.25   0.806    -.7378282    .9486396
                 |
         lnpcinc |
             D1. |  -.8343045   3.136129    -0.27   0.790    -6.989319     5.32071
                 |
           _cons |   .2377924   .2405444     0.99   0.323    -.2343037    .7098886
    ------------------------------------------------------------------------------
    Last edited by Michael Evangelist; 31 Aug 2017, 11:12. Reason: Fixed typo (changed "repcont" to "repgov" in several places)

  • #2
    In the post that you reference, when Jeff states

    Dummy variables are treated as all other variables. If you believe the equation written above, just use the differencing operator on the entire equation. Everything gets differenced. (I remain to this day puzzled as to why researchers think there is a problem differencing dummy variables.)
    he implies that as long as there is temporal variation in a dummy variable (i.e. a switch from 0 to 1 or 1 to 0 over time), then there is no problem in including it in a first differences (FD) model. He talks nothing about the interpretation of the variable.

    In Example 1 below, I estimate a linear regression model, differencing the predictor repgov, a continuous control variable lnpcinc (LN per-capita income), and a continuous outcome variable unemp (% unemployed). It does not seem right to interpret the coefficient for D.repgov as though it is a continuous variable. In other words, I don't know that I can conclude from the results shown below that Republican governors are associated with a 0.48 percentage point increase in the unemployment rate.
    The interpretation of a dummy variable coefficient in FD and fixed effects is exactly the same way you interpret a dummy variable coefficient in OLS regression. To see this, let us consider a simple model in line with your example

    $$
    \quad \text{Unemployment}_{it} = \beta_{0} + \beta_{1} \text{gdpc}_{it} + \beta_{2} \text{repgov}_{it} + u_{it} \quad \quad \quad (1)
    $$


    where \( Unemployment_{it} \) is the unemployment rate in state i and year t, gdpc is GDP per capita (continuous, time varying) and \( repgov_{it} \) is an indicator variable that takes the value one if state i has a republican governor in year t. In period t-1, we have

    $$
    \quad \text{Unemployment}_{it-1} = \beta_{0} + \beta_{1} \text{gdpc}_{it-1} + \beta_{2} \text{repgov}_{it-1} + u_{it-1}
    $$



    The FD equation in this case is therefore


    $$
    \quad \Delta \text{Unemployment}_{it}= \text{Unemployment}_{it} - \text{Unemployment}_{it-1} =
    $$
    $$
    \quad \beta_{1} \Delta \text{gdpc}_{it} + \beta_{2} \Delta \text{repgov}_{it} + \Delta u_{it}
    $$


    Here, you can see that an OLS estimate of the above equation will result in coefficients of \( \Delta gdpc_{it}\) and \( \Delta repgov_{it} \) that have the same interpretation as \( \beta_{1} \) and \( \beta_{2} \) in Eq. 1, respectively. If you are still skeptical, I will use fixed effects, FD and LSDV (OLS with dummies) to show that in the case of T=2, all 3 approaches result in identical coefficients

    Code:
    webuse grunfeld
    
    . sum year
    
        Variable |        Obs        Mean    Std. Dev.       Min        Max
    -------------+---------------------------------------------------------
            year |        200      1944.5    5.780751       1935       1954
    
    . keep if inlist(year, 1951, 1952)
    (180 observations deleted)
    
    . xtreg invest mvalue kstock, fe
    
    Fixed-effects (within) regression               Number of obs     =         20
    Group variable: company                         Number of groups  =         10
    
    R-sq:                                           Obs per group:
         within  = 0.8078                                         min =          2
         between = 0.5980                                         avg =        2.0
         overall = 0.5997                                         max =          2
    
                                                    F(2,8)            =      16.81
    corr(u_i, Xb)  = -0.1065                        Prob > F          =     0.0014
    
    ------------------------------------------------------------------------------
          invest |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
          mvalue |   .0395304   .0641695     0.62   0.555    -.1084448    .1875056
          kstock |   .4838544   .0879291     5.50   0.001     .2810894    .6866193
           _cons |  -57.57569   80.72854    -0.71   0.496     -243.736    128.5847
    -------------+----------------------------------------------------------------
         sigma_u |  175.75085
         sigma_e |  16.557985
             rho |  .99120203   (fraction of variance due to u_i)
    ------------------------------------------------------------------------------
    F test that all u_i=0: F(9, 8) = 81.72                       Prob > F = 0.0000
    
    
    
    . reg D.(invest mvalue kstock), nocons
    
          Source |       SS           df       MS      Number of obs   =        10
    -------------+----------------------------------   F(2, 8)         =     16.81
           Model |   18435.823         2  9217.91149   Prob > F        =    0.0014
        Residual |  4386.66999         8  548.333749   R-squared       =    0.8078
    -------------+----------------------------------   Adj R-squared   =    0.7597
           Total |   22822.493        10   2282.2493   Root MSE        =    23.417
    
    ------------------------------------------------------------------------------
        D.invest |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
          mvalue |
             D1. |   .0395304   .0641695     0.62   0.555    -.1084448    .1875056
                 |
          kstock |
             D1. |   .4838544   .0879291     5.50   0.001     .2810894    .6866193
    ------------------------------------------------------------------------------
    
    . reg invest mvalue kstock i.company
    
          Source |       SS           df       MS      Number of obs   =        20
    -------------+----------------------------------   F(11, 8)        =    456.45
           Model |  1376582.97        11  125143.906   Prob > F        =    0.0000
        Residual |    2193.335         8  274.166874   R-squared       =    0.9984
    -------------+----------------------------------   Adj R-squared   =    0.9962
           Total |  1378776.31        19   72567.174   Root MSE        =    16.558
    
    ------------------------------------------------------------------------------
          invest |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
          mvalue |   .0395304   .0641695     0.62   0.555    -.1084448    .1875056
          kstock |   .4838544   .0879291     5.50   0.001     .2810894    .6866193
                 |
         company |
              2  |   346.2583   173.2644     2.00   0.081    -53.29013    745.8068
              3  |  -261.3165   185.0004    -1.41   0.195    -687.9283    165.2953
              4  |   10.48345   261.1029     0.04   0.969     -591.621    612.5879
              5  |  -265.0453    284.987    -0.93   0.380    -922.2265     392.136
              6  |  -13.54514   266.5807    -0.05   0.961    -628.2812    601.1909
              7  |  -152.7323   295.4151    -0.52   0.619    -833.9607     528.496
              8  |  -27.31449   261.1512    -0.10   0.919    -629.5301    574.9012
              9  |  -142.0501     281.55    -0.50   0.627    -791.3055    507.2053
             10  |   5.195167   305.5027     0.02   0.987    -699.2952    709.6855
                 |
           _cons |   -7.56901   310.1083    -0.02   0.981      -722.68     707.542
    ------------------------------------------------------------------------------
    
    . 
    Last edited by Andrew Musau; 01 Sep 2017, 04:01.

    Comment


    • #3
      Andrew,

      Thank you for providing the example comparing FE, FD, and LSDV for the two-period case. I am still having a little difficulty understanding how the interpretation of dummy variables is the same across the three types of estimation. My confusion is that in LSDV regression, the coefficient for an indicator variable is the estimated difference between two groups as the indicator can only take on two values. On the other hand, taking the first difference of an indicator results in three possible values (-1, 0, 1). It is difficult to understand in the FD case how we are still making a comparison to a reference group. I've come across similar questions on the Stata forum, but haven't seen an entirely intuitive explanation.

      A poster with the same question offered the following answer in response to his own question:
      One shouldn't interpret the estimating equation but rather the original levels equation as FD is just an estimation method just as FE, for example.
      This more or less makes sense to me.

      So, based on your response, I would interpret the coefficient for repgov in the FD equation above to be the difference in the unemployment rate in a state when a Republican is governor relative to when a Democrat is governor.

      Comment


      • #4
        I am still having a little difficulty understanding how the interpretation of dummy variables is the same across the three types of estimation. My confusion is that in LSDV regression, the coefficient for an indicator variable is the estimated difference between two groups as the indicator can only take on two values. On the other hand, taking the first difference of an indicator results in three possible values (-1, 0, 1). It is difficult to understand in the FD case how we are still making a comparison to a reference group. I've come across similar questions on the Stata forum, but haven't seen an entirely intuitive explanation
        The issue is not any inherent difficulty in directly interpreting the first differenced equation but rather what it means in terms of your original hypothesis. If you want to say "a one unit increase in the difference of the indicator of whether a state has a Republican governor increases (decreases) the difference in unemployment by XX units holding the difference in GDP per capita constant", then by all means. However, you need not do this. By virtue of the Frisch-Waugh theorem, provided that we have a balanced panel, we know that the residuals from LSDV (regress with dummy variables) are exactly the deviations from the individual means. See a derivation here . Therefore LSDV is equivalent to the within estimator (xtreg, fe) and, in the case of a balanced panel in which the dummy variable coefficients are not required, can be most easily computed as the within estimator. So this establishes equivalence between LSDV and FE. Next, it can be shown that the GLS estimator for the differenced equation is identical to FE. The algebra which shows this is difficult in the general case (T >2), but is immediate in the case of T=2


        Write the differenced equation as

        $$
        \Delta y_{i} = \beta \Delta x_{i} + v_{i}
        $$

        For T=2, this implies

        $$
        v_{i} = u_{i2} - u_{i1} = 2u_{i2} - (u_{i1} + u_{i2}) = 2(u_{i2} - \bar{u}_{i} )
        $$

        where

        $$
        \bar{u}_{i} = \frac{u_{i1} + u_{i2}}{2}
        $$

        So, based on your response, I would interpret the coefficient for repgov in the FD equation above to be the difference in the unemployment rate in a state when a Republican is governor relative to when a Democrat is governor
        Finally, how to interpret a dummy variable coefficient in your model: First note that your population is the US and not one specific state. Therefore, a positive repgov coefficient implies that Republican governors are associated with XX (dependent variable units) more unemployment relative to Democratic governors after controlling for state fixed-effects and GDP per capita.

        Comment


        • #5
          Thanks Andrew for following up with the additional example.

          Comment

          Working...
          X