Announcement

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

  • Analysis panel data which includes country, industry and year fixed effects.

    Hi,

    I am a fresher of STATA, and expect to analysis the panel data by simple regression, which includes the country, industry and year fixed effects.

    by checking online, I think I can use "xtreg Y X1 X2 X2, fe" but it seems that it dose not include the country, industry and year fixed effects.

    Could you please tell me how to do it? or give me some suggestions about this/

    Thanks for your attention to this matter.

  • #2
    Alex:
    welcome to this forum.
    As per Jeff Wooldridge' s memento (that you can find in many of his most recent threads), please note that the only fixed effect that you impose is the one included in your -xtset- code.
    Assuming that you're interested in industry:
    Code:
    xtset industry year
    Then you can add all the categorical variables you need for -country- and -year-. (but they are not fixed effect. If that were the case, our regressions will be full of fixed effects floating around).
    Last but not least, you chose an -fe- estimator: as you're surely aware of, -the -fe- machinery wipes out time-invariant predictors.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      To add to Carlo's useful response, you might consider user-written reghdfe.

      Comment


      • #4
        Hi Carlo :
        Many thanks for your advice.

        But I still confuse about it. the following is part of my data,
        Company_ID year Y X1 X2 X3 X4 X5 X6 Industry Country
        130057 1994 0 0.008482 0 0.001069 1.752031361 0.693147181 Medium MANUFACTURING US
        130057 1995 0 0.028821 0 0.015976 2.886118307 1.098612289 Medium MANUFACTURING US
        130057 1996 0.693147181 0.031338 0 0.0079 2.002018961 1.386294361 Medium MANUFACTURING US
        130057 1997 0 0.090801 0 0.00618 2.731637747 1.609437912 Medium MANUFACTURING US
        130057 1998 0 0.140647 0 0 0.983591186 1.791759469 Small MANUFACTURING US
        130057 1999 0 1.172691 0.803213 0 9.305220884 1.945910149 Small MANUFACTURING US
        130057 2000 0 0.037084 0 0.003455 0.231832316 2.079441542 Small MANUFACTURING US
        130057 2001 0 0.029063 0 0.002095 0.104206668 2.197224577 Small MANUFACTURING US
        130057 2002 0 0.043314 0 0 0.247358121 2.302585093 Small MANUFACTURING US
        130057 2003 0 0.071889 0 0.002701 0.577602327 2.397895273 Small MANUFACTURING US
        130057 2004 0 0.016134 0 0.000234 0.094743734 2.48490665 Small MANUFACTURING US
        130057 2005 0 0.038466 0 0.03692 0.313566113 2.564949357 Medium MANUFACTURING US
        130057 2006 0 0.045024 0 0.015556 2.63905733 Medium MANUFACTURING US
        130057 2007 0 0.0988 0 0.006043 2.708050201 Medium MANUFACTURING US
        130057 2008 0 0.025239 0 0.000255 2.772588722 Medium MANUFACTURING US
        130057 2009 0 0.018938 0 8.11E-05 2.833213344 Small MANUFACTURING US
        130057 2010 0 0 2.890371758 MANUFACTURING US
        130062 1994 0 1.309941 0.185963 0.079193 0.001003551 0.693147181 Large MINING US
        130062 1995 0 1.16531 0.293465 0.090752 0.001100877 1.098612289 Large MINING US
        130062 1996 1.386294361 1.276097 0.170919 0.103396 0.000957189 1.386294361 Large MINING US
        130062 1997 0.693147181 1.123869 0.282267 0.078176 0.000598709 1.609437912 Large MINING US
        130062 1998 1.098612289 0.945815 0.38888 0.07801 0.000560875 1.791759469 Large MINING US
        130062 1999 0 0.948716 0.368267 0.07909 0.000351205 1.945910149 Large MINING US
        130062 2000 0.693147181 0.984882 0.353806 0.092756 0.000200387 2.079441542 Large MINING US
        130062 2001 0 0.932501 0.360461 0.087381 0.000249935 2.197224577 Large MINING US
        130062 2002 0 0.950388 0.329933 0.067601 0.001029873 2.302585093 Large MINING US
        130062 2003 0.693147181 0.946514 0.313037 0.051774 0.001196948 2.397895273 Large MINING US
        130062 2004 1.791759469 0.98034 0.307387 0.069378 0.001295922 2.48490665 Large MINING US
        130062 2005 1.609437912 1.028134 0.295059 0.090987 0.001399736 2.564949357 Large MINING US
        130062 2006 1.098612289 1.092924 0.285045 0.106118 0.000756856 2.63905733 Large MINING US
        130062 2007 1.098612289 1.109753 0.421522 0.098712 0.000693418 2.708050201 Large MINING US
        130062 2008 0.693147181 1.095104 0.448489 0.085159 0.000650948 2.772588722 Large MINING US
        130062 2009 0 1.069983 0.386304 0.042982 0.000700464 2.833213344 Large MINING US
        130062 2010 0 1.160512 0.335925 0.044204 2.890371758 Large MINING US
        130088 1994 0 0.362183 0.09485 0.046347 0 0.693147181 Large RETAIL TRADE US
        130088 1995 0 0.352445 0.158885 0.058568 0 1.098612289 Large RETAIL TRADE US
        (each Company_ID represents a company, Y is the dependent variable, X1-X6 are the explanatory variables, specifically, X6 is a dummy variable.
        it covers 11 industries and 20 countries, not the just US)


        How could I control the industry and country fixed effects of this panel data and then analysis this by a linear regression?

        I have read some post or log of panel data and fixed effects, but all of them describe a part of the process, and it makes me even more confused. For example, a video said I should use "xtset Company_ID year" at the beginning, it strange.

        Could you please give me some suggestions about this specific question?

        Many thanks in advance.

        Comment


        • #5
          Alex:
          1) the -xt-commands suite requires that you -xtset- your data beforehand: this is not strange, as it allows Stata to learn that your data are panel;
          2) for what you have in mind, I think you could follow two approaches:
          Code:
          xtset Company_ID year
          xtreg  xtreg <depvar>  <other predictors> i.year i.industry <controls>, fe
          As expected, all time-invariant predictors will be wiped out by the -fe- machinery.

          The second approach, as per Phil's wise advice, implies the community-contributed command -reghdfe-:
          Code:
          reghdfe <depvar> <other predictors> <controls>, abs(Company_ID year industry)
          Kind regards,
          Carlo
          (Stata 19.0)

          Comment


          • #6
            Hi Carlo,

            Many thanks for your reply and kind help. May I ask one more questions please?

            1)In the Code:
            xtset Company_ID year xtreg xtreg <depvar> <other predictors> i.year i.industry <controls>, fe Why you write "i.year" rather than "i.country". it seems the "i.country" is meaning of country-fixed effect?

            so as I expect to use the industry and country-fixed effect, should I write the code like below,
            (apology that I write the year-fixed effect in the earliest post, I should not do that)


            Code:
            xtset Company_ID year
            xtreg xtreg <depvar> <other predictors> i.country i.industry <controls>, fe
            Many thanks in advance.

            Comment


            • #7
              Alex:
              I would recommend you to add -i.year- to your -xtreg,fe- code, as this predictor will inform you about how time contributes to explain within panel variations when adjusted for the other predictors.
              Again please note the the only fixed effect y
              that you will get with your code is the one related to compact (as per -xtset- coding).
              Kind regards,
              Carlo
              (Stata 19.0)

              Comment


              • #8
                Hi Carlo,

                Many thanks for your advice.

                I use the following code,

                Code:
                xtreg LN_APPLN PPETA LEV CAPEXTA RDTA Q SHORT_LIQ LONG_LIQ LN_TA LN_AGE LN_MV Employees_1 i.Country i.industry i.year , fe
                However, I get
                note: LONG_LIQ omitted because of collinearity
                note: 2.Country omitted because of collinearity
                note: 3.Country omitted because of collinearity
                note: 4.Country omitted because of collinearity
                note: 5.Country omitted because of collinearity
                note: 6.Country omitted because of collinearity
                note: 7.Country omitted because of collinearity
                note: 8.Country omitted because of collinearity
                note: 9.Country omitted because of collinearity
                note: 10.Country omitted because of collinearity
                note: 11.Country omitted because of collinearity
                note: 13.Country omitted because of collinearity
                note: 14.Country omitted because of collinearity
                note: 15.Country omitted because of collinearity
                note: 16.Country omitted because of collinearity
                note: 17.Country omitted because of collinearity
                note: 18.Country omitted because of collinearity
                note: 19.Country omitted because of collinearity
                note: 22.Country omitted because of collinearity
                note: 23.Country omitted because of collinearity
                note: 24.Country omitted because of collinearity
                note: 25.Country omitted because of collinearity
                note: 27.Country omitted because of collinearity
                note: 28.Country omitted because of collinearity
                note: 29.Country omitted because of collinearity
                note: 30.Country omitted because of collinearity
                note: 32.Country omitted because of collinearity
                note: 33.Country omitted because of collinearity
                note: 35.Country omitted because of collinearity
                note: 36.Country omitted because of collinearity
                note: 37.Country omitted because of collinearity
                note: 38.Country omitted because of collinearity
                note: 39.Country omitted because of collinearity
                note: 40.Country omitted because of collinearity
                note: 41.Country omitted because of collinearity
                note: 42.Country omitted because of collinearity
                note: 2.industry omitted because of collinearity
                note: 3.industry omitted because of collinearity
                note: 4.industry omitted because of collinearity
                note: 5.industry omitted because of collinearity
                note: 6.industry omitted because of collinearity
                note: 7.industry omitted because of collinearity
                note: 8.industry omitted because of collinearity
                note: 9.industry omitted because of collinearity
                note: 10.industry omitted because of collinearity

                Click image for larger version

