Announcement

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

  • Running Fixed effects at different level to id

    Hi there,

    I have a panel which id=company and time=monthly (1 to 120) for 10 years. I have controlled for time by including year dummies by manually adding them into the regression.

    However, I want to do fixed effects but at a country level, not company. Each company has a dummy for the country they are in - could you let me know how to do this?

    I would manually input the country dummies, but stata won't let me run the Hausman fe vs re unless I officially do the command with ", fe". So is there a command for changing what level you run fixed effects for (when the level is not the default id - company in this case), and therefore I can do the test.

  • #2
    But if you use company as your panel variable in -xtset-, then your model will treat observations within firms as independent--which they almost certainly are not.
    Do remember, though, assuming that each firm stays in the same country during the time it is included in your data, the use of firm level country effects will automatically adjust for any country-level time-invariant effects without your having do do anything special to make that happen. What it won't do is let you estimate those country-level effects (because they will be colinear with the firm-fixed effects). It sounds like you have a multi-level model:monthly observations nested in firms nested in countries. So if estimating country-level effects are important to your goals, you need a multi-level model, or perhaps you would estimate the country level effects separately using -xtset country-, -xtreg, be-.

    Comment


    • #3
      Hi Clyde, thanks for your reply.

      What do you mean by multi-level model? I am following the regression specification seen in literature such as the one attached, where similarly country fixed effects are used when the id is company.

      Also as there are over 9000 companies in my sample, company fixed effects would be too tough on the regression/estimation I think. The aim behind my research is looking at country variation, which also explains why I want to use country level fixed effects. (The research is on the effect of religiosity of a country (which is time varying) on the return on "sin" stocks (tobacco, alcohol etc companies)
      Attached Files

      Comment


      • #4
        Each company belongs to 1 of 8 countries, where each country has a level of religiosity which is changing over time

        Comment


        • #5
          Also as there are over 9000 companies in my sample, company fixed effects would be too tough on the regression/estimation I think.
          I don't think 9,000 companies is particularly challenging for Stata's fixed effects estimation if you are using flavor MP or SE. Maybe even IC would handle it. If it did cause problems, you could switch to -reghdfe-, available from SSC.

          The research is on the effect of religiosity of a country (which is time varying) on the return on "sin" stocks (tobacco, alcohol etc companies
          Sounds interesting! In any case, you don't need to introduce country-level effects in order to include a religiosity variable that changes over time here.

          What do you mean by multi-level model?
          The -me- commands (and mixed) implement multi-level models. But if the focus is on religiosity and not country per se, you may be just fine with a firm-level fixed effects regression that includes the religiosity variable.




          Comment


          • #6
            But the focus is the religiosity of the country which I am trying to disentangle by --> controlling for country fixed effects, lots of other things like culture or just time-invariant cross country variation, I'm hoping that the effect of religiosity will be left to some extent. I think this would be better, than controlling for each firm

            Also what I meant is, I think stata can handle it in terms of processing, but running the regression for company fe makes the coefficients very insignificant and produces very different, odd, coefficients of interest when doing fe and random eff. Coeffcients are very different between fe and re when doing company level fe.

            Is there any way other than, storing results after running both regressions (one regression with manually adding country dummies, and the other without them) and calculating the Hausman statistics manually, to get around this??

            Comment


            • #7
              Clyde's point apply, but if you want to run that spec you can run it with reghdfe without problems. Just use it as areg, and put your time and country bars in absorb. The program is on SSC and there is a guide on my website (on mobile, can't link it easily)

              Best,
              S

              Comment


              • #8
                But the focus is the religiosity of the country which I am trying to disentangle by --> controlling for country fixed effects, lots of other things like culture or just time-invariant cross country variation,
                But if you use firm as your fixed effect, adjustment for any time-invariant country-level effects are automatically built in--they come along "for free."

                Coeffcients are very different between fe and re when doing company level fe.
                If it's that blatant, you don't need a Hausman test. A Hausman test, legendary and revered as it may be, is, in the end, nothing but a test of the equality of the coefficients betwen the -fe- and -re- models.

                More important, when there is a blatant, obvious difference between -fe- and -re- results, that tells you about something else that is very important. The fixed-effects estimator is a within-panel estimator. It estimates the effects of the predictor variables as they vary within panels. Differences in predictor effects between panels are not registered at all in fixed-effects estimates. By contrast, the -re- estimator provides a mixture of within-panel and between-panel effects. (In fact, that is exactly how -xtreg, re- is implemented in Stata.) For a simplistic illustration of how within- and between-panel effects can be very different, try this:

                Code:
                clear
                set obs 5
                gen panel_id = _n
                expand 2
                
                set seed 1234
                by panel_id , sort: gen y = 4*panel_id - _n + 3 + rnormal(0, 0.5)
                by panel_id: gen x = panel_id + _n
                
                xtset panel_id 
                
                xtreg y x, fe
                regress y x
                
                //    GRAPH THE DATA TO SHOW WHAT'S HAPPENING
                separate y, by(panel_id)
                
                graph twoway connect y? x || lfit y x
                You may have something like this going on in your data, where some of your x's work one way within a panel over time yet have very different, maybe even opposite effects on the outcome variable. If this is the case, a full understanding of the phenomenon under study requires looking at both aspects of that. There are ways of doing this, such as running a random effects model in which each x variable is replaced by two variables: one is the panel mean of x, and the other is the observation-level deviation between x and the panel mean of x. I don't want to go too far down this road, but this is something I think you should be pondering.

                I have looked briefly at the article you attached. I do not find their methods section clearly written. But to the extent that I follow it, it appears to me that they are using a random effects model with the random effect defined at the firm level. They have also incorporated additional indicator variables for country and industry, thus simulating fixed effects at those levels. By using random effects for the firm, they avoid having the industry and country indicators omitted for colinearity. While I would probably prefer to handle this with a multi-level model, I do think this is a reasonable alternative, and given the skepticism that typically greets multi-level models in finance, probably the way you should go. You are, however, going to need to use random effects at the firm level--otherwise the whole thing implodes. And you will have to do that without Hausman's blessing, because as noted earlier, when there are blatant differences between -fe- and -re- results, Hausman will definitely rule for the fixed-effects consistent model.

                Comment


                • #9
                  Thank you both for you replies and the useful info. Sergio,

                  Originally posted by Sergio Correia View Post
                  Clyde's point apply, but if you want to run that spec you can run it with reghdfe without problems. Just use it as areg, and put your time and country bars in absorb. The program is on SSC and there is a guide on my website (on mobile, can't link it easily)

                  Best,
                  S
                  1) When you mean use it as areg, you mean used "reghdfe" instead? What do you mean "time bars" and why would I need to put time in the fe part anyway?

                  2) This is how the commands are looking, do they look ok?

                  quietly reghdfe netreturn sin religiositymean sinreligiositymean l.beta l.return l.lmarketcap l.lpb bev lgdp l.spread l.inflationrate open law year1 year2 year3 year4 year5 year6 year7 year8 year9 year10, absorb(i.country_c)
                  estimates store fixed
                  quietly xtreg netreturn sin religiositymean sinreligiositymean l.beta l.return l.lmarketcap l.lpb bev lgdp l.spread l.inflationrate open law year1 year2 year3 year4 year5 year6 year7 year8 year9 year10, re
                  estimates store random
                  hausman fixed random

                  3) Also, lastly running both below causes the same coeffecients (as expected as they are same equation" BUT

                  "reghdfe netreturn sin religiositymean sinreligiositymean l.beta l.return l.lmarketcap l.lpb bev lgdp l.spread l.inflationrate open law year1 year2 year3 year4 year5 year6 year7 year8 year9 year10, absorb(i.country_c)" omits the var "law" due to collinearity

                  Whereas:

                  xtreg netreturn sin religiositymean sinreligiositymean l.beta l.return l.lmarketcap l.lpb bev lgdp l.spread l.inflationrate open law year1 year2 year3 year4 year5 year6 year7 year8 year9 year10 m1 m2 m3, re does not? Do you have any idea why this is happening?
                  Last edited by Krissy Philips; 09 Feb 2017, 03:12.

                  Comment


                  • #10
                    Originally posted by Clyde Schechter View Post
                    But if you use firm as your fixed effect, adjustment for any time-invariant country-level effects are automatically built in--they come along "for free."


                    I have looked briefly at the article you attached. I do not find their methods section clearly written. But to the extent that I follow it, it appears to me that they are using a random effects model with the random effect defined at the firm level. They have also incorporated additional indicator variables for country and industry, thus simulating fixed effects at those levels. By using random effects for the firm, they avoid having the industry and country indicators omitted for colinearity. While I would probably prefer to handle this with a multi-level model, I do think this is a reasonable alternative, and given the skepticism that typically greets multi-level models in finance, probably the way you should go. You are, however, going to need to use random effects at the firm level--otherwise the whole thing implodes. And you will have to do that without Hausman's blessing, because as noted earlier, when there are blatant differences between -fe- and -re- results, Hausman will definitely rule for the fixed-effects consistent model.
                    Clyde:

                    I see your point regarding the firm fixed effects, however am reluctant to given the results and especially as country level effects is what the focus is on here. Also the fact that I would prefer to based method off what has been done before and published. Therefore referring to the paper, Pg 154, second paragraph they state in method "in order to control for unobserved country characteristics in our analysis, we include country fixed effects as dummy variables for each country in our sample" - this is not random effects?

                    Comment


                    • #11
                      [QUOTE=Krissy Ragan;n1373544]1) When you mean use it as areg, you mean used "reghdfe" instead? What do you mean "time bars" and why would I need to put time in the fe part anyway?
                      /QUOTE]

                      You would do reghdfe y x1 x2 ... , absorb(year country) where year and country are categorical variables for year and country. Also, reghdfe doens't allowfor random effects on top (in which case the mixed commands would be a good alternative)

                      About your last question, your xtreg spec. didn't include country dummies, which is why there were no collinear variables.

                      Comment


                      • #12
                        [QUOTE=Sergio Correia;n1373581]
                        Originally posted by Krissy Ragan View Post
                        1) When you mean use it as areg, you mean used "reghdfe" instead? What do you mean "time bars" and why would I need to put time in the fe part anyway?
                        /QUOTE]

                        You would do reghdfe y x1 x2 ... , absorb(year country) where year and country are categorical variables for year and country. Also, reghdfe doens't allowfor random effects on top (in which case the mixed commands would be a good alternative)

                        About your last question, your xtreg spec. didn't include country dummies, which is why there were no collinear variables.
                        Thanks Sergio, 1) so you are saying instead of putting in year1, year2 etc etc dummies like I have I can just put i.year in the bracket as well?

                        2)Sorry I should have said as well, m1-m4 are country dummies- hence my confusion with the lack of collinearity in xtreg spec but coll using reghdfe - any thoughts?

                        Comment


                        • #13
                          Yes, you can put it. Also, I don't see m4 in xtreg, maybe that's why?

                          Comment


                          • #14
                            Originally posted by Sergio Correia View Post
                            Yes, you can put it. Also, I don't see m4 in xtreg, maybe that's why?
                            m4 is just a country dummy (its the default so is ommitted if I was to include it anyway due to collinearity). Its just odd that practically the same equation is omitting "law" variable in one case and not in the other??

                            Comment


                            • #15
                              Responding to #10.

                              You can use random effects at the firm level and also include fixed effects at the country level (at least if you use -xtset firm- and -xtreg, re-). That's what I was suggesting in #8, and to the extent that I understand the paper you attached, that is also what they did there.

                              Now, they aren't all that clear in explaining their methods. I may be misinterpreting them, and it may be that they simply ignored firm-level effects. In that case, you have to choose between using a clearly incorrect methodology just because somebody else used it before, and doing something that is defensible in its own right. To justify ignoring firm level effect, you first do an analysis that shows that they are effectively zero anyway. It is possible that for this particular content they are, and it is possible that those authors found that as well in their study (though I didn't see that said in the paper in my quick read-down). It is worth looking into. But unless you first show that firm level effects are effectively zero, leaving them out of the model builds in a risk of missing-variable bias and also producing incorrect standard errors.

                              Comment

                              Working...
                              X