Announcement

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

  • How to conduct Hausman-test for mixed-model with random slopes?

    Hi to everyone in this forum,

    I am currently struggling with an issue regarding Hausman tests for multilevel models. I couldn't find any other post that would answer my questions. Still, I am a rookie to this platform and even though I read the posting advices, I might have missed out on something. So please, excuse me if I violate any points of the code of conduct. If I should correct or add something, please let me know!


    My data structure looks as follows (data obtained from ISSP and WID):

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float Likert_Prot_Env double WID_gini_NI byte left_right float(post_materialist mixed middle_edu high_edu middle_income high_income age) byte gender long encCountry float ISSP
    . .426481367479445  . 0 1 0 0 0 0 3 1 1 0
    . .426481367479445  1 0 1 1 0 0 0 2 2 1 0
    . .426481367479445 10 1 0 0 0 0 0 2 2 1 0
    . .426481367479445  5 0 1 0 0 0 0 5 2 1 0
    . .426481367479445 10 0 1 0 0 0 0 5 1 1 0
    . .426481367479445  1 0 1 1 0 0 0 3 2 1 0
    . .426481367479445 10 0 1 0 0 0 0 4 2 1 0
    . .426481367479445  8 1 0 1 0 0 0 5 1 1 0
    . .426481367479445  1 0 1 0 0 0 0 6 1 1 0
    . .426481367479445 10 0 1 1 0 0 0 5 2 1 0
    . .426481367479445 10 0 1 0 0 0 0 6 1 1 0
    . .426481367479445  8 0 1 1 0 0 0 3 1 1 0
    . .426481367479445  . 1 0 0 1 0 0 2 2 1 0
    . .426481367479445  . 0 0 1 0 0 0 2 1 1 0
    . .426481367479445 10 0 1 0 0 0 0 6 2 1 0
    . .426481367479445  5 0 1 0 0 0 0 3 2 1 0
    . .426481367479445  . 0 1 1 0 0 0 2 2 1 0
    . .426481367479445  3 0 0 1 0 0 0 4 1 1 0
    . .426481367479445 10 0 0 0 0 0 0 6 1 1 0
    . .426481367479445  7 0 1 1 0 0 0 4 2 1 0
    . .426481367479445  . 0 1 1 0 0 0 5 1 1 0
    . .426481367479445  1 0 1 1 0 0 0 5 1 1 0
    . .426481367479445  1 0 1 1 0 0 0 6 2 1 0
    . .426481367479445  5 0 1 0 0 0 0 5 2 1 0
    . .426481367479445  1 0 0 0 0 0 0 5 2 1 0
    . .426481367479445  5 0 1 0 0 0 0 4 2 1 0
    . .426481367479445  3 0 1 1 0 0 0 4 2 1 0
    . .426481367479445  3 0 0 1 0 0 0 3 2 1 0
    . .426481367479445  . 0 1 0 0 0 0 5 2 1 0
    . .426481367479445  . 0 1 1 0 0 0 6 1 1 0
    . .426481367479445  6 0 0 0 0 0 0 5 2 1 0
    . .426481367479445  5 0 1 0 0 0 0 4 2 1 0
    . .426481367479445 10 0 1 1 0 0 0 1 2 1 0
    . .426481367479445  8 0 0 0 0 0 0 5 2 1 0
    . .426481367479445  8 0 0 0 0 0 0 1 1 1 0
    . .426481367479445 10 1 0 0 0 0 0 5 2 1 0
    . .426481367479445  . 0 1 0 0 0 0 4 2 1 0
    . .426481367479445  4 0 0 1 0 0 0 3 2 1 0
    . .426481367479445  2 0 0 1 0 0 0 3 2 1 0
    . .426481367479445  9 0 1 0 0 0 0 4 2 1 0
    . .426481367479445  6 0 0 0 0 0 0 2 2 1 0
    . .426481367479445  . 0 1 0 0 0 0 3 2 1 0
    . .426481367479445  1 0 0 1 0 0 0 2 2 1 0
    . .426481367479445  . 0 1 0 0 0 0 5 1 1 0
    . .426481367479445  3 0 0 0 0 0 0 4 2 1 0
    . .426481367479445  3 1 0 1 0 0 0 6 2 1 0
    . .426481367479445  . 0 1 1 0 0 0 2 2 1 0
    . .426481367479445  . 0 1 0 0 0 0 3 2 1 0
    . .426481367479445  5 0 1 1 0 0 0 6 1 1 0
    . .426481367479445  1 0 1 0 0 0 0 4 2 1 0
    . .426481367479445 10 0 1 1 0 0 0 5 2 1 0
    . .426481367479445 10 0 1 0 0 0 0 3 2 1 0
    . .426481367479445  1 0 0 1 0 0 0 5 2 1 0
    . .426481367479445  . 1 0 0 0 0 0 3 1 1 0
    . .426481367479445  3 0 1 1 0 0 0 6 2 1 0
    . .426481367479445  7 0 1 0 0 0 0 4 2 1 0
    . .426481367479445  . 0 1 1 0 0 0 3 2 1 0
    . .426481367479445  . 0 1 0 0 0 0 4 1 1 0
    . .426481367479445 10 0 1 0 0 0 0 6 1 1 0
    . .426481367479445  1 0 1 0 0 0 0 3 2 1 0
    . .426481367479445  8 0 0 1 0 0 0 2 2 1 0
    . .426481367479445 10 0 1 0 0 0 0 2 1 1 0
    . .426481367479445  . 0 1 1 0 0 0 1 2 1 0
    . .426481367479445  1 1 0 0 0 0 0 3 2 1 0
    . .426481367479445  . 0 1 0 0 0 0 2 2 1 0
    . .426481367479445  1 0 0 0 0 0 0 4 1 1 0
    . .426481367479445  1 0 1 1 0 0 0 4 1 1 0
    . .426481367479445  . 0 0 0 0 0 0 6 2 1 0
    . .426481367479445  . 0 1 0 0 0 0 3 2 1 0
    . .426481367479445 10 0 1 1 0 0 0 4 2 1 0
    . .426481367479445  . 0 1 1 0 0 0 4 1 1 0
    . .426481367479445  1 0 1 1 0 0 0 5 2 1 0
    . .426481367479445  . 0 1 1 0 0 0 5 2 1 0
    . .426481367479445 10 0 0 0 0 0 0 4 2 1 0
    . .426481367479445  . 0 1 1 0 0 0 1 2 1 0
    . .426481367479445  5 0 1 0 0 0 0 2 2 1 0
    . .426481367479445  1 0 1 1 0 0 0 3 2 1 0
    . .426481367479445  5 0 0 1 0 0 0 5 2 1 0
    . .426481367479445  . 0 1 0 0 0 0 6 1 1 0
    . .426481367479445  2 0 1 0 0 0 0 2 1 1 0
    . .426481367479445  . 0 1 1 0 0 0 5 2 1 0
    . .426481367479445  . 0 1 0 0 0 0 4 2 1 0
    . .426481367479445  . 0 0 1 0 0 0 5 2 1 0
    . .426481367479445 10 0 0 0 1 0 0 6 1 1 0
    . .426481367479445  1 0 1 1 0 0 0 6 2 1 0
    . .426481367479445  1 0 1 0 0 0 0 6 2 1 0
    . .426481367479445  . 0 1 0 0 0 0 6 1 1 0
    . .426481367479445  . 0 1 0 0 0 0 2 2 1 0
    . .426481367479445  . 0 1 1 0 0 0 3 1 1 0
    . .426481367479445  1 0 0 1 0 0 0 4 1 1 0
    . .426481367479445  . 0 1 0 0 0 0 6 2 1 0
    . .426481367479445  5 0 0 0 0 0 0 4 2 1 0
    . .426481367479445  . 0 0 0 0 0 0 4 2 1 0
    . .426481367479445  1 0 1 0 0 0 0 6 2 1 0
    . .426481367479445  5 0 1 0 0 0 0 3 1 1 0
    . .426481367479445  . 0 1 0 0 0 0 4 1 1 0
    . .426481367479445  . 0 1 1 0 0 0 4 1 1 0
    . .426481367479445 10 0 1 0 0 0 0 5 1 1 0
    . .426481367479445  . 0 1 0 0 0 0 3 2 1 0
    . .426481367479445  . 0 1 0 1 0 0 5 2 1 0
    end
    label values left_right PARTY_LR
    label def PARTY_LR 1 "1. Far left (communist, etc.)", modify
    label def PARTY_LR 2 "2. Left / center left", modify
    label def PARTY_LR 3 "3. Center / liberal", modify
    label def PARTY_LR 4 "4. Right / conservative", modify
    label def PARTY_LR 5 "5. Far right (fascist, etc.)", modify
    label def PARTY_LR 6 "6. Other", modify
    label values gender SEX
    label def SEX 1 "1. Male", modify
    label def SEX 2 "2. Female", modify
    label values encCountry encCountry
    label def encCountry 1 "Albania", modify
    The model I want to implement:
    >> mixed Likert_Prot_Env WID_gini_NI left_right post_materialist mixed middle_edu high_edu middle_income high_income age gender if ISSP==1 || encCountry <<
    with individual observations being nested in countries. All variables are on the individual level except WID_gini_NI which is the gini for each country.

    If I go on to implement the following FE model:
    >> reg Likert_Prot_Env left_right post_materialist mixed middle_edu high_edu middle_income high_income age gender i.encCountry if ISSP==1 <<
    I only get negative chi2-values for Hausman:

    "Test of H0: Difference in coefficients not systematic

    chi2(9) = (b-B)'[(V_b-V_B)^(-1)](b-B)
    = -16.56

    Warning: chi2 < 0 ==> model fitted on these data
    fails to meet the asymptotic assumptions
    of the Hausman test; see suest for a
    generalized test."

    Usually, this problem seems to be fixed with the "sigmamore"-option. Yet, this option is not available for "mixed"-commands, since it does not store sigma.
    Another solution would be to use "xtreg, re" instead of "mixed". This is also not viable for me (if I am correct), since I include variables on the second/country level (random slopes), which is not possible for ", re".

    Does any-one know a solution for this? I really tried lots of things and still, I wasn't able to find any solution for this. All help will be very, very much appreciated!

    (If it is of any help to get the intuition behind the model: I am checking for a relationship between the personal willingness to pay for a green transition of the economy and the economic inequality in a country)


  • #2
    I am not clear on your question, but your mixed model is not doing what you describe, as there are no separate slopes. What you have shown is identical to xtreg, mle, which is a random effect model such that each encCountry will have a separate intercept. Your second reg model should be run using xtreg, fe or reghdfe to account for the proper degrees of freedom. But, the first model is an encCountyr random effect model whereas the second is a fixed effect model.
    If you want to use the Hausman test to compare models, run both with xtreg, one with the re option and the other with the fe option.
    But, the Hausman test will simply tell you if the coefficients are statistically similar such that if they are then you can use either model (since the coefficients are similar), but if they are not then you should use a fixed effect model. However, bear in mind that a fixed effect model only considers within-entity variation, whereas a random effect model combines both within and between-entity variation. For this reason, the interpretation of a random effects model is not as clear, but it is sometimes necessary due to time-invariant variables which get washed out of a fixed effect model.

    Comment


    • #3
      Dear JJ Kovach,

      thanks a lot for your reply. You are probably right on the slopes thing.
      To my understanding, I have to use a random effects model, since in my case, gini is basically a "time-invariant" variable: In panel data, different observations over time are the level 1 observations, while all time-invariant variables are associated with level 2 (the individual level). In my case, individuals are level 1 and country variables are level 2. In an fe model country variables would therefore be ruled out, just like time-invariant variables would be for panel data. This is also the reason I did not choose ", re" since I read that this command is not capable of including level 2 variables. Do you know, if I can do this with , mle?
      I also tried running , mle and compared it with the results from mixed. The estimates and also the p-values seem to be quite different from each other.

      Thanks again

      Comment


      • #4
        I am trying to help, but precision in terminology is important.

        "while all time-invariant variables are associated with level 2 (the individual level). In my case, individuals are level 1 and country variables are level 2." I assume you mean the second sentence as it contradicts the first?

        'In an fe model country variables would therefore be ruled out, just like time-invariant variables would be for panel data.' Time invariant variables are not 'ruled out' of panel data models, only with entity specific fixed effects panel models. They are not omitted from entity random effects or entity between effects, nor are their interactions omitted from fixed effects models.

        xtreg, mle will yield similar outcomes to -xtreg, re, and both handle nested data in the same way. -xtreg, mle uses maximum likelihood estimation whereas -xtreg, re uses generalized least squares, but they are both random effects models which means (among other things) that the coefficients are a weighted mix of the between and within effects. -mixed uses maximum likelihood estimation so its results can be identical to -xtreg, mle under some conditions. I tried to run the model you indicated, but the "if ISSP==1" constraint is never satisfied, as the data you show has 0s for all ISSP instances. Thus, I cannot reproduce your results. Please post the actual code showing your results so it can be evaluated.

        Comment


        • #5
          I am sorry for not being precise enough and thank you for your patience. I will try to explain it better. Regarding your first question: Yes, you are right, I mean the second sentence. I was only trying to explain why I think I cannot use , fe or , re: Because I have variables on the second level (the country level) which would be washed out in an ,fe model and can also not be properly estimated in an , re model (if I get it right), which is why I chose mixed.

          Speaking of the data I provided, I really made a mistake and only provided invalid observations. Please, excuse me. Here is another set of variables with only valid observations (not necessary any more to include the condition "ISSP==1" in the model):

          Code:
          * Example generated by -dataex-. For more info, type help dataex
          clear
          input float Likert_Prot_Env double WID_gini_NI byte left_right float(post_materialist mixed middle_edu high_edu middle_income high_income age) byte gender long encCountry
          12                .  . 0 0 0 1 0 0 6 1  3
           6                .  2 0 0 0 1 1 0 3 2  3
           5                .  4 0 1 0 0 0 1 3 1  3
           .                .  . 0 0 0 1 0 0 4 2  3
          11  .29771838170867  2 0 0 1 0 0 0 4 2  4
           7  .29771838170867  2 0 0 0 0 1 0 6 2  4
           6  .29771838170867  4 1 0 1 0 0 1 4 2  4
           5  .29771838170867  2 0 0 1 0 0 0 6 1  4
           3 .382910851896986  2 0 1 1 0 0 0 5 1 10
           4 .382910851896986  4 1 0 1 0 1 0 3 2 10
           7 .382910851896986 96 1 1 0 0 0 1 6 1 10
           3 .382910851896986  . 0 1 1 0 0 0 3 2 10
          12 .317511502023727  3 0 1 0 1 0 0 6 1 12
           8 .317511502023727  1 0 1 0 1 1 0 4 2 12
           . .317511502023727  1 0 0 0 1 0 1 6 2 12
           9 .317511502023727  . 0 1 1 0 0 0 2 2 12
          12  .31711412727492  6 1 0 0 1 0 0 2 1 14
           3  .31711412727492  4 0 1 1 0 1 0 2 1 14
           7  .31711412727492  4 0 0 0 1 0 1 2 1 14
           5  .31711412727492  4 0 0 0 1 0 0 6 2 14
           3 .315502443824087  4 0 1 0 1 0 0 3 2 15
           7 .315502443824087  3 0 1 0 1 1 0 6 2 15
          10 .315502443824087  2 1 0 1 0 0 1 4 2 15
           3 .315502443824087 96 0 1 0 1 0 0 4 2 15
           4  .31880451313118  . 0 1 1 0 0 0 6 2 17
          10  .31880451313118  2 0 1 1 0 1 0 6 1 17
          11  .31880451313118  2 0 0 0 1 0 1 4 1 17
          10  .31880451313118  1 0 0 1 0 0 0 6 1 17
           6 .347332686814582  4 0 0 0 0 0 0 6 2 19
           3 .347332686814582  . 0 0 0 0 1 0 3 2 19
          13 .347332686814582  3 0 0 1 0 0 1 1 2 19
           6 .347332686814582  4 0 1 0 1 0 0 1 2 19
          11 .266577932014147  . 0 0 1 0 0 0 4 1 20
          11 .266577932014147  . 0 1 1 0 1 0 3 2 20
          12 .273249817316092  2 0 1 0 1 0 1 4 2 20
           7 .266577932014147  . 0 1 0 1 0 0 4 1 20
           8 .480229969666585  3 0 0 0 0 0 0 6 1 21
          12 .480229969666585  . 0 1 1 0 1 0 4 1 21
          12 .480229969666585  3 0 1 0 1 0 1 4 2 21
          14 .480229969666585  2 0 1 1 0 0 0 3 1 21
          10 .410040338909816  4 1 0 0 0 0 0 6 1 22
          12 .410040338909816  2 0 1 0 1 1 0 3 2 22
          13 .410040338909816  4 0 1 1 0 0 1 5 1 22
           5 .410040338909816  . 1 1 1 0 0 0 5 2 22
           3 .625335378691203  2 0 1 1 0 0 0 5 1 24
           9 .625335378691203  4 0 1 0 0 1 0 5 1 24
           4 .625335378691203  . 0 0 0 1 0 1 5 1 24
           . .625335378691203  . 0 1 1 0 0 0 1 2 24
           8 .312597233641764  2 0 0 0 1 0 0 3 2 27
          12 .312597233641764  2 0 1 0 1 1 0 1 2 27
          10 .312597233641764  2 0 1 0 0 0 1 5 1 27
           . .312597233641764  . 1 1 0 1 0 0 4 1 27
           7 .262263788839457  2 0 1 1 0 0 0 5 1 29
           7 .262263788839457  4 0 1 0 1 1 0 3 1 29
          12 .262263788839457  2 0 1 0 1 0 1 3 2 29
          12 .262263788839457  2 0 1 0 1 0 0 4 2 29
           3 .479457431075552  3 0 1 1 0 0 0 5 1 33
          11 .479457431075552  . 0 1 0 1 1 0 1 2 33
           7 .479457431075552  3 0 1 0 1 0 1 6 1 33
           . .479457431075552  . 1 0 0 1 0 0 5 2 33
          10 .273364698905071  4 0 0 1 0 0 0 6 1 35
          11 .273364698905071  3 0 1 1 0 1 0 2 1 35
           7 .273364698905071  2 0 1 1 0 0 1 4 2 35
           6 .273364698905071  4 0 0 1 0 0 0 4 1 35
           6 .293909840433564  . 1 0 0 1 0 0 2 2 36
          10 .293732798472523  3 1 0 0 1 1 0 6 1 36
          12 .293732798472523  4 0 1 1 0 0 1 4 1 36
           7 .293732798472523  . 0 1 1 0 0 0 2 2 36
          12 .282895576374681  . 0 1 1 0 0 0 5 1 38
          10 .282895576374681  4 0 0 1 0 1 0 6 1 38
           8 .282895576374681  3 0 1 1 0 0 1 4 1 38
           6 .282895576374681  . 0 1 0 1 0 0 3 2 38
          14 .404394540995419  2 0 1 1 0 0 0 5 2 39
          10 .404394540995419  2 0 1 0 1 1 0 2 2 39
           8 .404394540995419  4 0 1 1 0 0 1 1 1 39
           7 .404394540995419  . 0 1 0 1 0 0 3 2 39
           9                .  . 0 1 1 0 0 0 2 2 41
          14                .  3 1 0 1 0 1 0 3 2 41
          14                .  3 1 0 0 1 0 1 6 2 41
           9                .  . 1 1 0 0 0 0 3 2 41
          end
          label values left_right PARTY_LR
          label def PARTY_LR 1 "1. Far left (communist, etc.)", modify
          label def PARTY_LR 2 "2. Left / center left", modify
          label def PARTY_LR 3 "3. Center / liberal", modify
          label def PARTY_LR 4 "4. Right / conservative", modify
          label def PARTY_LR 6 "6. Other", modify
          label def PARTY_LR 96 "96. Invalid ballot", modify
          label values gender SEX
          label def SEX 1 "1. Male", modify
          label def SEX 2 "2. Female", modify
          label values encCountry encCountry
          label def encCountry 3 "Australia", modify
          label def encCountry 4 "Austria", modify
          label def encCountry 10 "Croatia", modify
          label def encCountry 12 "Denmark", modify
          label def encCountry 14 "Finland", modify
          label def encCountry 15 "France", modify
          label def encCountry 17 "Germany", modify
          label def encCountry 19 "Hungary", modify
          label def encCountry 20 "Iceland", modify
          label def encCountry 21 "Italy", modify
          label def encCountry 22 "Japan", modify
          label def encCountry 24 "Lithuania", modify
          label def encCountry 27 "New Zealand", modify
          label def encCountry 29 "Norway", modify
          label def encCountry 33 "Russia", modify
          label def encCountry 35 "Slovakia", modify
          label def encCountry 36 "Slovenia", modify
          label def encCountry 38 "Sweden", modify
          label def encCountry 39 "Switzerland", modify
          label def encCountry 41 "United States", modify

          The model is now:
          Code:
          mixed Likert_Prot_Env WID_gini_NI left_right post_materialist mixed middle_edu high_edu middle_income high_income age gender || encCountry
          est sto me
          and the FE model:
          Code:
          xtset encCountry
          xtreg Likert_Prot_Env left_right post_materialist mixed middle_edu high_edu middle_income high_income age gender, fe
          est sto fe
          hausman fe me
          My results:

          Code:
          . mixed Likert_Prot_Env WID_gini_NI left_right post_materialist mixed middle_edu high_edu middle_income high_income age gender || encCountry:
          
          Performing EM optimization ...
          
          Performing gradient-based optimization:
          Iteration 0: Log likelihood = -37530.394
          Iteration 1: Log likelihood = -37530.394
          
          Computing standard errors ...
          
          Mixed-effects ML regression Number of obs = 15,378
          Group variable: encCountry Number of groups = 18
          Obs per group:
          min = 291
          avg = 854.3
          max = 2,408
          Wald chi2(10) = 878.16
          Log likelihood = -37530.394 Prob > chi2 = 0.0000
          
          ----------------------------------------------------------------------------------
          Likert_Prot_Env | Coefficient Std. err. z P>|z| [95% conf. interval]
          -----------------+----------------------------------------------------------------
          WID_gini_NI | -2.890542 2.398095 -1.21 0.228 -7.590722 1.809638
          left_right | -.0085881 .0018078 -4.75 0.000 -.0121314 -.0050449
          post_materialist | 1.208417 .0697083 17.34 0.000 1.071791 1.345043
          mixed | .392136 .0510655 7.68 0.000 .2920494 .4922227
          middle_edu | .2924847 .0785446 3.72 0.000 .1385401 .4464294
          high_edu | .974378 .0802422 12.14 0.000 .8171062 1.13165
          middle_income | .2827749 .0547985 5.16 0.000 .1753718 .390178
          high_income | .512154 .0587002 8.72 0.000 .3971037 .6272043
          age | -.0106252 .0153465 -0.69 0.489 -.0407038 .0194533
          gender | .3502312 .045017 7.78 0.000 .2619995 .4384629
          _cons | 7.743422 .8895835 8.70 0.000 5.99987 9.486974
          ----------------------------------------------------------------------------------
          
          ------------------------------------------------------------------------------
          Random-effects parameters | Estimate Std. err. [95% conf. interval]
          -----------------------------+------------------------------------------------
          encCountry: Identity |
          var(_cons) | .8714548 .2977929 .4460391 1.702617
          -----------------------------+------------------------------------------------
          var(Residual) | 7.674782 .0875773 7.505039 7.848365
          ------------------------------------------------------------------------------
          LR test vs. linear model: chibar2(01) = 1596.01 Prob >= chibar2 = 0.0000
          
          
          
          . xtset encCountry
          
          Panel variable: encCountry (unbalanced)
          
          . xtreg Likert_Prot_Env left_right post_materialist mixed middle_edu high_edu middle_income high_income age gender, fe
          
          Fixed-effects (within) regression Number of obs = 17,391
          Group variable: encCountry Number of groups = 20
          
          R-squared: Obs per group:
          Within = 0.0544 min = 291
          Between = 0.2977 avg = 869.5
          Overall = 0.0615 max = 2,408
          
          F(9, 17362) = 110.98
          corr(u_i, Xb) = 0.0668 Prob > F = 0.0000
          
          ----------------------------------------------------------------------------------
          Likert_Prot_Env | Coefficient Std. err. t P>|t| [95% conf. interval]
          -----------------+----------------------------------------------------------------
          left_right | -.0091988 .0018224 -5.05 0.000 -.0127708 -.0056267
          post_materialist | 1.140871 .0654806 17.42 0.000 1.012523 1.26922
          mixed | .3621251 .0488464 7.41 0.000 .2663812 .457869
          middle_edu | .2506549 .075118 3.34 0.001 .103416 .3978938
          high_edu | 1.005865 .0761732 13.20 0.000 .8565581 1.155173
          middle_income | .2850975 .0523331 5.45 0.000 .1825193 .3876757
          high_income | .5031084 .0560738 8.97 0.000 .3931981 .6130187
          age | -.0190207 .0147166 -1.29 0.196 -.0478667 .0098253
          gender | .360422 .0430142 8.38 0.000 .2761099 .4447341
          _cons | 7.113977 .1293089 55.02 0.000 6.860519 7.367436
          -----------------+----------------------------------------------------------------
          sigma_u | .99131895
          sigma_e | 2.8136146
          rho | .11042789 (fraction of variance due to u_i)
          ----------------------------------------------------------------------------------
          F test that all u_i=0: F(19, 17362) = 97.45 Prob > F = 0.0000
          
          . est sto fe
          
          . hausman fe me
          no coefficients in common; specify equations(matchlist)
          for problems with different equation names.
          r(498);
          
          .

          In my first post I mentioned that my problem was negative Chi2-values for the hausman test. As you can see, for some reason, I encountered another problem now, which is
          "no coefficients in common; specify equations(matchlist)
          for problems with different equation names.
          r(498);"
          for which I also haven't got any solution, yet. I guess, it occurs because of the different structures of the mixed and xtreg command. But still, I don't know why this problem occurs only now, since I haven't changed anything in the code.
          So, I guess, the problem with negative Chi2-hausman-values remains.

          I also tried using the ,mle option. It gave me the same error as above:

          Code:
          . xtset encCountry
          
          Panel variable: encCountry (unbalanced)
          
          . xtreg Likert_Prot_Env WID_gini_NI left_right post_materialist mixed middle_edu high_edu middle_income high_income age gender, mle
          
          Fitting constant-only model:
          Iteration 0: Log likelihood = -37958.199
          Iteration 1: Log likelihood = -37957.121
          Iteration 2: Log likelihood = -37957.06
          Iteration 3: Log likelihood = -37957.059
          Iteration 4: Log likelihood = -37957.059
          
          Fitting full model:
          Iteration 0: Log likelihood = -37546.158
          Iteration 1: Log likelihood = -37530.511
          Iteration 2: Log likelihood = -37530.396
          Iteration 3: Log likelihood = -37530.394
          Iteration 4: Log likelihood = -37530.394
          
          Random-effects ML regression Number of obs = 15,378
          Group variable: encCountry Number of groups = 18
          
          Random effects u_i ~ Gaussian Obs per group:
          min = 291
          avg = 854.3
          max = 2,408
          
          LR chi2(10) = 853.33
          Log likelihood = -37530.394 Prob > chi2 = 0.0000
          
          ----------------------------------------------------------------------------------
          Likert_Prot_Env | Coefficient Std. err. z P>|z| [95% conf. interval]
          -----------------+----------------------------------------------------------------
          WID_gini_NI | -2.890545 2.426082 -1.19 0.233 -7.645579 1.864489
          left_right | -.0085881 .0018078 -4.75 0.000 -.0121314 -.0050449
          post_materialist | 1.208417 .0697112 17.33 0.000 1.071786 1.345049
          mixed | .392136 .0510678 7.68 0.000 .2920451 .492227
          middle_edu | .2924847 .0785466 3.72 0.000 .1385363 .4464332
          high_edu | .974378 .0802473 12.14 0.000 .8170963 1.13166
          middle_income | .2827749 .0547994 5.16 0.000 .1753702 .3901797
          high_income | .512154 .0587037 8.72 0.000 .3970968 .6272112
          age | -.0106252 .0153488 -0.69 0.489 -.0407084 .019458
          gender | .3502312 .045017 7.78 0.000 .2619994 .438463
          _cons | 7.743423 .8989071 8.61 0.000 5.981597 9.505248
          -----------------+----------------------------------------------------------------
          /sigma_u | .9335162 .1595015 .6678589 1.304845
          /sigma_e | 2.77034 .0158062 2.739533 2.801493
          rho | .1019692 .0313107 .0531388 .1773092
          ----------------------------------------------------------------------------------
          LR test of sigma_u=0: chibar2(01) = 1596.01 Prob >= chibar2 = 0.000
          
          . est sto re
          
          . xtreg Likert_Prot_Env left_right post_materialist mixed middle_edu high_edu middle_income high_income age gender, fe
          
          Fixed-effects (within) regression Number of obs = 17,391
          Group variable: encCountry Number of groups = 20
          
          R-squared: Obs per group:
          Within = 0.0544 min = 291
          Between = 0.2977 avg = 869.5
          Overall = 0.0615 max = 2,408
          
          F(9, 17362) = 110.98
          corr(u_i, Xb) = 0.0668 Prob > F = 0.0000
          
          ----------------------------------------------------------------------------------
          Likert_Prot_Env | Coefficient Std. err. t P>|t| [95% conf. interval]
          -----------------+----------------------------------------------------------------
          left_right | -.0091988 .0018224 -5.05 0.000 -.0127708 -.0056267
          post_materialist | 1.140871 .0654806 17.42 0.000 1.012523 1.26922
          mixed | .3621251 .0488464 7.41 0.000 .2663812 .457869
          middle_edu | .2506549 .075118 3.34 0.001 .103416 .3978938
          high_edu | 1.005865 .0761732 13.20 0.000 .8565581 1.155173
          middle_income | .2850975 .0523331 5.45 0.000 .1825193 .3876757
          high_income | .5031084 .0560738 8.97 0.000 .3931981 .6130187
          age | -.0190207 .0147166 -1.29 0.196 -.0478667 .0098253
          gender | .360422 .0430142 8.38 0.000 .2761099 .4447341
          _cons | 7.113977 .1293089 55.02 0.000 6.860519 7.367436
          -----------------+----------------------------------------------------------------
          sigma_u | .99131895
          sigma_e | 2.8136146
          rho | .11042789 (fraction of variance due to u_i)
          ----------------------------------------------------------------------------------
          F test that all u_i=0: F(19, 17362) = 97.45 Prob > F = 0.0000
          
          . est sto fe
          
          . hausman fe re
          no coefficients in common; specify equations(matchlist)
          for problems with different equation names.
          r(498);
          
          .
          The only thing I can say for sure, is that the problem is not that I include "WID_gini_NI" as a variable in my re model but not in the fe model.

          I hope, this makes things clearer.
          Last edited by Daniel Geiter; 08 May 2024, 06:51.

          Comment


          • #6
            Something is amiss, as when I run the analysis with the data you generated I do not get the same results you have posted. First though, here is confirmation that the -mixed model (as you wanted to specify, but without the WID_gini_NI variable) matches an -xtreg, mle model.

            Copying your generated date:

            //
            clear
            input float Likert_Prot_Env double WID_gini_NI byte left_right float(post_materialist mixed middle_edu high_edu middle_income high_income age) byte gender long encCountry
            12 . . 0 0 0 1 0 0 6 1 3
            6 . 2 0 0 0 1 1 0 3 2 3
            5 . 4 0 1 0 0 0 1 3 1 3
            . . . 0 0 0 1 0 0 4 2 3
            11 .29771838170867 2 0 0 1 0 0 0 4 2 4
            7 .29771838170867 2 0 0 0 0 1 0 6 2 4
            6 .29771838170867 4 1 0 1 0 0 1 4 2 4
            5 .29771838170867 2 0 0 1 0 0 0 6 1 4
            3 .382910851896986 2 0 1 1 0 0 0 5 1 10
            4 .382910851896986 4 1 0 1 0 1 0 3 2 10
            7 .382910851896986 96 1 1 0 0 0 1 6 1 10
            3 .382910851896986 . 0 1 1 0 0 0 3 2 10
            12 .317511502023727 3 0 1 0 1 0 0 6 1 12
            8 .317511502023727 1 0 1 0 1 1 0 4 2 12
            . .317511502023727 1 0 0 0 1 0 1 6 2 12
            9 .317511502023727 . 0 1 1 0 0 0 2 2 12
            12 .31711412727492 6 1 0 0 1 0 0 2 1 14
            3 .31711412727492 4 0 1 1 0 1 0 2 1 14
            7 .31711412727492 4 0 0 0 1 0 1 2 1 14
            5 .31711412727492 4 0 0 0 1 0 0 6 2 14
            3 .315502443824087 4 0 1 0 1 0 0 3 2 15
            7 .315502443824087 3 0 1 0 1 1 0 6 2 15
            10 .315502443824087 2 1 0 1 0 0 1 4 2 15
            3 .315502443824087 96 0 1 0 1 0 0 4 2 15
            4 .31880451313118 . 0 1 1 0 0 0 6 2 17
            10 .31880451313118 2 0 1 1 0 1 0 6 1 17
            11 .31880451313118 2 0 0 0 1 0 1 4 1 17
            10 .31880451313118 1 0 0 1 0 0 0 6 1 17
            6 .347332686814582 4 0 0 0 0 0 0 6 2 19
            3 .347332686814582 . 0 0 0 0 1 0 3 2 19
            13 .347332686814582 3 0 0 1 0 0 1 1 2 19
            6 .347332686814582 4 0 1 0 1 0 0 1 2 19
            11 .266577932014147 . 0 0 1 0 0 0 4 1 20
            11 .266577932014147 . 0 1 1 0 1 0 3 2 20
            12 .273249817316092 2 0 1 0 1 0 1 4 2 20
            7 .266577932014147 . 0 1 0 1 0 0 4 1 20
            8 .480229969666585 3 0 0 0 0 0 0 6 1 21
            12 .480229969666585 . 0 1 1 0 1 0 4 1 21
            12 .480229969666585 3 0 1 0 1 0 1 4 2 21
            14 .480229969666585 2 0 1 1 0 0 0 3 1 21
            10 .410040338909816 4 1 0 0 0 0 0 6 1 22
            12 .410040338909816 2 0 1 0 1 1 0 3 2 22
            13 .410040338909816 4 0 1 1 0 0 1 5 1 22
            5 .410040338909816 . 1 1 1 0 0 0 5 2 22
            3 .625335378691203 2 0 1 1 0 0 0 5 1 24
            9 .625335378691203 4 0 1 0 0 1 0 5 1 24
            4 .625335378691203 . 0 0 0 1 0 1 5 1 24
            . .625335378691203 . 0 1 1 0 0 0 1 2 24
            8 .312597233641764 2 0 0 0 1 0 0 3 2 27
            12 .312597233641764 2 0 1 0 1 1 0 1 2 27
            10 .312597233641764 2 0 1 0 0 0 1 5 1 27
            . .312597233641764 . 1 1 0 1 0 0 4 1 27
            7 .262263788839457 2 0 1 1 0 0 0 5 1 29
            7 .262263788839457 4 0 1 0 1 1 0 3 1 29
            12 .262263788839457 2 0 1 0 1 0 1 3 2 29
            12 .262263788839457 2 0 1 0 1 0 0 4 2 29
            3 .479457431075552 3 0 1 1 0 0 0 5 1 33
            11 .479457431075552 . 0 1 0 1 1 0 1 2 33
            7 .479457431075552 3 0 1 0 1 0 1 6 1 33
            . .479457431075552 . 1 0 0 1 0 0 5 2 33
            10 .273364698905071 4 0 0 1 0 0 0 6 1 35
            11 .273364698905071 3 0 1 1 0 1 0 2 1 35
            7 .273364698905071 2 0 1 1 0 0 1 4 2 35
            6 .273364698905071 4 0 0 1 0 0 0 4 1 35
            6 .293909840433564 . 1 0 0 1 0 0 2 2 36
            10 .293732798472523 3 1 0 0 1 1 0 6 1 36
            12 .293732798472523 4 0 1 1 0 0 1 4 1 36
            7 .293732798472523 . 0 1 1 0 0 0 2 2 36
            12 .282895576374681 . 0 1 1 0 0 0 5 1 38
            10 .282895576374681 4 0 0 1 0 1 0 6 1 38
            8 .282895576374681 3 0 1 1 0 0 1 4 1 38
            6 .282895576374681 . 0 1 0 1 0 0 3 2 38
            14 .404394540995419 2 0 1 1 0 0 0 5 2 39
            10 .404394540995419 2 0 1 0 1 1 0 2 2 39
            8 .404394540995419 4 0 1 1 0 0 1 1 1 39
            7 .404394540995419 . 0 1 0 1 0 0 3 2 39
            9 . . 0 1 1 0 0 0 2 2 41
            14 . 3 1 0 1 0 1 0 3 2 41
            14 . 3 1 0 0 1 0 1 6 2 41
            9 . . 1 1 0 0 0 0 3 2 41
            end
            label values left_right PARTY_LR
            label def PARTY_LR 1 "1. Far left (communist, etc.)", modify
            label def PARTY_LR 2 "2. Left / center left", modify
            label def PARTY_LR 3 "3. Center / liberal", modify
            label def PARTY_LR 4 "4. Right / conservative", modify
            label def PARTY_LR 6 "6. Other", modify
            label def PARTY_LR 96 "96. Invalid ballot", modify
            label values gender SEX
            label def SEX 1 "1. Male", modify
            label def SEX 2 "2. Female", modify
            label values encCountry encCountry
            label def encCountry 3 "Australia", modify
            label def encCountry 4 "Austria", modify
            label def encCountry 10 "Croatia", modify
            label def encCountry 12 "Denmark", modify
            label def encCountry 14 "Finland", modify
            label def encCountry 15 "France", modify
            label def encCountry 17 "Germany", modify
            label def encCountry 19 "Hungary", modify
            label def encCountry 20 "Iceland", modify
            label def encCountry 21 "Italy", modify
            label def encCountry 22 "Japan", modify
            label def encCountry 24 "Lithuania", modify
            label def encCountry 27 "New Zealand", modify
            label def encCountry 29 "Norway", modify
            label def encCountry 33 "Russia", modify
            label def encCountry 35 "Slovakia", modify
            label def encCountry 36 "Slovenia", modify
            label def encCountry 38 "Sweden", modify
            label def encCountry 39 "Switzerland", modify
            label def encCountry 41 "United States", modify
            //

            Here is the -mixed model

            Code:
            . mixed Likert_Prot_Env left_right post_materialist mixed middle_edu high_edu middle_income high_income age gender|| encCountry:
            
            Performing EM optimization ...
            
            Performing gradient-based optimization: 
            Iteration 0:   log likelihood = -139.99379  
            Iteration 1:   log likelihood = -139.99249  
            Iteration 2:   log likelihood = -139.99249  
            
            Computing standard errors ...
            
            Mixed-effects ML regression                     Number of obs     =         56
            Group variable: encCountry                      Number of groups  =         20
                                                            Obs per group:
                                                                          min =          1
                                                                          avg =        2.8
                                                                          max =          4
                                                            Wald chi2(9)      =       8.87
            Log likelihood = -139.99249                     Prob > chi2       =     0.4495
            
            ----------------------------------------------------------------------------------
             Likert_Prot_Env | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
            -----------------+----------------------------------------------------------------
                  left_right |  -.0287363   .0240061    -1.20   0.231    -.0757874    .0183148
            post_materialist |   1.618777    1.27212     1.27   0.203    -.8745331    4.112087
                       mixed |   .0626609   .9784575     0.06   0.949    -1.855081    1.980403
                  middle_edu |   .7223386    1.27091     0.57   0.570      -1.7686    3.213277
                    high_edu |   1.101671   1.348247     0.82   0.414    -1.540844    3.744187
               middle_income |   .5245141   .9711757     0.54   0.589    -1.378955    2.427984
                 high_income |   1.616273   .9257947     1.75   0.081    -.1982511    3.430797
                         age |   .0612115   .2837082     0.22   0.829    -.4948463    .6172694
                      gender |   .4261422   .9052592     0.47   0.638    -1.348133    2.200417
                       _cons |    6.27604   2.551256     2.46   0.014      1.27567    11.27641
            ----------------------------------------------------------------------------------
            
            ------------------------------------------------------------------------------
              Random-effects parameters  |   Estimate   Std. err.     [95% conf. interval]
            -----------------------------+------------------------------------------------
            encCountry: Identity         |
                              var(_cons) |   2.347904   1.818804       .514395    10.71677
            -----------------------------+------------------------------------------------
                           var(Residual) |   6.863243   1.673667      4.255551    11.06886
            ------------------------------------------------------------------------------
            LR test vs. linear model: chibar2(01) = 2.27          Prob >= chibar2 = 0.0659
            Note how this model is not-significant (Prob > chi2 =0.4495), essentially just random noise. Now to the comparable -xtreg, mle random effect model.

            Code:
            . xtset encCountry
            
            Panel variable: encCountry (balanced)
            
            . xtreg Likert_Prot_Env left_right post_materialist mixed middle_edu high_edu middle_income high_income age gender, mle
            
            Fitting constant-only model:
            Iteration 0:   log likelihood = -144.10766
            Iteration 1:   log likelihood = -144.09035
            Iteration 2:   log likelihood = -144.09034
            
            Fitting full model:
            Iteration 0:   log likelihood = -141.31959
            Iteration 1:   log likelihood = -140.55399
            Iteration 2:   log likelihood =  -140.0947
            Iteration 3:   log likelihood = -139.99325
            Iteration 4:   log likelihood = -139.99249
            Iteration 5:   log likelihood = -139.99249
            
            Random-effects ML regression                         Number of obs    =     56
            Group variable: encCountry                           Number of groups =     20
            
            Random effects u_i ~ Gaussian                        Obs per group:
                                                                              min =      1
                                                                              avg =    2.8
                                                                              max =      4
            
                                                                 LR chi2(9)       =   8.20
            Log likelihood = -139.99249                          Prob > chi2      = 0.5146
            
            ----------------------------------------------------------------------------------
             Likert_Prot_Env | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
            -----------------+----------------------------------------------------------------
                  left_right |  -.0287363    .026459    -1.09   0.277     -.080595    .0231224
            post_materialist |   1.618777    1.27223     1.27   0.203    -.8747481    4.112302
                       mixed |   .0626609   .9822104     0.06   0.949    -1.862436    1.987758
                  middle_edu |   .7223386   1.273088     0.57   0.570    -1.772867    3.217544
                    high_edu |   1.101671   1.349133     0.82   0.414    -1.542582    3.745924
               middle_income |   .5245141   .9713213     0.54   0.589    -1.379241    2.428269
                 high_income |   1.616273   .9278521     1.74   0.082    -.2022837     3.43483
                         age |   .0612115   .2838473     0.22   0.829     -.495119    .6175421
                      gender |   .4261422   .9062708     0.47   0.638    -1.350116      2.2024
                       _cons |    6.27604    2.55131     2.46   0.014     1.275565    11.27651
            -----------------+----------------------------------------------------------------
                    /sigma_u |   1.532287   .5934933                      .7172134    3.273647
                    /sigma_e |   2.619779    .319429                      2.062899     3.32699
                         rho |   .2548981   .1719516                       .043733    .6519567
            ----------------------------------------------------------------------------------
            LR test of sigma_u=0: chibar2(01) = 2.27               Prob >= chibar2 = 0.066
            Note how the results are identical, yet this model is still not significant (Prob > chi2 = 0.5146). Here is the result of a gls random effect model. Typically, these results are very similar to those from an -xtreg, mle regression, but I suspect since these models are not significant then the coefficients from the random noise being modeled are not stable.

            Code:
            . xtreg Likert_Prot_Env left_right post_materialist mixed middle_edu high_edu middle_income high_income age gender, re
            
            Random-effects GLS regression                   Number of obs     =         56
            Group variable: encCountry                      Number of groups  =         20
            
            R-squared:                                      Obs per group:
                 Within  = 0.0942                                         min =          1
                 Between = 0.3931                                         avg =        2.8
                 Overall = 0.1474                                         max =          4
            
                                                            Wald chi2(9)      =       7.52
            corr(u_i, X) = 0 (assumed)                      Prob > chi2       =     0.5832
            
            ----------------------------------------------------------------------------------
             Likert_Prot_Env | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
            -----------------+----------------------------------------------------------------
                  left_right |  -.0349515   .0270869    -1.29   0.197    -.0880409    .0181379
            post_materialist |   1.608542   1.417256     1.13   0.256    -1.169228    4.386312
                       mixed |   .1136099   1.086248     0.10   0.917    -2.015398    2.242618
                  middle_edu |   .6776388   1.413766     0.48   0.632    -2.093291    3.448569
                    high_edu |   1.119278   1.496937     0.75   0.455    -1.814664     4.05322
               middle_income |   .5153663   1.097487     0.47   0.639    -1.635669    2.666402
                 high_income |   1.650008   1.050506     1.57   0.116    -.4089457    3.708962
                         age |   .0659314   .3149758     0.21   0.834    -.5514097    .6832725
                      gender |   .4018984   1.001593     0.40   0.688    -1.561188    2.364985
                       _cons |   6.291196   2.825679     2.23   0.026     .7529674    11.82943
            -----------------+----------------------------------------------------------------
                     sigma_u |  1.3325282
                     sigma_e |   2.972652
                         rho |  .16731838   (fraction of variance due to u_i)
            ----------------------------------------------------------------------------------
            
            . estimates store re
            Last, here is the fixed effect model with the associated Hausman test. Note for the Hausman command, you need to include the consistent estimate first (fixed effect), followed by the efficient estimate (random effect).

            Code:
            . xtreg Likert_Prot_Env left_right post_materialist mixed middle_edu high_edu middle_income high_income age gender, fe
            
            Fixed-effects (within) regression               Number of obs     =         56
            Group variable: encCountry                      Number of groups  =         20
            
            R-squared:                                      Obs per group:
                 Within  = 0.1252                                         min =          1
                 Between = 0.1500                                         avg =        2.8
                 Overall = 0.0800                                         max =          4
            
                                                            F(9,27)           =       0.43
            corr(u_i, Xb) = -0.0246                         Prob > F          =     0.9073
            
            ----------------------------------------------------------------------------------
             Likert_Prot_Env | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
            -----------------+----------------------------------------------------------------
                  left_right |  -.0003824    .029903    -0.01   0.990    -.0617382    .0609734
            post_materialist |   1.599884    1.75132     0.91   0.369    -1.993528    5.193297
                       mixed |  -.1550012   1.331419    -0.12   0.908    -2.886848    2.576846
                  middle_edu |   .8216253   1.807823     0.45   0.653     -2.88772    4.530971
                    high_edu |   .7097497   1.923032     0.37   0.715    -3.235987    4.655486
               middle_income |   .5793292   1.245656     0.47   0.646    -1.976545    3.135204
                 high_income |   1.416785   1.146825     1.24   0.227    -.9363048    3.769875
                         age |    .020078   .4091091     0.05   0.961    -.8193444    .8595005
                      gender |    .503069   1.285108     0.39   0.699    -2.133754    3.139892
                       _cons |   6.398284   3.499097     1.83   0.079    -.7812707    13.57784
            -----------------+----------------------------------------------------------------
                     sigma_u |  2.4549786
                     sigma_e |   2.972652
                         rho |  .40548239   (fraction of variance due to u_i)
            ----------------------------------------------------------------------------------
            F test that all u_i=0: F(19, 27) = 1.60                      Prob > F = 0.1298
            
            . estimates store fe
            
            . hausman fe re
            
                             ---- Coefficients ----
                         |      (b)          (B)            (b-B)     sqrt(diag(V_b-V_B))
                         |       fe           re         Difference       Std. err.
            -------------+----------------------------------------------------------------
              left_right |   -.0003824    -.0349515        .0345691        .0126683
            post_mater~t |    1.599884     1.608542       -.0086577        1.028839
                   mixed |   -.1550012     .1136099       -.2686111        .7698973
              middle_edu |    .8216253     .6776388        .1439865        1.126716
                high_edu |    .7097497     1.119278       -.4095284        1.207159
            middle_inc~e |    .5793292     .5153663        .0639629          .58922
             high_income |    1.416785     1.650008       -.2332234        .4600476
                     age |     .020078     .0659314       -.0458534        .2610757
                  gender |     .503069     .4018984        .1011705        .8051789
            ------------------------------------------------------------------------------
                                      b = Consistent under H0 and Ha; obtained from xtreg.
                       B = Inconsistent under Ha, efficient under H0; obtained from xtreg.
            
            Test of H0: Difference in coefficients not systematic
            
                chi2(9) = (b-B)'[(V_b-V_B)^(-1)](b-B)
                        =  12.83
            Prob > chi2 = 0.1706
            
            .
            The Hausman test for these two models (neither of which can be trusted/used since neither are significant) would indicate that it is fine to use random effects as the coefficients are not statistically different from those found using a fixed effect model. In this case, it is because the coefficients are so consistently insignificant.

            Comment


            • #7
              Hi again and thanks for the reply. Can you explain why you excluded WID_gini_NI from the models?

              Comment


              • #8
                Hausman test is based on the coefficients of variables in both models. If additional variables are in one of the models, they will not be considered, yet their impact on the other coefficients in that model is still in play. Since you were interested in the Hausman test between fixed and random effects, I excluded the variables with no within-entity variation as they are collinear in a fixed effect model and drop out. You can include the time invariant variables if you want, and compare the models.
                A few other comments:
                1. Trying to understand the statistical differences between different models is difficult if none of the models fit the data. Please find a more appropriate dataset to use.
                2. This dataset has 80 observations, yet only uses 52 due to missing data. This leads to a singleton problem as one of your encCountry has only 1 observation, and 5 only have 2 observations. This creates problems as noted in 1.
                3. While the Hausman test is often considered a 'gold standard' in choosing between fixed and random effects, I would argue that the decision should be based on what model specification most appropriately addresses the research question. As the title in the post indicates random slopes, perhaps that is what you are really interested in examining. I am unaware of a Hausman test comparison for a random slope model, perhaps there is one. There are however tests to verify that random slopes (as well as intercepts) are different from 0.

                Good luck

                Comment


                • #9
                  Originally posted by JJ Kovach View Post
                  yet their impact on the other coefficients in that model is still in play
                  This would be my exact problem here. I want to include the time invariant variable in my random effects/mixed model since I assume it will have an effect on the coefficients of the other variables that are also included in the fe model. But this doesn't seem to be possible with the , re command, which is why I am using mixed instead. And here I am stuck, because Stata in many cases is not able to calculate the hausman test for mixed in comparison with , fe. So if you know how to calculate hausman when the random/mixed model includes a time invariant variable, it would help me massively!

                  1. Trying to understand the statistical differences between different models is difficult if none of the models fit the data. Please find a more appropriate dataset to use.
                  2. This dataset has 80 observations, yet only uses 52 due to missing data. This leads to a singleton problem as one of your encCountry has only 1 observation, and 5 only have 2 observations. This creates problems as noted in 1.
                  I think, with these two points you are referring to the data example, I provided, right? It really seems like it is not very useful to only provide 100 observations (or even less) to enable someone to recalculate such a mixed model. I reckon, a lot more observations are necessary. Unfortunately, I wasn't able to attach the full dataset. Maybe because the file is too large. Can you tell me, if there is any other possibility how I can attach a longer data example without creating a post that is 2 meters long?

                  Thank you very much again!


                  Comment


                  • #10
                    But this doesn't seem to be possible with the , re command
                    Have you tried? Works just fine. Time-invariant variables can be incorporated in a random-effect model, then compared to a fixed-effect model using the Hausman test for the time-variant variables (as the time-invariant variables would not be present in the fixed-effect model and thus excluded from the Hausman test). Again though, the Hausman test in this application is simply going to tell you if the between-effects are statistically similar to the within-effects. Note that a random-effect model combines the between and within effects into a single coefficient. If the random-effect coefficient is statistically similar to the fixed-effect coefficient, then a random-effect model and a fixed-effect model will yield similar coefficients, thus either can be used. If the Hausman test is statistically significant, it means the coefficients are different such that the between-entity effects are different from the within-entity effects. If this is the case, then using a random-effect model to examine within-entity effects is not appropriate, as it is polluted by the between-entity effects which are different.

                    Can you tell me, if there is any other possibility how I can attach a longer data example
                    Have you tried one of the Stata-provided data sets? perhaps

                    Code:
                    use https://www.stata-press.com/data/r18/nlswork.dta
                    Or others may be more appropriate for your setting to build examples to experiment with.

                    Comment

                    Working...
                    X