Announcement

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

  • Problem with -margins- after -xtlogit-

    Dear all,

    I estimate a panel Logit model on the covariates of transition from work into retirement (for a sample aged 50yo and over) using data from the SHARE survey (Survey of Health, Ageing and Retirement in Europe). Covariates include: one's risk of poverty in wave t-1, education, sex, age groups, equivalised household size, self-reported health status, work type, marital status, and extra working household member.

    I am using -margins- command after -xtlogit-, but Stata reports that it cannot estimate it for categorical variables such as sex, age groups, marital status and work type. Why this happens? Does someone know how, and if, this could be fixed?

    Thanks!

    Code:
    xtlogit trans $cov_pov_risk2 i.wave i.country if insample==1, vce(cl mergeid)
    note: 59.country != 0 predicts failure perfectly;
          59.country omitted and 18 obs not used.
    
    
    Fitting comparison model:
    
    Iteration 0:  Log pseudolikelihood =  -19819.09  
    Iteration 1:  Log pseudolikelihood = -11436.338  
    Iteration 2:  Log pseudolikelihood = -10233.414  
    Iteration 3:  Log pseudolikelihood = -10039.908  
    Iteration 4:  Log pseudolikelihood = -10034.707  
    Iteration 5:  Log pseudolikelihood = -10034.671  
    Iteration 6:  Log pseudolikelihood = -10034.671  
    
    Fitting full model:
    
    tau =  0.0    Log pseudolikelihood = -10034.671
    tau =  0.1    Log pseudolikelihood = -10035.455
    
    Iteration 0:  Log pseudolikelihood = -10035.455  
    Iteration 1:  Log pseudolikelihood =  -10033.58  
    Iteration 2:  Log pseudolikelihood = -10033.576  
    Iteration 3:  Log pseudolikelihood = -10033.576  
    
    Calculating robust standard errors ...
    
    Random-effects logistic regression                  Number of obs    =  41,108
    Group variable: panel                               Number of groups =  21,691
    
    Random effects u_i ~ Gaussian                       Obs per group:
                                                                     min =       1
                                                                     avg =     1.9
                                                                     max =       6
    
    Integration method: mvaghermite                     Integration pts. =      12
    
                                                        Wald chi2(44)    = 3775.88
    Log pseudolikelihood = -10033.576                   Prob > chi2      =  0.0000
    
                                             (Std. err. adjusted for 21,691 clusters in mergeid)
    --------------------------------------------------------------------------------------------
                               |               Robust
                         trans | Coefficient  std. err.      z    P>|z|     [95% conf. interval]
    ---------------------------+----------------------------------------------------------------
                  pov_risk_t_1 |   -.166522   .0554566    -3.00   0.003    -.2752149   -.0578291
                          educ |  -.0480365   .0051522    -9.32   0.000    -.0581347   -.0379383
                          male |  -.0036535   .0403659    -0.09   0.928    -.0827692    .0754621
                               |
                       age_grp |
                      55-59yo  |   1.583443   .1441991    10.98   0.000     1.300818    1.866068
                      60-64yo  |   3.665995   .1458866    25.13   0.000     3.380062    3.951927
                      65-69yo  |    5.52666    .163362    33.83   0.000     5.206477    5.846844
                      70-74yo  |   5.521011   .1849095    29.86   0.000     5.158595    5.883426
                        75+yo  |   5.636382   .2081366    27.08   0.000     5.228442    6.044323
                               |
                 hhsize_eqh_sr |   -.688005   .0841462    -8.18   0.000    -.8529286   -.5230814
                    sphus_poor |   .2017044    .046549     4.33   0.000     .1104699    .2929388
                               |
                     work_type |
    2. Public sector employee  |  -.0362042   .0449182    -0.81   0.420    -.1242423    .0518339
             3. Self-employed  |  -.3962109   .0567451    -6.98   0.000    -.5074292   -.2849926
                               |
                marital_status |
             2. Never married  |   .5132168   .0761686     6.74   0.000     .3639292    .6625045
          3. Divorced/widowed  |   .6816849   .0563723    12.09   0.000     .5711973    .7921726
                               |
                   hhmemb_work |   3.681871   .0693236    53.11   0.000     3.545999    3.817743
                               |
                          wave |
             Wave 4 (2011/12)  |   .3374674   .0840367     4.02   0.000     .1727584    .5021764
                Wave 5 (2013)  |  -.5325465   .0808804    -6.58   0.000    -.6910691   -.3740239
                Wave 6 (2015)  |  -.7306933   .0770652    -9.48   0.000    -.8817383   -.5796483
             Wave 7 (2017/18)  |  -.7648985   .0768926    -9.95   0.000    -.9156052   -.6141918
             Wave 8 (2019/20)  |  -.6286996   .0854089    -7.36   0.000    -.7960979   -.4613014
                               |
                       country |
                      Germany  |  -1.132057   .1076993   -10.51   0.000    -1.343143   -.9209697
                       Sweden  |   -1.45545    .101693   -14.31   0.000    -1.654765   -1.256136
                  Netherlands  |   -1.05716   .2297129    -4.60   0.000    -1.507389   -.6069306
                        Spain  |  -1.180997   .1105569   -10.68   0.000    -1.397684   -.9643094
                        Italy  |  -.9605274   .1118705    -8.59   0.000    -1.179789   -.7412653
                       France  |  -.4165643   .1011144    -4.12   0.000    -.6147449   -.2183838
                      Denmark  |  -1.660126   .1037472   -16.00   0.000    -1.863466   -1.456785
                       Greece  |  -1.926768   .1433675   -13.44   0.000    -2.207763   -1.645773
                      Belgium  |  -.5056569   .0967097    -5.23   0.000    -.6952045   -.3161094
               Czech Republic  |   .0129918   .1045713     0.12   0.901    -.1919641    .2179477
                       Poland  |  -.4235347   .1624915    -2.61   0.009    -.7420123   -.1050572
                   Luxembourg  |    .796625    .164644     4.84   0.000     .4739288    1.119321
                      Hungary  |  -.2479898   .3837071    -0.65   0.518    -1.000042    .5040623
                     Portugal  |  -1.773635   .4457738    -3.98   0.000    -2.647336   -.8999345
                     Slovenia  |   .2080824   .1367434     1.52   0.128    -.0599297    .4760945
                      Estonia  |  -2.076609    .108053   -19.22   0.000    -2.288389   -1.864829
                      Croatia  |  -.9230151    .202877    -4.55   0.000    -1.320647   -.5253835
                    Lithuania  |  -1.530839   .3172675    -4.83   0.000    -2.152672   -.9090057
                     Bulgaria  |  -1.756475   .4795923    -3.66   0.000    -2.696459   -.8164917
                       Cyprus  |  -1.829712   .6442928    -2.84   0.005    -3.092503   -.5669214
                      Finland  |   -1.37054   .3897093    -3.52   0.000    -2.134356   -.6067239
                       Latvia  |  -2.485857   .6674459    -3.72   0.000    -3.794027   -1.177687
                        Malta  |          0  (empty)
                      Romania  |  -1.502531   .6942346    -2.16   0.030    -2.863206   -.1418559
                     Slovakia  |  -1.277278    .785677    -1.63   0.104    -2.817177    .2626202
                               |
                         _cons |  -2.592475   .2180242   -11.89   0.000    -3.019795   -2.165155
    ---------------------------+----------------------------------------------------------------
                      /lnsig2u |  -2.120559   .6699549                     -3.433647   -.8074715
    ---------------------------+----------------------------------------------------------------
                       sigma_u |    .346359   .1160225                      .1796359    .6678206
                           rho |   .0351819   .0227411                      .0097133    .1193795
    --------------------------------------------------------------------------------------------
    Code:
    margins, dydx(pov_risk_t_1 educ i.male i.age_grp hhsize_eqh_sr sphus_poor i.work_type i.marital_status hhmemb_work) post 
    
    Average marginal effects                                Number of obs = 11,875
    Model VCE: Bootstrap
    
    Expression: Pr(trans|fixed effect is 0), predict(pu0)
    dy/dx wrt:  pov_risk_t_1 educ 1.male 2.age_grp 3.age_grp 4.age_grp 5.age_grp 6.age_grp hhsize_eqh_sr sphus_poor 2.work_type 3.work_type 4.marital_status 5.marital_status hhmemb_work
    
    --------------------------------------------------------------------------------------------
                               |            Delta-method
                               |      dy/dx   std. err.      z    P>|z|     [95% conf. interval]
    ---------------------------+----------------------------------------------------------------
                  pov_risk_t_1 |   .0097081   .0068568     1.42   0.157    -.0037311    .0231472
                          educ |          0  (omitted)
                               |
                          male |
                         Male  |          .  (not estimable)
                               |
                       age_grp |
                      55-59yo  |          .  (not estimable)
                      60-64yo  |          .  (not estimable)
                      65-69yo  |          .  (not estimable)
                      70-74yo  |          .  (not estimable)
                        75+yo  |          .  (not estimable)
                               |
                 hhsize_eqh_sr |  -.1381772   .0353437    -3.91   0.000    -.2074496   -.0689047
                    sphus_poor |   .0029245    .006222     0.47   0.638    -.0092703    .0151193
                               |
                     work_type |
    2. Public sector employee  |          .  (not estimable)
             3. Self-employed  |          .  (not estimable)
                               |
                marital_status |
             2. Never married  |          .  (not estimable)
          3. Divorced/widowed  |          .  (not estimable)
                               |
                   hhmemb_work |   .2724671   .0771439     3.53   0.000     .1212678    .4236664
    --------------------------------------------------------------------------------------------
    Note: dy/dx for factor levels is the discrete change from the base level.

  • #2
    It would probably be helpful to show us the command that produced $cov_pov_risk2. However, I am channeling Joao Santos Silva and pointing you towards aextlogit given the known problems of uninterpretable marginal effects estimates from fixed effects logit models. See the helpful presentation as well.

    Comment


    • #3
      Originally posted by Erik Ruzek View Post
      It would probably be helpful to show us the command that produced $cov_pov_risk2. However, I am channeling Joao Santos Silva and pointing you towards aextlogit given the known problems of uninterpretable marginal effects estimates from fixed effects logit models. See the helpful presentation as well.
      Thank you for the suggestion to use -aextlogit-, Erik! I will try it out.

      My apologies, here is the command producing $cov_pov_risk2. I was careful to use i.variable always, apart for male. Could it be something wrong with how these categorical variables were created?

      Code:
      global cov_pov_risk2 pov_risk_t_1 educ male i.age_grp hhsize_eqh_sr sphus_poor i.work_type i.marital_status hhmemb_work

      Comment


      • #4
        It is unique to what you've done. I can get margins on dummy/cat variables using xtlogit without a problem.

        If all you're interested in is the margins, just use the LPM.

        Comment


        • #5
          Originally posted by George Ford View Post
          It is unique to what you've done. I can get margins on dummy/cat variables using xtlogit without a problem.

          If all you're interested in is the margins, just use the LPM.
          I have revised my code to recreate all dummies and categorical variables used in the regression and even changed the calculations in some instances. Still, -margins- after -xtlogit- do not calculate margins for the same variables mentioned in my post #3. I am not simply interested in the margins, but in comparing the models used (see my other post here) and how margins vary across them.

          Therefore, I would like to address this curious error in -margins- calculation. Please see below how each "faulty" variable is calculated. If anyone has any suggestions on how to make it work, please let me know.

          Code:
          generate agegrp=.
          replace agegrp=1 if 50<=age & age<55
          replace agegrp=2 if 55<=age & age<60
          replace agegrp=3 if 60<=age & age<65
          replace agegrp=4 if 65<=age & age<70
          replace agegrp=5 if 70<=age & age<75
          replace agegrp=6 if 75<=age
          
          gen work_type=ep009__w
          la var work_type "Type of work (private/public sector, self-employed)"
          la de work_type_val 1"1. Private sector employee" 2"2. Public sector employee" 3"3. Self-employed"
          
          gen marital_status0=marital_status 
          la var marital_status0 "Marital status"
          replace marital_status0=. if marital_status<0 //replace "no info", "don't know/refusal", and "implausible" as missing
          replace marital_status0=1 if marital_status==2 | marital_status==3 //Married or in partnership
          replace marital_status0=2 if marital_status==4 //Never married
          replace marital_status0=3 if marital_status==5 //Divorced or widowed
          la de marital_status0 1"1. Married/in partnership" 2"2. Never married" 3"3. Divorced/widowed"
          la values marital_status0 marital_status0
          la var married "Married dummy"
          drop marital_status 
          rename marital_status0 marital_status

          Comment


          • #6
            No obvious issues there.

            Without a dataex, I'll just toss some ideas out there.

            What's up with the error message related to 59.country?

            Run on a subset of countries (or one country), see if keeps doing it.

            Run:
            Code:
            margins, dydx(*) predict(pr)
            margins, dydx(*) predict(xb)

            Replicate the margins error with a small subset of the data and then dataex that portion of the data.

            Also see
            HTML Code:
            https://www.statalist.org/forums/forum/general-stata-discussion/general/1304704-cannot-estimate-marginal-effect-after-xtlogit
            https://www.statalist.org/forums/forum/general-stata-discussion/general/1410365-margins-after-xtlogit-re

            Comment

            Working...
            X