Announcement

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

  • Time dummies in Panel Data

    Hello all,

    I have a general question about fixed effect estimation in Stata concerning time dummies. What is the difference between having one trend variable (1,2,3..T) and having T-1 dummy variables for each time period?
    I have GDP growth one the left hand side and various independent variables on the right hand side. My dataset contains of 143 countries.I am using Stata 10.1 for Windows and areg for the fixed effect regression.

    Thanks!

  • #2
    Amin:
    the main difference is in the way you read the results of your panel data regression.
    If you use the dummy approach (that I would prefer), you can see how years contribute to explain the variation of depvar with respect to a reference year (1970 in the following toy example).
    If you consider the trend approach, you can only say that each year contribute to explain the variation of depvar for a given amount (given by the related coefficient), no matter which is the year under discussion:

    Code:
    . use "http://www.stata-press.com/data/r13/union.dta", clear
    (NLS Women 14-24 in 1968)
    
    . xtset idcode year
           panel variable:  idcode (unbalanced)
            time variable:  year, 70 to 88, but with gaps
                    delta:  1 unit
    
    
    . xtreg grade age not_smsa i.year, fe vce(robust) basel
    
    Fixed-effects (within) regression               Number of obs      =     26200
    Group variable: idcode                          Number of groups   =      4434
    
    R-sq:  within  = 0.1465                         Obs per group: min =         1
           between = 0.0103                                        avg =       5.9
           overall = 0.0163                                        max =        12
    
                                                    F(13,4433)         =     54.15
    corr(u_i, Xb)  = 0.0398                         Prob > F           =    0.0000
    
                                  (Std. Err. adjusted for 4434 clusters in idcode)
    ------------------------------------------------------------------------------
                 |               Robust
           grade |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             age |   .0207676    .017992     1.15   0.248    -.0145057    .0560408
        not_smsa |  -.0332252   .0283567    -1.17   0.241    -.0888185    .0223681
                 |
            year |
             70  |          0  (base)
             71  |  -.0057865   .0242874    -0.24   0.812    -.0534019    .0418289
             72  |   .0027519   .0389557     0.07   0.944    -.0736208    .0791245
             73  |   .0070686   .0563978     0.13   0.900    -.1034993    .1176364
             77  |   .0940501   .1268956     0.74   0.459    -.1547286    .3428288
             78  |   .1143574    .145465     0.79   0.432    -.1708265    .3995414
             80  |   .1441521   .1803833     0.80   0.424    -.2094891    .4977934
             82  |   .1614795   .2160628     0.75   0.455    -.2621115    .5850705
             83  |   .2136141   .2337656     0.91   0.361    -.2446831    .6719113
             85  |   .1991364   .2700399     0.74   0.461    -.3302768    .7285495
             87  |   .2087822   .3063528     0.68   0.496    -.3918222    .8093866
             88  |   .2293233   .3304785     0.69   0.488    -.4185796    .8772263
                 |
           _cons |   12.01606   .3775464    31.83   0.000     11.27588    12.75624
    -------------+----------------------------------------------------------------
         sigma_u |   2.441513
         sigma_e |  .48188672
             rho |  .96250488   (fraction of variance due to u_i)
    ------------------------------------------------------------------------------
    
    . xtreg grade age not_smsa c.year, fe vce(robust) 
    
    Fixed-effects (within) regression               Number of obs      =     26200
    Group variable: idcode                          Number of groups   =      4434
    
    R-sq:  within  = 0.1453                         Obs per group: min =         1
           between = 0.0117                                        avg =       5.9
           overall = 0.0164                                        max =        12
    
                                                    F(3,4433)          =    227.24
    corr(u_i, Xb)  = 0.0427                         Prob > F           =    0.0000
    
                                  (Std. Err. adjusted for 4434 clusters in idcode)
    ------------------------------------------------------------------------------
                 |               Robust
           grade |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             age |   .0087617   .0156482     0.56   0.576    -.0219166    .0394399
        not_smsa |    -.03262   .0283461    -1.15   0.250    -.0881926    .0229526
            year |   .0261751   .0158766     1.65   0.099     -.004951    .0573011
           _cons |    10.4239    .788173    13.23   0.000     8.878687    11.96911
    -------------+----------------------------------------------------------------
         sigma_u |  2.4409578
         sigma_e |  .48210979
             rho |  .96245503   (fraction of variance due to u_i)
    ------------------------------------------------------------------------------
    
    .
    Kind regards,
    Carlo
    (StataNow 18.5)

    Comment


    • #3
      Thank you, Carlo. I understand it now.

      Best,

      Amin

      Comment


      • #4
        Dear Carlo;
        How can one create a dummy for a time interval? For example, For Amin data set, I want to create dummies as: dummy1 for the years 70-74, dummy to for the years 76-79, dummy3 for the years 80-84. In Short: creating dummies for panel data so that first dummy is related to the first 5 years, second dummy is related to the second five years and so on.

        I have tried that: generate dummy1 = (year>=1970 & year<=1979)

        Is there an easy way to create for the whole intervals?
        Last edited by Mecit Yildirim; 13 Nov 2017, 13:24.

        Comment


        • #5
          Originally posted by Mecit Yildirim View Post
          Dear Carlo;
          How can one create a dummy for a time interval? For example, For Amin data set, I want to create dummies as: dummy1 for the years 70-74, dummy to for the years 76-79, dummy3 for the years 80-84. In Short: creating dummies for panel data so that first dummy is related to the first 5 years, second dummy is related to the second five years and so on.

          I have tried that: generate dummy1 = (year>=1970 & year<=1979)

          Is there an easy way to create for the whole intervals?
          You'll have to do some kind of transformation. Lots of possible solutions: Something like:
          recode oldvar "rules", generate(nevar)
          tab nevar, gen(dnewvar1)

          Comment


          • #6
            Mecit:
            you may want to try something along the following lines:
            Code:
            sort panelid year
            bysort panelid: egen dummy=seq(), b(5)
            Kind regards,
            Carlo
            (StataNow 18.5)

            Comment


            • #7
              Dear Carlo,

              thank you for your comments!

              I want to run a panel regression with final demand and import data for 40 countries over 20 years. I regress final demand and relative import prices on imports and add country fixed effects. My beta coefficient for demand is supposed to capture the average world import demand elasticity. I have three subperiods from pre-, in- and post crisis and I want to measure whether the world elasticity has changed significantly from the pre-crisis to the in- and post-crisis period. So far I interacted my final demand variable with dummies for period 2 and 3 and am wondering whether they need to be included linearly as well. My theoretical model assumes the general intercept to be zero.

              Thanks!

              Klaus

              Comment


              • #8
                Klaus:
                welcome to this forum.
                As per FAQ, the best way to share what you'after is to post what you typed and what Stata gave you back via CODE delimiters. Thanks.
                Kind regards,
                Carlo
                (StataNow 18.5)

                Comment


                • #9
                  Dear Carlo,

                  thank you for all the answers, I have understood a lot more about time dummies and they answered some of my questions.

                  However, I have one more: I would like to run a fixed effects model with time dummies for 1973-82 1983-90 1991-98 1999-2005 2006-13 and 2014-17 and interact them with the independent variables to see time trends in them. Let's say I want 1973-82 as the base period. If I omit it, is the constant the value for 1973-82? and what about the parameters for the 'base' independent variables, are they also the values for the independent variable for 1973-82?

                  This is my code (AV: 1983-90; ... AZ: 2014-17):

                  Code:
                  xtreg lnODAlagged AV AW AX AY AZ UNGA100 i.AV#c.UNGA100 i.AW#c.UNGA100 i.AX#c.UNGA100 i.AY#c.UNGA100 i.AZ#c.UNGA100 UNSC i.AV#c.UNSC i.AW#c.UNSC i.AX#c.UNSC i.AY#c.UNSC i.AZ#c.UNSC lntrademil i.AV#c.lntrademil i.AW#c.lntrademil i.AX#c.lntrademil i.AY#c.lntrademil i.AZ#c.lntrademil expsurp i.AV#c.expsurp i.AW#c.expsurp i.AX#c.expsurp i.AY#c.expsurp i.AZ##c.expsurp lnGDPpc i.AV#c.lnGDPpc i.AW#c.lnGDPpc i.AX#c.lnGDPpc i.AY#c.lnGDPpc i.AZ#c.lnGDPpc ipolity210 i.AV#c.ipolity210 i.AW#c.ipolity210 i.AX#c.ipolity210 i.AY#c.ipolity210 i.AZ#c.ipolity210 lnpopulation i.AV#c.lnpopulation i.AW#c.lnpopulation i.AX#c.lnpopulation i.AY#c.lnpopulation i.AZ#c.lnpopulation,fe
                  Is this correct? Is there any way to make this look neater?

                  Comment


                  • #10
                    Originally posted by Philip Horster View Post
                    Is this correct? Is there any way to make this look neater?
                    I have found an answer to how to make things look neater, the new code is:

                    Code:
                    xtreg lnODAlagged i.period##(c.UNGA100 i.UNSC c.lntrademil i.expsurp c.lnGDPpc c.ipolity210 c.lnpopulation), fe
                    where period (categorical) ranges from 1-6 a value for each period respectively. I have also set the base period to 1:

                    Code:
                    fvset base 1 period
                    I am now pretty sure that the values desplayed for each of the independent variables when not interacting, are the base values for period 1 (that is 1973-82). In other words, the constant is the value for period 1 and the value of UNGA100 (UNSC lntrademil etc) is the parameter for its interaction with period 1.
                    Just to confirm, is this correct?

                    Here is the beginning of the result I get, for clarification:

                    Code:
                    xtreg lnODAlagged i.period##(c.UNGA100 i.UNSC c.lntrademil i.expsurp c.lnGDPpc c.ipolity210 c.lnpopulation), fe
                    
                    Fixed-effects (within) regression               Number of obs     =      1,784
                    Group variable: code                            Number of groups  =         52
                    
                    R-sq:                                           Obs per group:
                         within  = 0.3187                                         min =          2
                         between = 0.5028                                         avg =       34.3
                         overall = 0.4048                                         max =         42
                    
                                                                    F(47,1685)        =      16.77
                    corr(u_i, Xb)  = 0.3921                         Prob > F          =     0.0000
                    
                    ---------------------------------------------------------------------------------------
                              lnODAlagged |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
                    ----------------------+----------------------------------------------------------------
                                   period |
                                       2  |  -3.216908    2.19394    -1.47   0.143    -7.520043    1.086227
                                       3  |  -7.224089   2.180476    -3.31   0.001    -11.50082   -2.947362
                                       4  |  -17.58991   2.107016    -8.35   0.000    -21.72255   -13.45727
                                       5  |  -11.54484   2.164794    -5.33   0.000    -15.79081   -7.298868
                                       6  |  -8.785906   4.107527    -2.14   0.033     -16.8423   -.7295138
                                          |
                                  UNGA100 |    -.00161   .0053431    -0.30   0.763    -.0120899    .0088699
                                   1.UNSC |  -.1096866   .1637886    -0.67   0.503    -.4309371    .2115638
                               lntrademil |   .4802891   .0843842     5.69   0.000     .3147803     .645798
                                1.expsurp |   .3718702   .0973938     3.82   0.000     .1808445    .5628958
                                  lnGDPpc |  -.5277899   .1289162    -4.09   0.000    -.7806426   -.2749372
                               ipolity210 |  -.0016497   .0023371    -0.71   0.480    -.0062336    .0029341
                             lnpopulation |   -.584524   .2293405    -2.55   0.011    -1.034346   -.1347017
                                          |
                         period#c.UNGA100 |
                                       2  |   .0006761   .0081416     0.08   0.934    -.0152926    .0166448
                                       3  |  -.0003218   .0061522    -0.05   0.958    -.0123885    .0117448
                                       4  |   .0044295   .0060516     0.73   0.464    -.0074398    .0162989
                                       5  |  -.0019018   .0061625    -0.31   0.758    -.0139887    .0101851
                                       6  |  -.0091803   .0091002    -1.01   0.313    -.0270292    .0086686
                                          |
                              period#UNSC |
                                     2 1  |   .3399586   .2390666     1.42   0.155    -.1289402    .8088573
                                     3 1  |   .2499088   .2457923     1.02   0.309    -.2321815    .7319992
                                     4 1  |   .3266512   .2425464     1.35   0.178    -.1490727     .802375
                                     5 1  |   .2132417   .2341957     0.91   0.363    -.2461034    .6725867
                                     6 1  |  -.1130696   .5234829    -0.22   0.829    -1.139815    .9136756
                    Last edited by Philip Horster; 24 May 2020, 14:45.

                    Comment


                    • #11
                      Uh, now I have come across another problem and this really does seem like a dead end.

                      Instead of running the previous regression:

                      Originally posted by Philip Horster View Post

                      Code:
                      xtreg lnODAlagged i.period##(c.UNGA100 i.UNSC c.lntrademil i.expsurp c.lnGDPpc c.ipolity210 c.lnpopulation), fe
                      I run this:

                      Code:
                      xtreg lnODAlagged i.period##(c.lntrademil i.expsurp c.GermanFDI2010 c.tradeopen c.FDIinflow c.hf_efiscore) lnGDPpc UNGA100 lnpopulation
                      and get the following results. Does anybody know why period 1 is empty, while period 2 and 3 aren't even shown and 6 is omitted? In the above case it worked...


                      Code:
                      note: 1.period identifies no observations in the sample
                      note: 6.period omitted because of collinearity
                      note: 1.period#c.lntrademil identifies no observations in the sample
                      note: 6.period#c.lntrademil omitted because of collinearity
                      note: 1.period#0.expsurp identifies no observations in the sample
                      note: 1.period#1.expsurp identifies no observations in the sample
                      note: 6.period#1.expsurp omitted because of collinearity
                      note: 1.period#c.GermanFDI2010 identifies no observations in the sample
                      note: 6.period#c.GermanFDI2010 omitted because of collinearity
                      note: 1.period#c.tradeopen identifies no observations in the sample
                      note: 6.period#c.tradeopen omitted because of collinearity
                      note: 1.period#c.FDIinflow identifies no observations in the sample
                      note: 6.period#c.FDIinflow omitted because of collinearity
                      note: 1.period#c.hf_efiscore identifies no observations in the sample
                      note: 6.period#c.hf_efiscore omitted because of collinearity
                      
                      Random-effects GLS regression                   Number of obs     =        306
                      Group variable: code                            Number of groups  =         47
                      
                      R-sq:                                           Obs per group:
                           within  = 0.1026                                         min =          1
                           between = 0.7326                                         avg =        6.5
                           overall = 0.6247                                         max =         10
                      
                                                                      Wald chi2(23)     =     137.61
                      corr(u_i, X)   = 0 (assumed)                    Prob > chi2       =     0.0000
                      
                      ----------------------------------------------------------------------------------------
                                 lnODAlagged |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
                      -----------------------+----------------------------------------------------------------
                                      period |
                                          1  |          0  (empty)
                                          4  |   3.090255   2.630819     1.17   0.240    -2.066056    8.246566
                                          5  |     .47186   1.289866     0.37   0.714    -2.056231    2.999951
                                          6  |          0  (omitted)
                                             |
                                  lntrademil |   .0192495   .1597446     0.12   0.904    -.2938442    .3323432
                                   1.expsurp |  -.2802305   .3636174    -0.77   0.441    -.9929076    .4324465
                               GermanFDI2010 |   .0031039   .0023871     1.30   0.194    -.0015747    .0077825
                                   tradeopen |   .0028524   .0068249     0.42   0.676    -.0105241    .0162288
                                   FDIinflow |  -.0323243   .0427126    -0.76   0.449    -.1160395    .0513909
                                 hf_efiscore |     .00896   .0216883     0.41   0.680    -.0335483    .0514682
                                             |
                         period#c.lntrademil |
                                          1  |          0  (empty)
                                          4  |  -.0824471   .1383152    -0.60   0.551    -.3535398    .1886456
                                          5  |   -.052117     .10863    -0.48   0.631    -.2650279    .1607939
                                          6  |          0  (omitted)
                                             |
                              period#expsurp |
                                        1 0  |          0  (empty)
                                        1 1  |          0  (empty)
                                        4 1  |   .9502599   .5637358     1.69   0.092     -.154642    2.055162
                                        5 1  |   .3495964   .3640857     0.96   0.337    -.3639986    1.063191
                                        6 1  |          0  (omitted)
                                             |
                      period#c.GermanFDI2010 |
                                          1  |          0  (empty)
                                          4  |  -.0035658   .0025625    -1.39   0.164    -.0085881    .0014565
                                          5  |  -.0029331   .0024025    -1.22   0.222     -.007642    .0017758
                                          6  |          0  (omitted)
                                             |
                          period#c.tradeopen |
                                          1  |          0  (empty)
                                          4  |   -.011615    .009716    -1.20   0.232    -.0306581    .0074281
                                          5  |   .0055226   .0053628     1.03   0.303    -.0049883    .0160335
                                          6  |          0  (omitted)
                                             |
                          period#c.FDIinflow |
                                          1  |          0  (empty)
                                          4  |  -.0000657   .0905689    -0.00   0.999    -.1775775    .1774462
                                          5  |   .0337809   .0411783     0.82   0.412    -.0469271     .114489
                                          6  |          0  (omitted)
                                             |
                        period#c.hf_efiscore |
                                          1  |          0  (empty)
                                          4  |  -.0382143   .0407368    -0.94   0.348    -.1180569    .0416283
                                          5  |  -.0140349   .0172463    -0.81   0.416     -.047837    .0197672
                                          6  |          0  (omitted)
                                             |
                                     lnGDPpc |  -.4147728   .2277486    -1.82   0.069    -.8611519    .0316063
                                     UNGA100 |  -.0013371   .0049505    -0.27   0.787      -.01104    .0083658
                                lnpopulation |   1.121926   .1989363     5.64   0.000     .7320175    1.511834
                                       _cons |   -13.0447   4.191138    -3.11   0.002    -21.25917   -4.830216
                      -----------------------+----------------------------------------------------------------
                                     sigma_u |  1.0721369
                                     sigma_e |  .68723504
                                         rho |  .70877984   (fraction of variance due to u_i)
                      ----------------------------------------------------------------------------------------

                      Comment


                      • #12
                        Philip:
                        what is not clear with the comprehensive explantion that Stata gave back?
                        Code:
                        note: 1.period identifies no observations in the sample
                        note: 6.period omitted because of collinearity
                        note: 1.period#c.lntrademil identifies no observations in the sample
                        note: 6.period#c.lntrademil omitted because of collinearity
                        note: 1.period#0.expsurp identifies no observations in the sample
                        note: 1.period#1.expsurp identifies no observations in the sample
                        note: 6.period#1.expsurp omitted because of collinearity
                        note: 1.period#c.GermanFDI2010 identifies no observations in the sample
                        note: 6.period#c.GermanFDI2010 omitted because of collinearity
                        note: 1.period#c.tradeopen identifies no observations in the sample
                        note: 6.period#c.tradeopen omitted because of collinearity
                        note: 1.period#c.FDIinflow identifies no observations in the sample
                        note: 6.period#c.FDIinflow omitted because of collinearity
                        note: 1.period#c.hf_efiscore identifies no observations in the sample
                        note: 6.period#c.hf_efiscore omitted because of collinearity
                        Kind regards,
                        Carlo
                        (StataNow 18.5)

                        Comment


                        • #13
                          I don't understand where the collinearity can come from, is it collinearity with one other period? Because all variables are omitted in period 6. Also why has period 1 no observations in the sample
                          while it had in the first regression? What about period 2 and 3? Why are they not shown? One variable only starts at period 4, is that the answer?

                          Comment


                          • #14
                            Philip:
                            in all likelihood, the main issue is collinearity with the fixed effect.
                            Other omissions are probably due to lack of observations for a given level of the categorical variable(s).
                            Kind regards,
                            Carlo
                            (StataNow 18.5)

                            Comment


                            • #15
                              Okay, thank you Carlo! Your answers to other entrances have proven very helpful in other cases as well, so thank you for those too!

                              Comment

                              Working...
                              X