Name:	Screenshot (10).png
Views:	1
Size:	49.8 KB
ID:	1549409

                Click image for larger version

Name:	Screenshot (11).png
Views:	1
Size:	26.6 KB
ID:	1549410

                Click image for larger version

Name:	Screenshot (13).png
Views:	1
Size:	41.9 KB
ID:	1549411


                Do you know how to fix it?
                Many thanks for your help.

                Comment


                • #9
                  Alex:
                  there's nothing to fix here: as expected, the -fe- estimator got ride of time-invariant predictors.
                  If you're intetested in estimating the coefficients of the omitted variable, you should switch to a differenti estimator: see -xtreg,re- or -xthybrid-.
                  Kind regards,
                  Carlo
                  (Stata 19.0)

                  Comment


                  • #10
                    Hi Carlo,

                    Many thanks for your advice. But I did not understand it. What should I do if I want to control the country, industry and year fixed effect?

                    Besides, is the code
                    Code:
                    xtset company_ID year,yearly
                    xtreg LN_APPLN PPETA LEV CAPEXTA RDTA Q SHORT_LIQ LONG_LIQ LN_TA LN_AGE LN_MV i.Country i.Industry i.year, fe
                    do the same thing as the Code:
                    Code:
                    reg LN_APPLN PPETA LEV CAPEXTA RDTA Q SHORT_LIQ LONG_LIQ LN_TA LN_AGE LN_MV i.Country i.Industry i.year
                    I can get a result without collinearity by the second code( reg ), however, I am not sure whether the second approach can control the country, industry and year fixed effect.

                    Many thanks for your help, and sorry for my poor understanding ability

                    Comment


                    • #11
                      Alex:
                      if you want to obtain fixed effects for country, industry and year, you should switch to the community-contributed command -reghdfe-.
                      Please note that investigating the fixed effect (ie, the heterogeneity) in a panel data set is not the same thing as controlling for other predictors.
                      With your -regress- code you could obtain (for some regressors)the same results as per -xtreg,fe- if you include -i.company_ID- among the predictors.
                      I think you should consult any decent textbook on panel data econometrics in order to get yourself familiar with the building blocks of this theoretically demanding research field.
                      Kind regards,
                      Carlo
                      (Stata 19.0)

                      Comment


                      • #12
                        Hi everyone,
                        I found the above discussion very helpful for my analysis, and am working towards similar issue. I am currently using Stata 16.1. I am also running a Panel data analysis for a sample period of 2011-2018 for American firms. In my research, if I want to control for election years as my dependent variables may be influenced by political factors. So, could someone advise me on what would be a good way to go about this? So far I am thinking of creating a dummy variable to represent the election years, but I am not sure.

                        Best,
                        Shiwani

                        Comment


                        • #13
                          Shiwany:
                          -i.election_year- is the way to go.
                          Kind regards,
                          Carlo
                          (Stata 19.0)

                          Comment


                          • #14
                            Hi Carlo,

                            Thank you so much for helping me! Just to be a little more clear. I will also be controlling for industry and year. So, I will first need to construct a variable called "election_year", and then run the following:

                            regress D_var Indep_var control_var i.election_year i.year i.industry

                            is that the way?

                            Best,
                            Shiwani

                            Comment


                            • #15
                              Shiwany:
                              if you want to estimate so many fixed effects, I would recommend you to switch to the community-contributed command -reghdfe-.
                              Kind regards,
                              Carlo
                              (Stata 19.0)

                              Comment

                              Working...
                              X