Announcement

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

  • xtreg regression leaves out one country for i.country

    Hello everyone,

    For my thesis, I am aming on extracting country fixed effects on the perception of migrants. For that purpose, my supervisor instructed me to use the *xtreg* command.

    As you can see below, when I use *tab cntry*, I have 20 countries including EE = Estonia:
    Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	15.9 KB
ID:	1522226



    But after using:
    xtset cntry
    xtrereg patm trstun trstep i.safe i.strgov i.trad i.rule imp_eco imp_cult lrscale ecoinsec i.hinctnta sex i.agebrack eduyrs highschool apprentice undergrad postgrad i.cntry, vce(robust)
    I receive the following output for the country variables:
    Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	25.4 KB
ID:	1522225


    As you can see, EE = Estonia is not included anymore. Why is that?

    I already tried removing vce(robust) or to replace it by vce(country = robust).

    Interestingly, I am working with the data from the Eurobarometer. This is for ESS7 in 2014. I already did the same regression on ESS8 in 2016 and I did not have that issue.

    Can anyone help me?

    Thank you very much in advance for your help!
    Aileen

  • #2
    You have too many categorical variables in your regression

    xtrereg patm trstun trstep i.safe i.strgov i.trad i.rule imp_eco imp_cult lrscale ecoinsec i.hinctnta sex i.agebrack eduyrs highschool apprentice undergrad postgrad i.cntry, vce(robust)
    Most probably, it is collinear with one of these dummies and was dropped. Compare how many coefficients of these other variables are present in this regression and the previous one.

    Comment


    • #3
      Originally posted by Aileen Elisabeth Bunte View Post
      But after using:
      xtset cntry
      xtrereg . . . i.cntry . . .
      Is that usual?

      Comment


      • #4
        Joseph:
        no, it is not (and illegal, too; -xtrereg-).
        I read that as a copy-and-paste typo made by the original poster (who can confirm it).
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          Many thanks for the fast response!

          And apologies for my typo: I use xtreg not, xtrereg.

          Andrew: Thank you for your advice. I am aware that it is a lot of categorical variables, but they are relevant for my analysis so if possible I would like to keep them. And all of them were present in the regression for ESS 8 2016, that is why I am so confused. I also assumed it had something to do with co-linearity, but if I remember well Stata would tell me if that was the case, correct? It would say something like: omitted due to multicolinearity.

          Last edited by Aileen Elisabeth Bunte; 28 Oct 2019, 06:51.

          Comment


          • #6
            Sorry, I did not pay attention to your code. I thought you were running the model using regress. If you xtset your data with country as the panel identifier, then you should not add -i.country- in the regression. Do you have a time variable? You should

            Code:
            xtset cntry year
            xtreg patm trstun trstep i.safe i.strgov i.trad i.rule imp_eco imp_cult lrscale ecoinsec i.hinctnta sex i.agebrack eduyrs highschool apprentice undergrad postgrad, fe vce(robust)
            Assuming "year" is your time variable. The fixed effects are usually nuisance parameters (and are not estimated consistently). But since you need these coefficients for one reason or another, to get them from xtreg, run

            Code:
            predict fe, u

            Added in edit: Also note by default, xtreg estimates a random effects model. Add option -fe- to get fixed effects.
            Last edited by Andrew Musau; 28 Oct 2019, 07:31.

            Comment


            • #7
              Aileen:
              thanks for clarifying that -xtrereg- actually was -xtreg-..
              However, it is strange that, with yiour previous code, you did not stumble upon a warning concerning your -matsize-
              Code:
              . use "http://www.stata-press.com/data/r15/nlswork.dta"
              (National Longitudinal Survey.  Young Women 14-26 years of age in 1968)
              
              . xtreg ln_wage age i.idcode if idcode<=4
              matsize too small
                  You have attempted to create a matrix with too many rows or columns or attempted to fit a model
                  with too many variables.  You need to increase matsize; it is currently 400.  Use set matsize; see
                  help matsize.
              
                  If you are using factor variables and included an interaction that has lots of missing cells,
                  either increase matsize or set emptycells drop to reduce the required matrix size; see help set
                  emptycells.
              
                  If you are using factor variables, you might have accidentally treated a continuous variable as a
                  categorical, resulting in lots of categories.  Use the c. operator on such variables.
              r(908);
              Kind regards,
              Carlo
              (Stata 19.0)

              Comment


              • #8
                Hello Andrew,
                Thanks for your input. I know it sounds unconventional, but the idea to use xtreg with i.cntry and nothing more is from my supervisor and I trust her statistical experience.

                I still tried out your method and I was able to get the country fixed effects, but same issue here: for Estonia I only get a . It also says in the regression that it is clustered with 19 countries (though it should be 20). I am really confused by that.

                Hello Carlo,

                Thanks for you input as well. I tried to change matsize (which really has not been an issue for me so far), but it did not help.

                Comment


                • #9
                  Hello Andrew,
                  Thanks for your input. I know it sounds unconventional, but the idea to use xtreg with i.cntry and nothing more is from my supervisor and I trust her statistical experience.
                  It is surprising that you get coefficient estimates if you have xtset your data correctly. They should all drop out due to collinearity. Because you provide no data example, my guess is that with no collinearity warning from Stata, one of your variables has all missing values for Estonia. Copy and paste the result of the following:

                  Code:
                  sum patm trstun trstep safe strgov trad rule imp_eco imp_cult lrscale ecoinsec hinctnta sex agebrack eduyrs highschool apprentice undergrad postgrad if cntry== "EE":`:val label cntry'
                  If this is not it, you may have to upload your data set if anyone in the forum is to be of more help.

                  Comment


                  • #10
                    Thank you so much Andrew, you are right! For hinctnta I do not have any values for Estonia, which is unfortunate. Hence, I will drop it for further analysis.

                    Have a good afternoon,
                    Aileen

                    Comment


                    • #11
                      Ailleen:
                      I do share Andrew's concern about the methodological soundness of including -i.panelid- as a predictor in the right-hand side of your regression equation (as they're collinear with the panel-wise fixed effect).
                      As Andrew surmised, the coefficients you obtained were probably due to the a variable having all missing values.
                      Kind regards,
                      Carlo
                      (Stata 19.0)

                      Comment


                      • #12
                        Let me try to explain the problem slightly differently. xtreg with fixed effects for country is precisely the same for the non-panel id variables as regress with i.country as a regressor. Try it. So, there is no point in the i.country in the regressors. Note also that you always have to drop one of the dummy values so that the sum of the dummies doesn't equal 1 which would be colinear with the column of 1's for the intercept. Stata does this automatically. All the parameters are then differences from the omitted country.

                        However, how you got what you say you did with xtreg is unclear.

                        You'll increase your chances of a useful answer by following the FAQ on asking questions - provide Stata code in code delimiters, readable Stata output, and sample data using dataex. Replicating the problem is often essential to fixing it. Full results (e.g., for xtreg) would also help us.

                        Comment

                        Working...
                        X