Announcement

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

  • Time-demeaning time-varying dummy variables

    Hi! I'm running a fixed effects regression (within group method) in which two of my explanatory variables are time-varying dummy variables. For example, employment status=1 if the individual is employed and 0 otherwise (the periods in my data are not consecutive years so there is variation across time for some individuals in terms of employment). I understand that using the within group transformation, we time-demean the explanatory variables. I understand this in the case of continuous variables where we get the average of the data for individual i across time then subtract it from the value for that individual i at time t. But I'm not sure if that works for time-varying dummy variables (and if that makes sense) as I don't get the intuition behind it. I can't get an answer anywhere as all of the resources/video tutorials I've consulted all use continuous time-varying explanatory variables as examples.
    Last edited by Chizuru Hishiro; 29 Mar 2024, 09:25.

  • #2
    Chizuru:
    welcome to this forum.
    Perhaps the following toy-example helps:
    Code:
    . use "https://www.stata-press.com/data/r18/nlswork.dta"
    (National Longitudinal Survey of Young Women, 14-24 years old in 1968)
    
    . xtreg ln_wage i.nev_mar i.year if idcode<=3, fe
    
    Fixed-effects (within) regression               Number of obs     =         39
    Group variable: idcode                          Number of groups  =          3
    
    R-squared:                                      Obs per group:
         Within  = 0.5763                                         min =         12
         Between = 0.3526                                         avg =       13.0
         Overall = 0.4751                                         max =         15
    
                                                    F(15, 21)         =       1.90
    corr(u_i, Xb) = -0.4328                         Prob > F          =     0.0857
    
    ------------------------------------------------------------------------------
         ln_wage | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
       1.nev_mar |  -.5062391   .4037468    -1.25   0.224    -1.345877    .3333984
                 |
            year |
             69  |    .208967   .3868942     0.54   0.595    -.5956235    1.013557
             70  |  -.0423474   .3868942    -0.11   0.914    -.8469379     .762243
             71  |  -.3816407   .3225583    -1.18   0.250    -1.052437    .2891561
             72  |  -.2259469   .3225583    -0.70   0.491    -.8967436    .4448499
             73  |  -.0512957   .3225583    -0.16   0.875    -.7220924     .619501
             75  |   .0213776   .3225583     0.07   0.948    -.6494192    .6921743
             77  |   .0156442   .3225583     0.05   0.962    -.6551526    .6864409
             78  |   .2230704   .3225583     0.69   0.497    -.4477264    .8938671
             80  |   .2523643   .3225583     0.78   0.443    -.4184324    .9231611
             82  |   .1650993   .3396819     0.49   0.632    -.5413079    .8715065
             83  |   .2721994   .3225583     0.84   0.408    -.3985974    .9429961
             85  |   .3510093   .3225583     1.09   0.289    -.3197874    1.021806
             87  |   .2757865   .3225583     0.85   0.402    -.3950102    .9465833
             88  |   .2836143   .3225583     0.88   0.389    -.3871824    .9544111
                 |
           _cons |   1.873077   .3274309     5.72   0.000     1.192147    2.554006
    -------------+----------------------------------------------------------------
         sigma_u |  .23778325
         sigma_e |  .27357548
             rho |  .43034687   (fraction of variance due to u_i)
    ------------------------------------------------------------------------------
    F test that all u_i=0: F(2, 21) = 6.37                       Prob > F = 0.0069
    
    
    . bysort idcode: egen wanted=mean( nev_mar)
    
    . bysort idcode: gen dem_nev_mar= nev_mar-wanted
    
    
    . regress ln_wage i.idcode dem_nev_mar i.year if idcode<=3
    
          Source |       SS           df       MS      Number of obs   =        39
    -------------+----------------------------------   F(17, 21)       =      2.83
           Model |  3.60402454        17  .212001443   Prob > F        =    0.0127
        Residual |  1.57171442        21  .074843544   R-squared       =    0.6963
    -------------+----------------------------------   Adj R-squared   =    0.4505
           Total |  5.17573896        38  .136203657   Root MSE        =    .27358
    
    ------------------------------------------------------------------------------
         ln_wage | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
          idcode |
              2  |  -.3696661   .1152181    -3.21   0.004    -.6092751    -.130057
              3  |  -.4640525   .1106151    -4.20   0.000    -.6940893   -.2340158
                 |
     dem_nev_mar |  -.5062391   .4037468    -1.25   0.224    -1.345877    .3333984
                 |
            year |
             69  |    .208967   .3868942     0.54   0.595    -.5956235    1.013557
             70  |  -.0423474   .3868942    -0.11   0.914    -.8469379     .762243
             71  |  -.3816407   .3225583    -1.18   0.250    -1.052437    .2891561
             72  |  -.2259469   .3225583    -0.70   0.491    -.8967436    .4448499
             73  |  -.0512957   .3225583    -0.16   0.875    -.7220924     .619501
             75  |   .0213776   .3225583     0.07   0.948    -.6494192    .6921743
             77  |   .0156442   .3225583     0.05   0.962    -.6551526    .6864409
             78  |   .2230704   .3225583     0.69   0.497    -.4477264    .8938671
             80  |   .2523643   .3225583     0.78   0.443    -.4184324    .9231611
             82  |   .1650993   .3396819     0.49   0.632    -.5413079    .8715065
             83  |   .2721994   .3225583     0.84   0.408    -.3985974    .9429961
             85  |   .3510093   .3225583     1.09   0.289    -.3197874    1.021806
             87  |   .2757865   .3225583     0.85   0.402    -.3950102    .9465833
             88  |   .2836143   .3225583     0.88   0.389    -.3871824    .9544111
                 |
           _cons |   1.957614   .2950919     6.63   0.000     1.343937    2.571291
    ------------------------------------------------------------------------------
    
    .
    Kind regards,
    Carlo
    (StataNow 18.5)

    Comment

    Working...
    X