Announcement

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

  • country and year fixed effects used along side other dummy variables.

    Dear all:
    I am trying to run an xtreg, fe regression in which I specify i.country and i.year. Besides, I have four dummy variables to capture whether or not the effects of some event varied before the financial crisis, during the financial crisis, during the euro crisis, and after the euro crisis. The four dummy variables are:
    precrises = 1 if year < 2008 and 0 otherwise
    finacrisis = 1 if year > 2007 & < 2010 and 0 otherwise
    eurocrisis = 1 if year > 2009 & < 2013 and 0 otherwise
    postcrises = 1 if year > 2012 and 0 otherwise

    Additionally, I have a dummy eurozone which takes the value of 1 if a country uses the Euro and 0 otherwise.

    Here's a snippet of my data
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input long codes str4 isocode double year float(effect TO) double(debt_to_gdp labour_cost) float(ctfp migr precrises finacrisis eurocrisis postcrises eurozone ID)
     3 "BGR" 2007  3.2065556 1.1702172               .163         .787812407  .8370961 -.062666036 1 0 0 0 0 1
     3 "BGR" 2008   6.377153 1.1450799                .13         .820934493  .7882922  -.07541114 0 1 0 0 0 1
     3 "BGR" 2009     6.7576  .9814345 .13699999999999998         .868061915  .7585077  -.09362397 0 1 0 0 0 1
     3 "BGR" 2010   2.838052  1.021302               .153         .896313782  .7228292  -.11698304 0 0 1 0 0 1
     3 "BGR" 2011   .4808148 1.1100246               .152         .863827292  .7211491  -.15262954 0 0 1 0 0 1
     3 "BGR" 2012 -1.5709802 1.1480831               .166         .890741951  .7123723   -.1877556 0 0 1 0 0 1
     3 "BGR" 2013  -4.068332  1.223813                .17  .9697065739999999  .6842833  -.20909213 0 0 0 1 0 1
     3 "BGR" 2014 -4.0509253 1.2507068                .27        1.004373088  .6817679   -.2142942 0 0 0 1 0 1
     3 "BGR" 2015  -.3892253 1.2702523               .259                  1  .7010686  -.21328545 0 0 0 1 0 1
     3 "BGR" 2016   2.930019 1.3082312 .29100000000000004         .998707117  .7335442  -.20899187 0 0 0 1 0 1
     3 "BGR" 2017   5.323411 1.3473432               .251         1.04297689  .7210643   -.1909202 0 0 0 1 0 1
     3 "BGR" 2018   7.543334 1.3550078               .221         1.06758656  .7245558   -.1718048 0 0 0 1 0 1
     3 "BGR" 2019   10.26668 1.3393754                 .2        1.046065297  .7298936   -.1634115 0 0 0 1 0 1
    14 "HRV" 2013  -6.278373  .8189332               .801        1.030091738 .57368857  -.27669188 0 0 0 1 0 2
    14 "HRV" 2014  -7.157742  .8629592  .8380000000000001        1.006253194 .55969673   -.3019378 0 0 0 1 0 2
    14 "HRV" 2015   -7.83611  .9253985  .8320000000000001                  1  .5811352   -.3167588 0 0 0 1 0 2
    14 "HRV" 2016  -8.498741  .9548587               .797  .9719168890000001 .59332204   -.3224111 0 0 0 1 0 2
    14 "HRV" 2017  -8.626427  .9961237               .765         .954118083  .6224349   -.3264276 0 0 0 1 0 2
    14 "HRV" 2018   -9.10683 1.0240718               .732         .969073726  .5925546   -.3168844 0 0 0 1 0 2
    14 "HRV" 2019  -8.138688 1.0414894                .71  .9506983630000001   .591148   -.3021569 0 0 0 1 0 2
     4 "CYP" 2004   .5406208 1.1253651               .648        1.060799709  .7818322   1.8030715 1 0 0 0 0 3
     4 "CYP" 2005  1.3135726 1.0949893               .634        1.095913465  .8277659     1.79232 1 0 0 0 0 3
     4 "CYP" 2006  1.6042433 1.0877829               .593        1.077859941  .8122461   1.6863636 1 0 0 0 0 3
     4 "CYP" 2007  1.9996914 1.1131341                .54        1.047699148   .825168   1.6831677 1 0 0 0 1 3
     4 "CYP" 2008  1.9538878 1.1441915               .455        1.031512464  .8240209   1.5876547 0 1 0 0 1 3
     4 "CYP" 2009 -1.1361805 1.0441003  .5429999999999999 1.1086572909999999  .8458163    1.506494 0 1 0 0 1 3
     4 "CYP" 2010  -4.542301 1.1114072               .563        1.082770706  .7800184   1.5017252 0 0 1 0 1 3
     4 "CYP" 2011  -8.782444 1.1271577  .6579999999999999        1.088140026  .7552454    .7208999 0 0 1 0 1 3
     4 "CYP" 2012  -14.18608 1.1425554               .801        1.087502061  .7620074    .5543177 0 0 1 0 1 3
     4 "CYP" 2013 -20.863415 1.2015067              1.037 1.0508898580000001   .705969    .5134988 0 0 0 1 1 3
     4 "CYP" 2014  -22.91376   1.30874              1.088        1.024137293  .6777698    .5239858 0 0 0 1 1 3
     4 "CYP" 2015   -20.5332 1.3802793              1.075                  1  .6765807   .54913294 0 0 0 1 1 3
     4 "CYP" 2016 -16.539932 1.3974997              1.032         .978621433  .7156157   .57280415 0 0 0 1 1 3
     4 "CYP" 2017 -15.223533  1.482693               .932         .980375137   .689432    .5865686 0 0 0 1 1 3
     4 "CYP" 2018 -14.166972  1.474323  .9860000000000001         .981964978  .6658052   .57754636 0 0 0 1 1 3
     4 "CYP" 2019 -12.910274 1.4531323  .9080000000000001  .9952256490000001  .6820247   .56972116 0 0 0 1 1 3
     5 "CZE" 2004   2.555202 1.0058016               .284        1.002198224  .5409089   .25340256 1 0 0 0 0 4
     5 "CZE" 2005   6.329136 1.0877221 .27699999999999997  .9946163020000001 .55721474   .24268468 1 0 0 0 0 4
     5 "CZE" 2006   9.968386 1.1502326               .276  .9937092839999999  .5562391   .25082016 1 0 0 0 0 4
     5 "CZE" 2007    11.7596  1.219547               .273         .985211115  .5840508   .26320928 1 0 0 0 0 4
     5 "CZE" 2008  13.299603 1.2316363               .281        1.003137624  .5771262   .28594953 0 1 0 0 0 4
     5 "CZE" 2009   9.690375 1.1569488 .33399999999999996        1.000605369  .5695849     .298594 0 1 0 0 0 4
     5 "CZE" 2010   7.258712 1.2958703               .371 1.0186066599999999  .5628898    .3303273 0 0 1 0 0 4
     5 "CZE" 2011   7.175409 1.3750027               .397        1.026531063  .5481288    .1552924 0 0 1 0 0 4
     5 "CZE" 2012  4.4623446  1.434239               .442        1.043832313  .5395675    .0974172 0 0 1 0 0 4
     5 "CZE" 2013  2.2453854   1.43727  .4440000000000001        1.033084958 .53338635  -.01466958 0 0 0 1 0 4
     5 "CZE" 2014   2.896477  1.536672 .41900000000000015        1.017997196 .54683644   .04729439 0 0 0 1 0 4
     5 "CZE" 2015   6.185791 1.5517566               .397                  1  .5724231   .04996511 0 0 0 1 0 4
     5 "CZE" 2016      6.756  1.568069               .366        1.018504372 .56919694 -.002825163 0 0 0 1 0 4
     5 "CZE" 2017   9.054478 1.5915858               .342        1.040275793 .59376955   .02639781 0 0 0 1 0 4
     5 "CZE" 2018  10.224904 1.6149105               .321        1.076380216  .5988429   .02993715 0 0 0 1 0 4
     5 "CZE" 2019  10.940145 1.5991404                 .3          1.0806402  .6011232   .03770157 0 0 0 1 0 4
     9 "EST" 2004   8.611467  .9983022 .05100000000000002         .925463184 .55015457  -.27633446 1 0 0 0 0 5
     9 "EST" 2005  14.671326 1.0784042               .047          .90224925 .58835495  -.38667855 1 0 0 0 0 5
     9 "EST" 2006   20.19566 1.1319072 .04600000000000001         .907715457  .5888916   -.4004112 1 0 0 0 0 5
     9 "EST" 2007  22.637203 1.1869963               .038         .945371423  .6250963  -.21289954 1 0 0 0 0 5
     9 "EST" 2008   12.63923 1.2151728               .045        1.026470178 .58749765  -.14723079 0 1 0 0 0 5
     9 "EST" 2009  -2.865555 1.0570027 .07200000000000001        1.043463342  .5706379  -.14512007 0 1 0 0 0 5
     9 "EST" 2010 -4.7264667 1.2640612               .067         .975884427  .5731603  -.28218582 0 0 1 0 0 5
     9 "EST" 2011 -.38099685 1.4775677               .062         .938444386 .57056624   -.2959233 0 0 1 0 1 5
     9 "EST" 2012   1.859935  1.535139               .098         .940352832  .5883074  -.27555266 0 0 1 0 1 5
     9 "EST" 2013   .7386503  1.554545               .102         .953582708 .58677775  -.20090033 0 0 0 1 1 5
     9 "EST" 2014   2.125317 1.5522966               .106  .9656508770000001 .58766955  -.04269618 0 0 0 1 1 5
     9 "EST" 2015    1.64359  1.498416 .10099999999999999                  1  .5932571    .3275236 0 0 0 1 1 5
     9 "EST" 2016    1.83472 1.5339965                 .1        1.010621062  .6046804   .08841559 0 0 0 1 1 5
     9 "EST" 2017  4.2018504  1.505947               .091        1.014076541  .6081639    .4038988 0 0 0 1 1 5
     9 "EST" 2018   4.999264 1.5128145 .08200000000000002        1.028922497  .6245617   .54644275 0 0 0 1 1 5
     9 "EST" 2019   7.232257 1.5128586               .085        1.043727907  .6394333    .4081023 0 0 0 1 1 5
    15 "HUN" 2004   1.366708  .9991526               .588        1.129756307  .7149618   .16612816 1 0 0 0 0 6
    15 "HUN" 2005  2.2049468 1.0567349               .605        1.135132303  .7531477    .1647343 1 0 0 0 0 6
    15 "HUN" 2006  2.0571945 1.1929824               .644 1.1179526009999998  .7380345   .20810185 1 0 0 0 0 6
    15 "HUN" 2007 -1.9930004 1.3694156  .6560000000000001        1.116577535  .7223583   .14363314 1 0 0 0 0 6
    15 "HUN" 2008  -3.285424  1.441106               .718         1.11578654  .7214223   .16677564 0 1 0 0 0 6
    15 "HUN" 2009  -7.938236  1.349588                .78        1.087155015  .6974668    .1926012 0 1 0 0 0 6
    15 "HUN" 2010  -8.928149  1.475121                 .8         1.05431945  .6944516    .1147736 0 0 1 0 0 6
    15 "HUN" 2011  -9.568783 1.5248843  .8030000000000002        1.057360006   .683087  .008983718 0 0 1 0 0 6
    15 "HUN" 2012 -11.849007  1.506773               .782 1.0815351560000002  .6513686    .1626867 0 0 1 0 0 6
    15 "HUN" 2013 -11.656494  1.541155               .772        1.048836367  .6402487    .0538544 0 0 0 1 0 6
    15 "HUN" 2014  -8.516434 1.6270152               .765        1.022472698  .6318016   .11801133 0 0 0 1 0 6
    15 "HUN" 2015  -5.670116 1.6723995               .758                  1  .6346771   .14487739 0 0 0 1 0 6
    15 "HUN" 2016  -4.951573  1.696434  .7490000000000001        1.026013557  .6094128 -.010068723 0 0 0 1 0 6
    15 "HUN" 2017  -2.580377 1.7470754  .7210000000000001 1.0314188629999999  .6332566   .18545045 0 0 0 1 0 6
    15 "HUN" 2018   .7771235 1.7565033  .6910000000000001        1.016523214  .6294906    .3293948 0 0 0 1 0 6
    15 "HUN" 2019  4.6456137   1.79086               .653 1.0005964040000002   .637391    .3465164 0 0 0 1 0 6
    18 "LVA" 2004   8.844845  .8851951               .146         .864375123  .5716405   -.7960785 1 0 0 0 0 7
    18 "LVA" 2005   16.01324  .9576236 .11900000000000001         .894164351  .6359435   -.7824181 1 0 0 0 0 7
    18 "LVA" 2006  24.698624  .9887175                 .1         .919787401 .56041706   -.7692356 1 0 0 0 0 7
    18 "LVA" 2007   30.39144 1.0423049               .084         .975128962 .57938445   -.7547465 1 0 0 0 0 7
    18 "LVA" 2008   22.04903 1.0158883               .185         1.05302797 .52701724   -.7338139 0 1 0 0 0 7
    18 "LVA" 2009   8.108592  .9111724                .37 1.0374104339999999   .501552   -.7064577 0 1 0 0 0 7
    18 "LVA" 2010  1.3797905 1.0782217 .47600000000000003  .9505604460000001  .5066871    -.675882 0 0 1 0 0 7
    18 "LVA" 2011   6.050076  1.192746               .451  .9051971670000001  .4956009   -.6422877 0 0 1 0 0 7
    18 "LVA" 2012   10.85012  1.226992 .42400000000000015  .8892900380000001  .4989296   -.6273997 0 0 1 0 0 7
    18 "LVA" 2013  11.485902 1.2022864 .40299999999999997         .927438354  .5163392   -.6115043 0 0 0 1 0 7
    18 "LVA" 2014   13.35634 1.2433076 .41600000000000004         .953428304  .5154674   -.5852904 0 0 0 1 1 7
    18 "LVA" 2015  16.931362  1.222836                .37                  1  .5312566  -.55879986 0 0 0 1 1 7
    18 "LVA" 2016  17.448938   1.23938 .40299999999999997        1.035671386 .53840506   -.5237389 0 0 0 1 1 7
    18 "LVA" 2017  19.627346 1.2900997  .3890000000000001 1.0474708529999999  .5620888  -.48680305 0 0 0 1 1 7
    18 "LVA" 2018  21.350445 1.3071905                .37        1.063042407  .5680675   -.4476113 0 0 0 1 1 7
    18 "LVA" 2019   21.38245 1.3135196               .365         1.08798521 .59386635   -.4144764 0 0 0 1 1 7
    end
    label values codes codes
    label def codes 3 "BGR", modify
    label def codes 4 "CYP", modify
    label def codes 5 "CZE", modify
    label def codes 9 "EST", modify
    label def codes 14 "HRV", modify
    label def codes 15 "HUN", modify
    label def codes 18 "LVA", modify

    Here are my codes:

    Code:
    xtreg effect L1.effect precrises finacrisis eurocrisis postcrises eurozone debt_to_gdp TO labour_cost i.year i.codes, fe
    However, all the countries in i.codes are dropped "due to collinearity". Is there a better (or perhaps correct way) to incorporate the five dummies within the xtref, fe setting?
    Last edited by Joe Zonda; 14 Aug 2023, 02:10.

  • #2
    Dear Clyde Schechter, Carlo Lazzaro Nick Cox or indeed anyone available, could you kindly assist?
    ​​​​​

    Comment


    • #3
      Joe:
      Country fixed effect and -i.country- cannot live together in -xtreg-. Just drop -i.country- and re-run.
      Kind regards,
      Carlo
      (Stata 19.0)

      Comment


      • #4
        Thank you so much for your insight.
        A follow-up question: keeping the dummy variables as specified above is correct in the light of -i.year-?

        Comment


        • #5
          Joe:
          if your question is: should I keep -i.year- in the right-hand side of my -xtreg,fe- regression?, the answer is:yes, always.
          Kind regards,
          Carlo
          (Stata 19.0)

          Comment


          • #6
            I understand. Thank you so much.

            Comment


            • #7
              Dear Joe, Carlo is absolutely right. As a side note, how many time periods do you have? If you have less than approximately 20 or 30, rule of thumb, it is a problem to include a lag of your dependent variable as regressor. You may want to look into
              Code:
              ssc install xtdpdgmm

              Comment


              • #8
                Dear Maxence Morlet thank you so much for the insight. I will definetly take that into account.

                Comment


                • #9
                  Note that each of the variables precrises, finacrisis, eurocrisis and postcrises is going to be colinear with i.year. Consequently, when you run this, in addition to having one year indicator omitted as the reference category for year, additional years or some of these crisis variables will be omitted for colinearity. A total of four such omissions will be found, although I cannot say which ones Stata will choose to omit (and which ones get omitted makes no difference anyway). If you need to estimate the effects of these crisis periods, then you cannot also have i.year in your model. If you run the model with all of these variables, then you cannot correctly interpret any of the crisis variables as an effect of the crisis period, nor any of the year indicators as an effect of that year. None of these effects are identifiable in a model with all of these colinear variables.
                  Last edited by Clyde Schechter; 14 Aug 2023, 09:59.

                  Comment


                  • #10
                    Thank you so much Clyde Schechter. Indeed, I have four year omissions. In this case, would you recommend dropping -i.year or I have to drop some (or all dummies). Indeed, the primary goal for the exercise is to check if the treatment effects from my baseline estimation (effect) varry before, during, after the crises. Do you recommend dropping i.year?

                    Comment


                    • #11
                      Indeed, the primary goal for the exercise is to check if the treatment effects from my baseline estimation (effect) varry before, during, after the crises.
                      This puts things in a different light. Your proposed model would not answer this research question in any case. To do that, you need to have interaction terms between the treatment variables and the crisis variables. For that, you need to add the interaction terms to the model, remove the crisis variables, and leave i.time. So, something like this:
                      Code:
                      xtreg effect L1.effect i.eurozone c.debt_to_gdp c.TO c.labour_cost i.(precrises finacrisis eurocrisis postcrises)#(i.eurozone c.debt_to_gdp c.TO c.labour_cost) i.year, fe
                      Note: I don't know which variables here are the "treatment" variables. In the above code I have assumed that eurozone, debt_to_gdp, TO, and labour_cost are all treatment variables--though they may just be covariates, I don't know. For any of them that are just covariates, you may (optionally) remove them from the interaction part of the model.

                      Comment


                      • #12
                        The year fixed effect is perfectly correlated with the definitions of the crisis variables. It will estimate with xtreg as specified, but will drop a few years to resolve that issue. If you move i.year to the first regressor, then the crisis coefficients aren't estimated (with fixed effects, where the i.x appear matters, something Clyde has pointed out on several occasions).

                        reghdfe, on the other hand, won't estimate the crisis coefficients, as it takes out the FE before estimation.

                        Shouldn't precrisis be left out as the base? (I think Clyde's specification may resolve that issue with the use of i.)

                        I'm thinking the year fixed effects are redundant (not irrelevant, but redundant).

                        And Maxence makes a reasonable point about the lag DV, but it may not work in your case (didn't for me, though I didn't study why not)..

                        Comment


                        • #13
                          Originally posted by Clyde Schechter View Post
                          This puts things in a different light. Your proposed model would not answer this research question in any case. To do that, you need to have interaction terms between the treatment variables and the crisis variables. For that, you need to add the interaction terms to the model, remove the crisis variables, and leave i.time. So, something like this:
                          Code:
                          xtreg effect L1.effect i.eurozone c.debt_to_gdp c.TO c.labour_cost i.(precrises finacrisis eurocrisis postcrises)#(i.eurozone c.debt_to_gdp c.TO c.labour_cost) i.year, fe
                          Note: I don't know which variables here are the "treatment" variables. In the above code I have assumed that eurozone, debt_to_gdp, TO, and labour_cost are all treatment variables--though they may just be covariates, I don't know. For any of them that are just covariates, you may (optionally) remove them from the interaction part of the model.
                          Thank you so much. This truly solves my problem. Deeply grateful.

                          Comment


                          • #14
                            Originally posted by George Ford View Post
                            The year fixed effect is perfectly correlated with the definitions of the crisis variables. It will estimate with xtreg as specified, but will drop a few years to resolve that issue. If you move i.year to the first regressor, then the crisis coefficients aren't estimated (with fixed effects, where the i.x appear matters, something Clyde has pointed out on several occasions).

                            reghdfe, on the other hand, won't estimate the crisis coefficients, as it takes out the FE before estimation.

                            Shouldn't precrisis be left out as the base? (I think Clyde's specification may resolve that issue with the use of i.)
                            Thank you so much for the insights.

                            Comment

                            Working...
                            X