Announcement

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

  • Panel Regression xtreg with FE and time-FE

    Hey guys,

    I want to include FE and time-FE in my panel regressions. I know I can do that by using

    xtreg y x1 x2 ... xn i.time, fe

    My Problem now is, that my time is "weekly" and I have over 250 weeks, thus for each week a coefficient. Is there anyway to summarize all of these results in one coefficient like the constant for the normal fixed effects? I know I can run the areg regression with the absorb(time) option, but then I have no FE for the institutions.
    I hope you understand my problem and I am looking forward for your help!

    Thanks
    Dave



  • #2
    I know I can do that by using

    xtreg y x1 x2 ... xn i.time, fe
    If your panel is well specified (xtset id time command), you shouldn't have to add the i.time variable into your xtreg with the fixed effect option (,fe). Actually Stata should ignore it because collinear with time fixed effects, and shouldn't report any time coefficient (Stata's FE rely on mean-differences, and not dummies). So this should get rid of your 250 coefficient issues.

    What are the dimensions in your panel? Is there already a time dimmension in it?

    Comment


    • #3
      Hi Charlie,

      yes I set the data as panel data with "xtset institution time".
      But as I read it, the "normal", fe command does not capture the time fixed effects. But I specified the requirements theoretically that I need both. On the one side, I want to control for differences between institutions with FE and on the other side I want to control for general trends in the panel with time fixed effects.
      Thus I want to include both in my xtreg. But for the purpose of interpretation I do not want to have over 250 results for time fixed effects (for each week one coefficient). Therefore I asked myself whether I can do a two-way fixed effect model with FE and time-fixed effects. I hope you know now what I meant

      Comment


      • #4
        David:
        -fe- specification gets rid of time-invariant variables.
        Is this feature of -fe- machinery that you label as "normal"?
        As an aside, have you got sound methodological reasons fpr side-tracking -re- specification on a priori basis?
        Did you perform -hausman- specification test?
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          Hey Carlo,

          yes I did the Hausman-Test and it is in favor of the Fixed Effects specification. And yes -fe- gets rid of time-invariant variables. But in addition I want to add time fixed effects.
          E.g. I have this regression:

          y = _cons + beta*x + error term

          Here, when I just do xtreg y x, fe the _cons captures the fixed effects. But now I want to include time fixed effects, too. The problem is that I only know the above mentioned possibility with -i.time-. Here I would have several coefficients for each week but not a SINGLE ONE like the _cons in the -fe- model in this post.

          In short again:
          Is there a possibility that I get FE and time FE that look like:
          y = _cons_FE + _cons_time-FE + beta*x + error term ?

          Comment


          • #6
            David:
            you may want to try:
            Code:
            reg y x1 x2 ... xn i.time i.industry, vce(cluster industry)
            If you were interested in investigating interaction issues between years and industry, you may want to tweak the previous code as follows:
            Code:
            reg y x1 x2 ... xn i.time#i.industry, vce(cluster industry)
            Kind regards,
            Carlo
            (Stata 19.0)

            Comment


            • #7
              David, I guess I understand what you meant.
              You claim that the _constant term in the xtreg model captures the individual fixed effect, and you want to add another coefficient (andonly one) that would capture the time fixed effect.

              However, I am afraid this can't be done, or a least not as you think of it.

              The constant term does capture the average individual fixed effect, but only when the time dimension is absent from the panel. (xtset panelvar only , or xtreg , i(panelvar) ) as reported in the examples in this Stata FAQ page about intercept term in xtreg,fe

              But when the panel is bi-dimensional (xtset id time), the intercept in the xtreg command is no longer only the average individual fixed effect, but a term that embodies both fixed effets (time average of individual average), and I don't know a way to disentangle them. For further details see the following ppt (esepcially page 8, where it explains the intercept term in xtreg,fe .) http://www.google.fr/url?sa=t&rct=j&...,d.d24&cad=rja

              I hope this is clearer now.
              Charlie

              Comment


              • #8
                Hey Carlo,

                thanks for you answer, but that is not what I want. I attached a screenshot of my actual state output. This is exactly what I want. FE and time fixed effects with robust standard errors. BUT all the time coefficients should be summarized in ONE coefficient, compared to the _cons in the results which captures the time-invariant fixed effects. In my example I want 7 coefficients.
                1) w
                2) lvg
                3) size
                4) m_b
                5) asset
                6) _cons
                7) the ONE coefficient for the time fixed effects, not like in the JPG for each week a coefficient.
                Is this possible or just not possible in STATA?

                Still, thanks a lot. Maybe we will get it

                Comment


                • #9
                  Charlie you got it! But your answer makes me sad
                  Nevertheless, if I want to include both types of FE, would it be ok just to say that they are included but report only the coefficients of the "normal" variables? This is more a question about "scientific best practice"

                  Originally posted by Charlie Joyez View Post
                  David, I guess I understand what you meant.
                  You claim that the _constant term in the xtreg model captures the individual fixed effect, and you want to add another coefficient (andonly one) that would capture the time fixed effect.

                  However, I am afraid this can't be done, or a least not as you think of it.

                  The constant term does capture the average individual fixed effect, but only when the time dimension is absent from the panel. (xtset panelvar only , or xtreg , i(panelvar) ) as reported in the examples in this Stata FAQ page about http://www.stata.com/support/faqs/statistics/intercept-in-fixed-effects-model/"]intercept term in xtreg,fe [/URL]

                  But when the panel is bi-dimensional (xtset id time), the intercept in the xtreg command is no longer only the average individual fixed effect, but a term that embodies both fixed effets (time average of individual average), and I don't know a way to disentangle them. For further details see the following ppt (esepcially page 8, where it explains the intercept term in xtreg,fe .) http://www.google.fr/url?sa=t&rct=j&...,d.d24&cad=rja

                  I hope this is clearer now.
                  Charlie

                  Comment


                  • #10
                    David,

                    If you want to include time-FEs, this is what you get, 249 dummy coefficients, which you cannot reduce to just one coefficient. You can export your results to, say a spreadsheet table using outreg or a similar command and omit those 249 coefficients. You can run an F-test for joint significance and report the result.
                    Instead of time FEs, you could of course include a trend, which would give you one coefficient. However, that would mean imposing a functional form, in the simplest case a linear one. Thus, if you just want to control for the time effects, I would go for keeping the time FEs in and omitting them when exporting your results.
                    If this is ok probably depends on your field. In economics this is the usual way it's done, reporting your coefficients of interest and adding lines to your table specifying yes or no for the various kinds of FEs that you include - if those are not of interest on their own I should add.
                    Last edited by Martin Bresslein; 13 May 2015, 05:10.

                    Comment


                    • #11
                      An alternative would be to use -reghdfe- from SSC (or github). It behaves like xtreg , but allows more than one within- transformation and doesn't report the time coefs in the table.

                      Code:
                      reghdfe d_covar_5 w lvg size m_b asset, absorb(institution time) vce(cluster institution)
                      Best,
                      Sergio

                      Comment


                      • #12
                        I'm not an expert on estout, but isn't it possible to quietly do the command and then use the "keep" option to keep only the coefficients on x1 ... xn? Unfortunately, I don't have total command of the syntax of estout so I can't provide the exact command. JW

                        Comment


                        • #13
                          Another alternative would be to manually time-demean all variables and subsequently use areg with the absorb(time) option, e.g.:
                          Code:
                          global vars "y x1 x2 .. xn"
                          foreach var of varlist $vars {
                              by id: egen `var'_m = mean(`var')
                              gen `var'_dm = `var' - `var'_m
                          }
                          areg *_dm, absorb(time)
                          https://www.kripfganz.de/stata/

                          Comment


                          • #14
                            I wouldn't advise that, as the results are not at all the same as including the two sets of fixed effects. In fact, the code is equivalent to just the first iteration of reghdfe. Besides, you would then have to adjust standard errors by hand which is error-prone.

                            Best,
                            Sergio

                            Originally posted by Sebastian Kripfganz View Post
                            Another alternative would be to manually time-demean all variables and subsequently use areg with the absorb(time) option, e.g.:
                            Code:
                            global vars "y x1 x2 .. xn"
                            foreach var of varlist $vars {
                            by id: egen `var'_m = mean(`var')
                            gen `var'_dm = `var' - `var'_m
                            }
                            areg *_dm, absorb(time)

                            Comment


                            • #15
                              Sergio: Fair point. I admit that I was not thinking it to the end. My suggestion indeed produces incorrect standard errors. But the coefficient estimates should still be the same?!
                              https://www.kripfganz.de/stata/

                              Comment

                              Working...
                              X