Announcement

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

  • Fixed firm effects vs fixed firm & time effects

    Hi! I was wondering what is the code for running a linear fixed firm effects and fixed firm and time effects regression on panel data? I firstly tired using the manual tabs to do so, but I came to have exactly the same output for both firm fiixed and firm and time fixed effects! Thank you in advance!


  • #2
    Elizabete:
    please report what you typed and what Stata gave you back (as per FAQ). Thanks.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      For fixed effects I first I define the sample as the panel data in regard to the identifier of the firm, in my case Global Company Key

      Code:
       xtset GlobalCompanyKey
      And then run the fixed effects regression

      Code:
        xtreg InvWinsor i.CR_POM## i.Tech_Industry Size Profitability, fe
      For fixed firm and time effects , I define the sample as panel data in respect to company and time

      Code:
        xtset GlobalCompanyKey D
      And then run agin the fixed effects regression

      Code:
       xtreg InvWinsor i.CR_POM## i.Tech_Industry Size Profitability, fe
      Is this the correct way to do firm fixed effects and firm & time fixed effect regression on panel data? Thank you in advance!



      Comment


      • #4
        Hi Elizabete,

        Check the help of -xtset-, I think you did a slight mistake. The syntax is "xtset panelvar [timevar]", and on the first line of code you only wrote the gvkey and not the time.

        About your last equation, there are a few potential problems:

        1) there is a space after ##
        2) what is CR_POM?
        3) Aren't the tech industry dummies redundant given that you have firm fixed effects?

        Finally, Stata won't add time FEs by itself, so you would need to add as a regressor something like "i.timevar"

        Best,
        Sergio

        Comment


        • #5
          Thanks Sergio!

          I see your point in regard to specifying the panel data in both regard to company and time, so I did that as follows, where year stands for year.

          Code:
           xtset GlobalCompanyKey year, yearly
          However I am still wondering how can I make my regression both fixed firm and time effects?

          1) I deleted the space, but It did not really raise any issues before. I assume the STATA disregards it
          2) CR_POM is a dummy variable that differentiates between firms close to a credit rating change and the ones not close.
          3) indeed, that was another question I had. In general I am trying to derive what is % change in firm net investments, when close to a credit rating change, as well as if this effect is more prominent in Tech_Industry. For robustness I run OLS, firm fixed effects and trying to run firm fixed & time fixed effects. When I run OLS regression the Tech_Industry variable does not get omitted, but when change to firm fixed effects it omits the variable, I was wondering why this is the case? And how should i interpret this, also with the interaction effect present? Below is my regression code and output. Thank you in advance!

          Code:
            xtset    GlobalCompanyKey    Year1, yearly
              panel variable:    GlobalCompanyKey (unbalanced)
              time variable:    Year1, 1982 to 2010, but with gaps
              delta:    1 year
          
          xtreg TFPWinsor i.CR_POM##i.Tech_Industry Size Profitability, fe
          note: 1.Tech_Industry omitted because of collinearity
          
          Fixed-effects (within) regression               Number of obs      =      6101
          Group variable: GlobalComp~y                    Number of groups   =       579
          
          R-sq:  within  = 0.1041                         Obs per group: min =         1
                 between = 0.0004                                        avg =      10.5
                 overall = 0.0230                                        max =        24
          
                                                          F(4,5518)          =    160.27
          corr(u_i, Xb)  = -0.7484                        Prob > F           =    0.0000
          
          --------------------------------------------------------------------------------------
                     TFPWinsor |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
          ---------------------+----------------------------------------------------------------
                      1.CR_POM |   .0056888   .0044095     1.29   0.197    -.0029557    .0143332
               1.Tech_Industry |          0  (omitted)
                               |
          CR_POM#Tech_Industry |
                          1 1  |   -.006015   .0081939    -0.73   0.463    -.0220783    .0100483
                               |
                          Size |  -.0503545   .0064388    -7.82   0.000    -.0629772   -.0377319
                 Profitability |  -.7625212   .0306957   -24.84   0.000    -.8226968   -.7023456
                         _cons |   .5824387   .0611959     9.52   0.000     .4624705    .7024068
          ---------------------+----------------------------------------------------------------
                       sigma_u |  .09971809
                       sigma_e |  .11421482
                           rho |   .4325468   (fraction of variance due to u_i)
          --------------------------------------------------------------------------------------
          F test that all u_i=0:     F(578, 5518) =     1.63           Prob > F = 0.0000
          Last edited by Elizabete Lurie; 28 May 2015, 15:36.

          Comment


          • #6
            "1.Tech_Industry" is omitted because it is collinear with the firm fixed effects. Firms in your sample don't change industry, so there is no variation left in the tech industry dummy after controlling for the firm dummies. I wouldn't worry about that.

            If you want to add time FEs, just add "i.Year1" to the regression, and you'll see a list of all year dummies (one of which will be omitted of course, as it's collinear with the constant)

            Comment


            • #7
              Hang on! If you have -xtset GlobalCompanyKey year, yearly-, then GlobalCompanyKey and year must jointly uniquely identify the observations in the data set. Otherwise, Stata would have complained and refused to do the -xtset-. That being the case, if you attempt to add i.year fixed effects to your model, the i.year variables and the GlobalCompanyKey fixed effects will also uniquely identify the observations, and all of your other model variables will be collinear with them! I can't predict whether Stata will respond by dropping some of the year indicators, or by dropping other variables, but you will in no way have a model that incorporates all those variables and company and year fixed effects! Such a model would be beyond saturated and completely unidentified. If you are concerned about time trends, incorporating c.year into your model, or some transform of c.year, will not cause problems. But you cannot estimate anything in your data controlling for firm and i.year when they jointly identify unique observations.

              When I run OLS regression the Tech_Industry variable does not get omitted, but when change to firm fixed effects it omits the variable, I was wondering why this is the case? And how should i interpret this, also with the interaction effect present?
              This is just a more limited version of the same thing. Each firm is a Tech_Industry or is not, but that status does not change from year to year. So when you include the firm fixed effects, Tech_Industry is collinear with them, and Stata omits it from the model. This is not a problem. A fixed-effects model where a main effect is collinear with the fixed effect is almost the only situation in which it is OK to have an interaction term and omit one of the main effects. You can still interpret the coefficient of CR_POM as the effect of CR_POM on TFPWinsor conditional on Tech_Industry == 0. And you can still interpret the interaction coefficient as the difference between the effect of CR_POM on TFPWinsor conditional on Tech_Industry == 1 and that effect conditional on Tech_Industry == 0. And -margins- will still give you correct outputs. The only difference is that you cannot estimate the effect of Tech_Industry itself (either overall or conditioned on CR_POM being either 0 or 1) in such a model, because it has been trumped by the fixed effects and is not estimable in that model..

              Looking at the F test at the very bottom of your posted output, there is clear evidence that including the fixed effects is important and the pooled regression model (estimated by OLS) is not valid for your data, so you can't really revert to that. If you need to estimate an effect for Tech_Industry, then you might consider looking at a random effects model. (In econometrics it is customary to first check the admissibility of a random effects model with a Hausman test, although in other disciplines this nicety is sometimes dispensed with, for better or for worse.) Another option is to look into -xtreg, be- for this.

              Comment


              • #8
                Thank you so much! it really clears up things!! Just a quick question in regard to adding time trends, I am a bit unsure where to add the c.year in the regression. For firm fixed effects I used as follows

                Code:
                   
                 xtreg TFPWinsor i.CR_POM##i.Tech_Industry Size Profitability, fe
                Last edited by Elizabete Lurie; 28 May 2015, 16:29.

                Comment


                • #9
                  Also I just run into an issue of using the margins function for the the regression and the output as mentioned in #5 and it says it is not estimable as shown below:

                  Code:
                  . margins, dydx(CR_POM) at(Tech_Industry == (0 1))
                  
                  Average marginal effects                          Number of obs   =       6101
                  Model VCE    : Conventional
                  
                  Expression   : Linear prediction, predict()
                  dy/dx w.r.t. : 1.CR_POM
                  
                  1._at        : Tech_Industry   =           0
                  
                  2._at        : Tech_Industry   =           1
                  
                  ------------------------------------------------------------------------------
                               |            Delta-method
                               |      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
                  -------------+----------------------------------------------------------------
                  1.CR_POM     |
                           _at |
                            1  |          .  (not estimable)
                            2  |          .  (not estimable)
                  ------------------------------------------------------------------------------
                  Note: dy/dx for factor levels is the discrete change from the base level.
                  How shall I handle this?

                  Thank you in advance!

                  Comment


                  • #10
                    I am a bit unsure where to add the c.year in the regression.
                    You can put it anywhere in your list of predictor variables, the order of those variables doesn't matter. Remember that including c.year is adjusting for linear trends in TFPWinsor over time. If there are time trends that are curvilinear, this will not properly capture them. For any non-linear monotone trend, over reasonably short timeframes, the misspecification will probably be minor and unimportant. But if there are U-shaped or other highly curved trends over the years in your study, then this specification will be inadequate and could produce misleading results. If that is the case, you should consider a more complicated specification of time trends such as a quadratic (c.year##c.year) or a linear or cubic spline (-help mkspline-). Some graphical exploration before you proceed might be helpful.

                    I just run into an issue of using the margins function for the the regression and the output as mentioned in #5 and it says it is not estimable
                    My bad. Because Tech_Industry is dropped from your model due to collinearity with the fixed effects, these marginal effects are also unestimable from this model. This is not a fluke of Stata's -margins- command. It is an inherent limitation of a fixed effects model with an interaction that includes a main effect that is collinear with the covariates.

                    If estimating this effect is crucial, you may have to go to a random effects model, or a between-effects model.
                    Last edited by Clyde Schechter; 28 May 2015, 18:00.

                    Comment


                    • #11
                      Thank you! Just wondering how would it change my analysis if I switched to random or between-effects? By using firm fixed effects I am assuming that each firm is different and have different influences that can sway the change in investment spending, wont this be compromised by switching the model? Thanks!

                      Comment


                      • #12
                        A random effects model also accounts for individual level differences between firms. However, in a random effects model, those differences are assumed to follow a normal distribution, rather than being freely estimated from the data. The fixed effects estimator used with a properly specified model will provide consistent estimates of all model parameters. The random effects estimator may not: if the normality assumption is too much of a mis-specification, the estimator will not be consistent, though it may still give very good answers and has the virtue of being more efficient. So then it becomes a question of whether it is better to shoot with a gun that has a perfectly-aligned site but tends to scatter its bullets somewhat wide of the point aimed at (fixed effects), or a gun that sends its bullets very close to where it is aimed at but whose site may be slightly off-kilter (random effects).

                        As an outsider, I have the distinct impression that in econometrics, there is an extremely strong preference for consistency over efficiency in estimation, and random effects models are accepted only when there is collateral demonstration of consistency for the particular problem at hand through a Hausman test. In other disciplines, people tend to be more willing to make a tradeoff between efficiency and consistency and random effects models are more widely used. (The econometricians might say they are more widely misused.) You might look into -help hausman- and try running a Hausman test on your data. It could get you off this hook, if your data are suitable.

                        Another possibility is to do a between-panels estimator with -xtreg, be-. This is a different model really: in effect the values of all the variables are averaged within panels to create a single observation per panel that has no time distinctions. The regression is then carried out on those averages. It is quite appropriate for estimating the effects of time-invariant variables such as Tech_Industry. The problem is that it is not so great for estimating effects of panel-level variables that change over time, such as your CR_POM. It is not that those estimates are altogether meaningless or wrong: they reflect the average effect over time. But that is a different animal from the in-the-moment effect of the variable. It's really estimating a different thing. And you could run into technical problems as well. For example, if you have the same number of observations for each firm, and each firm has exactly one observation with CR_POM = 1 and all others with CR_POM = 0, then the average value of CR_POM will be the same for all firms, and it will be collinear with the constant and will end up being omitted!

                        There are, unfortunately, no entirely satisfactory solutions to this problem. For what it's worth, I'm a fan of random-effects models and use them often. But my field is epidemiology, where the normality assumptions are often quite reasonable, and where this approach is widely accepted.

                        Comment


                        • #13
                          Thank you so much! I run the hausman test as suggested and in the end it comes to reject the random effects model in favor of fixed effects.

                          Code:
                          . hausman fixed ., sigmamore
                          
                                           ---- Coefficients ----
                                       |      (b)          (B)            (b-B)     sqrt(diag(V_b-V_B))
                                       |     fixed          .          Difference          S.E.
                          -------------+----------------------------------------------------------------
                              1.CR_POM |    .0323086     .0370316        -.004723        .0189048
                                CR_POM#|
                          Tech_Indus~y |
                                  1 1  |    .0400639     .0112959         .028768         .038931
                                  Size |    -.286774    -.2048736       -.0819004        .0606046
                          Profitabil~y |    2.655769     2.138582        .5171878        .2096264
                          ------------------------------------------------------------------------------
                                                     b = consistent under Ho and Ha; obtained from xtreg
                                      B = inconsistent under Ha, efficient under Ho; obtained from xtreg
                          
                              Test:  Ho:  difference in coefficients not systematic
                          
                                            chi2(4) = (b-B)'[(V_b-V_B)^(-1)](b-B)
                                                    =       11.71
                                          Prob>chi2 =      0.0196
                          Is still feasible to use random effects model? Is there anything else I could do to still be able to test this regression and be able to use -margins-? would theoretically lincom work?
                          Last edited by Elizabete Lurie; 29 May 2015, 01:18.

                          Comment


                          • #14
                            Elizabete:
                            in general, there's no point to reject Hausman result, unless you have sound theoretical reasons to go oppositely.
                            In your case, -hausman- tells you that -xtreg, re- would be worse specified than -xtgreg,fe-; hene, the latter is the way to go,
                            Another thing you could do is performing an augmented regression to test the robustness of the -hausman- test result when you cluster on panelid the standard errors of your coefficients.
                            If you were interestd in that procedure, you may find some interesting suggestion at: http://www.stata.com/statalist/archi.../msg00053.html
                            Kind regards,
                            Carlo
                            (Stata 19.0)

                            Comment


                            • #15
                              Under the circumstances, I think you either have to forego estimating the marginal effects of CR_POM, or estimate it in a between effects (-xtreg, be-) model. Just bear in mind, if you do this, that it is a different effect from the kind that the fixed-effects model would estimate if it could, in that it is averaged over time.

                              Comment

                              Working...
                              X