Announcement

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

  • Time fixed effects in stata

    Hi all,

    I am analyzing panel data in Stata for my masterthesis, and I have some questions about the data and the commands. I have a dataset of approx. 5000 firms for 15 years, annual data. One important thing is that one of the explanatory is not cross sectionally varying. It is the same for every firm in the same year.

    At first I thought time fixed effects are not possible with a cross sectional invaryant variable but my supervisor tells me it is, I think I figured out how, but I am not completely sure. Normally I use Eviews that's why I am not very experienced with using stata.

    I started with the panel setting xtset firmid year, than I tried to estimate the model with this:

    xtreg y x1 x2 xn, fe

    Is is true that this command is for unit/cross sectional fixed effects? And that time fixed effects can be estimated with this:

    xtreg y x1 x2 xn i.year

    If i use this, I receive the following note: 2016.year omitted because of collinearity, can anyone tell me why this is the case? If thougt because of a potential dummy trap when a dummy is included for every year?

    I hope someone can help me,

    Thank you
    Last edited by Rick Last; 19 Apr 2017, 08:52. Reason: Forgot about the dummy trap

  • #2
    If you have a variable which is constant across firms within years, then you cannot estimate its effect in a model that includes year fixed effects. That's true in Stata and Eviews and any other statistical package because it's a mathematical fact. It has nothing to do with the particular algorithm used.

    \xtreg y x1 x2 xn, fe

    Is is true that this command is for unit/cross sectional fixed effects?
    Yes that's correct. It gives you firm fixed effects, but not time fixed effects.

    xtreg y x1 x2 xn i.year

    If i use this, I receive the following note: 2016.year omitted because of collinearity, can anyone tell me why this is the case? If thougt because of a potential dummy trap when a dummy is included for every year?
    This is the way you add time fixed effects to the model. But the omission of 2016 is not just the normal "dummy trap" in this case. If you look carefully at you output you will see that 2016 was omitted in addition to the omission of the first year. The normal "dummy trap" causes you to lose only one indicator.

    The reason you are losing two here is because of the variable that is constant across firms within years. That variable creates colinearity with the year indicators ("dummy variables") even though one of the years has already been omitted as the reference category. To resolve that colinearity, another variable has to go. Removing either the variable that is constant across firms within years or removing one of the year indicators will accomplish this and,in this case Stata chose to remove a year indicator. (As far as I know, Stata resolves colinearities by removing the involved variable that appears last in the command's variable list.) So you are getting an estimate of the effects of that constant-across-firms-within-years variable, but you are not getting full adjustment for/estimation of year effects. If you want to have complete time-level fixed effects, you can do that by moving i.year to the front of the list of predictor variables--then you will get only the usual omission of one year indicator, but then the constant-across-firms-within-years variable will be omitted.

    ​​​​​​​You can have it either way, but it is mathematically impossible to have both.

    Comment


    • #3
      Thanks Clyde for your reply.

      I initially thought that time-period fixed are not possible, but my supervisor told me it is (i am really wondering why he said this), that's why I tried it anyway.

      Removing the constant-across-firms-within-years variable is unfortunately not possible since it is my most important explanatory variable.

      If I use the i.year dummies in the way I did with the xtreg y x1 x2 xn i.year command (so that one year indicacot has to go). Can I still use the estimation output, and say that I in some way did account for time fixed effects, or are the estimates completely not usuable?

      Comment


      • #4
        Usability is in the eye of the beholder. In my field, epidemiology, we almost never use time-level fixed effects. When we are concerned about the passage of time, we typically represent it as a linear trend, or a quadratic if we expect U- or upside down U-shaped effects. Or sometimes a piecewise linear representation. Occasionally we also throw in an indicator for a single year or a couple of years that are really special: e.g. in studying mortality in the early 20th century you need an indicator for 1917 because of the global flu pandemic that wiped out huge numbers of people. Now, the nature of our subject matter is that short time-period variations that are not expressed by these simpler trend models of time trend really are nothing but noise.in most cases, and there is no desire to closely fit the noise.

        In economics and finance, by contrast, it seems to be the standard practice to include yearly (or quarterly, monthly, whatever) indicators. I imagine (but I don't know, having no expertise in these subjects) that longer-term trends are either not a realistic specification of the model, or are not of interest, and there is a need to adjust for many unobserved effects that operate on short time scales.

        You're in a position where you can almost, but not quite, do that. I think you need the advice of somebody in your own discipline to comment on how results like this would be viewed. There are plenty of people in both of these disciplines on this forum, and, hopefully, one of them will chime in on this.

        Comment


        • #5
          Rick:
          I would not be concerned that much about loosing one year more than the one ruled out by Stata to avoid the dummy trap.
          The main issue is methodological: is -i.year- expected to play a relevant role in your regression model in the light of the "dominant" theory in your research field?
          In any case, I would test if -i.year- makes sense in your model via -testparm-.
          Kind regards,
          Carlo
          (Stata 18.0 SE)

          Comment


          • #6
            Thanks four your reply Carlo,

            Time effects are expected to play a rol. My data consist of data of firms from the same country, with time effects I could think about changing intercepts over time due to reguluation changes or tax rates changes, i.e. it makes senses to include time effects.

            Testparm tells me that I can reject H0 (prob. 0.000) which means the time effects makes sense. This is the right conclusion right?

            Comment


            • #7
              Rick:
              yes, it is.
              Kind regards,
              Carlo
              (Stata 18.0 SE)

              Comment


              • #8
                Hi there,

                I am new to this forum. I am more a Rstudio user, but nevertheless my question is more about concept than coding.

                I have recently bumped into a paper by Woo and Kumar (2010) about the effect of public debt on GDP growth. If you download the paper (or you read it) in Table 1 which should be at page 22 of the paper the regression table has something that I cannot understand. In column 6 with the FE estimator it includes time-fixed effect (explained at page 14-15) and I cannot understand what it means. Indeed, FE estimation procedure with demeaned data should factor out those effects, so I am wondering how they managed to insert them. In other words I would expect column 3 and 6 to show the same results due to the FE procedure, instead they change considerably.

                Thank you very much for you time and availability.

                Best

                Comment


                • #9
                  Luca:
                  welcome to this forum.
                  Adding time-fixed effect with -fe- specification makes sense if the researchers want to investigate the effect of time on the regressand within each panel. Besides, as i.year increases as the number of yearly waves of data increases is, in fact, a time-variant predictor.
                  You can take a look ate the following toy-example, that includes a test on the statistical significance of -i.year-:
                  Code:
                  . use "http://www.stata-press.com/data/r15/nlswork.dta"
                  (National Longitudinal Survey.  Young Women 14-26 years of age in 1968)
                  
                  . xtreg ln_wage age i.year, fe
                  
                  Fixed-effects (within) regression               Number of obs     =     28,510
                  Group variable: idcode                          Number of groups  =      4,710
                  
                  R-sq:                                           Obs per group:
                       within  = 0.1060                                         min =          1
                       between = 0.0914                                         avg =        6.1
                       overall = 0.0805                                         max =         15
                  
                                                                  F(15,23785)       =     188.00
                  corr(u_i, Xb)  = 0.0467                         Prob > F          =     0.0000
                  
                  ------------------------------------------------------------------------------
                       ln_wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
                  -------------+----------------------------------------------------------------
                           age |   .0125992   .0102163     1.23   0.217    -.0074253    .0326238
                               |
                          year |
                           69  |   .0748621   .0159011     4.71   0.000      .043695    .1060292
                           70  |   .0478697   .0235673     2.03   0.042     .0016763     .094063
                           71  |   .0865577   .0327939     2.64   0.008     .0222795     .150836
                           72  |   .0856757   .0424903     2.02   0.044     .0023919    .1689594
                           73  |   .0880069    .052344     1.68   0.093    -.0145906    .1906044
                           75  |   .0778607   .0720304     1.08   0.280    -.0633235    .2190449
                           77  |    .108365   .0922272     1.17   0.240    -.0724063    .2891363
                           78  |   .1309518   .1028143     1.27   0.203    -.0705707    .3324743
                           80  |   .1142649    .122792     0.93   0.352    -.1264152     .354945
                           82  |   .1090451   .1431112     0.76   0.446    -.1714619    .3895522
                           83  |   .1211272   .1532018     0.79   0.429    -.1791581    .4214125
                           85  |   .1465637   .1736146     0.84   0.399    -.1937321    .4868594
                           87  |   .1382642   .1941163     0.71   0.476     -.242216    .5187445
                           88  |   .1799741   .2079871     0.87   0.387    -.2276938     .587642
                               |
                         _cons |   1.203731   .1952306     6.17   0.000     .8210667    1.586396
                  -------------+----------------------------------------------------------------
                       sigma_u |   .4058746
                       sigma_e |  .30300411
                           rho |  .64212421   (fraction of variance due to u_i)
                  ------------------------------------------------------------------------------
                  F test that all u_i=0: F(4709, 23785) = 8.80                 Prob > F = 0.0000
                  
                  . testparm(i.year)
                  
                   ( 1)  69.year = 0
                   ( 2)  70.year = 0
                   ( 3)  71.year = 0
                   ( 4)  72.year = 0
                   ( 5)  73.year = 0
                   ( 6)  75.year = 0
                   ( 7)  77.year = 0
                   ( 8)  78.year = 0
                   ( 9)  80.year = 0
                   (10)  82.year = 0
                   (11)  83.year = 0
                   (12)  85.year = 0
                   (13)  87.year = 0
                   (14)  88.year = 0
                  
                         F( 14, 23785) =    6.50
                              Prob > F =    0.0000
                  
                  .
                  Kind regards,
                  Carlo
                  (Stata 18.0 SE)

                  Comment


                  • #10
                    Hi Carlo,

                    thank you for your answer. Anyway I still do not understand. These time-fixed effects which you are including in the regression are varying but their average is constant. In other words they could be aggregate in a time constant term say ai
                    https://www.youtube.com/watch?v=sFvV...&frags=pl%2Cwn this video at the beginning says that it aggregates all these terms under alpha.

                    Best regards,
                    Luca

                    Comment


                    • #11
                      Hi Carlo,

                      sorry maybe I understood. You refer to the second term of this error specification, right?

                      uititit

                      where the term varies throughout time ( so it does not get factored out) and is individual invariant?

                      Best,
                      Luca

                      Comment


                      • #12
                        Luca:
                        the demeaning process you refer to consider panel specific mean of a given variable.
                        Hence, as years increses by one unit per wave (assuming yearly waves), the demeaning process cannot end up with a null coefficient, as time is a time-varying predictors.
                        Things are different for other categorical predictors, such as -gender- which, exception made for very rare instances, is time-invariant: in this case, the mean of a constant equals the constant itself and the -fe- manchinery will wipe out the predictor.
                        Kind regards,
                        Carlo
                        (Stata 18.0 SE)

                        Comment


                        • #13
                          Ok gotcha.

                          Grazie mille

                          Best,
                          Luca

                          Comment

                          Working...
                          X