Announcement

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

  • -margins- after -melogit-

    I'm experiencing a problem with -margins- after -melogit-. When I ask for -margins A#B-, Stata responds with the output appropriate for -margins A B-, that is, separate margins for A and B variables, but nothing for the combinations thereof.

    Code:
    . webuse nlswork, clear
    (National Longitudinal Survey.  Young Women 14-26 years of age in 1968)
    
    . melogit union i.nev_mar##i.collgrad || idcode:
    
    Fitting fixed-effects model:
    
    Iteration 0:   log likelihood = -10441.017  
    Iteration 1:   log likelihood = -10422.908  
    Iteration 2:   log likelihood = -10422.892  
    Iteration 3:   log likelihood = -10422.892  
    
    Refining starting values:
    
    Grid node 0:   log likelihood = -8696.0695
    
    Fitting full model:
    
    Iteration 0:   log likelihood = -8696.0695  
    Iteration 1:   log likelihood = -8039.0834  
    Iteration 2:   log likelihood =   -7882.09  
    Iteration 3:   log likelihood = -7858.7862  
    Iteration 4:   log likelihood = -7858.2813  
    Iteration 5:   log likelihood = -7858.2803  
    Iteration 6:   log likelihood = -7858.2815  
    Iteration 7:   log likelihood = -7858.2822  
    
    Mixed-effects logistic regression               Number of obs     =     19,227
    Group variable:          idcode                 Number of groups  =      4,150
    
                                                    Obs per group:
                                                                  min =          1
                                                                  avg =        4.6
                                                                  max =         12
    
    Integration method: mvaghermite                 Integration pts.  =          7
    
                                                    Wald chi2(3)      =      50.71
    Log likelihood = -7858.2822                     Prob > chi2       =     0.0000
    ----------------------------------------------------------------------------------
               union |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -----------------+----------------------------------------------------------------
           1.nev_mar |   .1612591   .1059014     1.52   0.128    -.0463039     .368822
          1.collgrad |   .9411026   .1342232     7.01   0.000       .67803    1.204175
                     |
    nev_mar#collgrad |
                1 1  |  -.3990216   .2271745    -1.76   0.079    -.8442754    .0462322
                     |
               _cons |  -2.804856   .0815507   -34.39   0.000    -2.964692   -2.645019
    -----------------+----------------------------------------------------------------
    idcode           |
           var(_cons)|   8.429619   .5000171                      7.504426    9.468875
    ----------------------------------------------------------------------------------
    LR test vs. logistic model: chibar2(01) = 5129.22     Prob >= chibar2 = 0.0000
    
    . margins nev_mar#collgrad
    
    Predictive margins                              Number of obs     =     19,227
    Model VCE    : OIM
    
    Expression   : Marginal predicted mean, predict()
    
    ------------------------------------------------------------------------------
                 |            Delta-method
                 |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
         nev_mar |
              0  |   .2251414   .0046998    47.90   0.000     .2159299    .2343529
              1  |   .2316429   .0076755    30.18   0.000     .2165991    .2466866
                 |
        collgrad |
              0  |   .2120307   .0049563    42.78   0.000     .2023166    .2217448
              1  |   .2855803   .0098943    28.86   0.000     .2661878    .3049727
    ------------------------------------------------------------------------------
    
    .
    This doesn't happen with -mixed-. I haven't tried any of the other -me- commands yet. It didn't used to happen with version 14.

    My setup is:

    Code:
    . about
    
    Stata/MP 15.0 for Windows (64-bit x86-64)
    Revision 29 Jun 2017
    Copyright 1985-2017 StataCorp LLC
    
    Total physical memory:     8269900 KB
    Available physical memory: 5062552 KB
    
    Single-user 2-core Stata perpetual license:
           Serial number:  REDACTED
             Licensed to:  Clyde Schechter
                           Albert Einstein College of Medicine
    
    . update query
    (contacting http://www.stata.com)
    
    Update status
        Last check for updates:  07 Jul 2017
        New update available:    none         (as of 07 Jul 2017)
        Current update level:    29 Jun 2017  (what's new)
    
    Possible actions
    
        Do nothing; all files are up to date.
    I can't see that I'm doing anything wrong. Can others reproduce this problem on their installations?

  • #2
    Hello Clyde,
    I cannot even get that far:
    Code:
    . webuse nlswork, clear
    (National Longitudinal Survey.  Young Women 14-26 years of age in 1968)
    
    . melogit union i.nev_mar##i.collgrad || idcode:
    
    Fitting fixed-effects model:
    
    Iteration 0:   log likelihood = -10441.017  
    Iteration 1:   log likelihood = -10422.908  
    Iteration 2:   log likelihood = -10422.892  
    Iteration 3:   log likelihood = -10422.892  
    
    Refining starting values:
    
    Grid node 0:   log likelihood = -8696.0695
    
    Fitting full model:
    
    Iteration 0:   log likelihood = -8696.0695  
    Iteration 1:   log likelihood = -8039.0834  
    Iteration 2:   log likelihood =   -7882.09  
    Iteration 3:   log likelihood = -7858.7862  
    Iteration 4:   log likelihood = -7858.2813  
    Iteration 5:   log likelihood = -7858.2803  
    Iteration 6:   log likelihood = -7858.2815  
    Iteration 7:   log likelihood = -7858.2822  
    
    Mixed-effects logistic regression               Number of obs     =     19,227
    Group variable:          idcode                 Number of groups  =      4,150
    
                                                    Obs per group:
                                                                  min =          1
                                                                  avg =        4.6
                                                                  max =         12
    
    Integration method: mvaghermite                 Integration pts.  =          7
    
                                                    Wald chi2(3)      =      50.71
    Log likelihood = -7858.2822                     Prob > chi2       =     0.0000
    ----------------------------------------------------------------------------------
               union |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -----------------+----------------------------------------------------------------
             nev_mar |
                  0  |          0  (base)
                  1  |   .1612591   .1059014     1.52   0.128    -.0463039     .368822
                     |
            collgrad |
                  0  |          0  (base)
                  1  |   .9411026   .1342232     7.01   0.000       .67803    1.204175
                     |
    nev_mar#collgrad |
                0 0  |          0  (base)
                0 1  |          0  (base)
                1 0  |          0  (base)
                1 1  |  -.3990216   .2271745    -1.76   0.079    -.8442754    .0462322
                     |
               _cons |  -2.804856   .0815507   -34.39   0.000    -2.964692   -2.645019
    -----------------+----------------------------------------------------------------
    idcode           |
           var(_cons)|   8.429619   .5000171                      7.504426    9.468875
    ----------------------------------------------------------------------------------
    LR test vs. logistic model: chibar2(01) = 5129.22     Prob >= chibar2 = 0.0000
    
    . margins nev_mar#collgrad
    could not calculate numerical derivatives -- discontinuous region with missing values encountered
    r(459);
    Code:
    Stata/IC 15.0 for Windows (64-bit x86-64)
    Revision 29 Jun 2017
    Copyright 1985-2017 StataCorp LLC
    
    Total physical memory:     8263816 KB
    Available physical memory: 3788244 KB
    
    Stata/IC 15.0 for Windows (64-bit x86-64)
    Revision 29 Jun 2017
    Copyright 1985-2017 StataCorp LLC
    
    Total physical memory:     8263816 KB
    Available physical memory: 3788244 KB
    
    Single-user Stata perpetual license:
           
    
    . update query
    (contacting http://www.stata.com)
    
    Update status
        Last check for updates:  08 Jul 2017
        New update available:    none         (as of 08 Jul 2017)
        Current update level:    29 Jun 2017  (what's new)
    
    Possible actions
    
        Do nothing; all files are up to date.
    Martyn

    Comment


    • #3
      Hi Clyde,

      Here is the output for margins from Stata.SE (14.2). The main model output is same as yours but clearly the 'margins' interaction contradict. I think Stata Corp people need to have a look at it:


      Code:
      melogit union i.nev_mar##i.collgrad || idcode:
      
      
      Mixed-effects logistic regression               Number of obs     =     19,227
      Group variable:          idcode                 Number of groups  =      4,150
      
                                                      Obs per group:
                                                                    min =          1
                                                                    avg =        4.6
                                                                    max =         12
      
      Integration method: mvaghermite                 Integration pts.  =          7
      
                                                      Wald chi2(3)      =      50.71
      Log likelihood = -7858.2822                     Prob > chi2       =     0.0000
      ----------------------------------------------------------------------------------
                 union |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
      -----------------+----------------------------------------------------------------
                       |
             1.nev_mar |   .1612591   .1059014     1.52   0.128    -.0463039     .368822
            1.collgrad |   .9411026   .1342232     7.01   0.000       .67803    1.204175
                       |
      nev_mar#collgrad |
                  1 1  |  -.3990216   .2271745    -1.76   0.079    -.8442754    .0462322
                       |
                 _cons |  -2.804856   .0815507   -34.39   0.000    -2.964692   -2.645019
      -----------------+----------------------------------------------------------------
      idcode           |
             var(_cons)|   8.429619   .5000171                      7.504426    9.468875
      ----------------------------------------------------------------------------------
      LR test vs. logistic model: chibar2(01) = 5129.22     Prob >= chibar2 = 0.0000
      
      /*Margins*/
      
       margins nev_mar#collgrad
      
      Adjusted predictions                            Number of obs     =     19,227
      Model VCE    : OIM
      
      Expression   : Marginal predicted mean, predict()
      
      ----------------------------------------------------------------------------------
                       |            Delta-method
                       |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
      -----------------+----------------------------------------------------------------
      nev_mar#collgrad |
                  0 0  |   .2094762   .0052294    40.06   0.000     .1992268    .2197255
                  0 1  |   .2896667   .0107121    27.04   0.000     .2686714    .3106619
                  1 0  |   .2226864   .0086199    25.83   0.000     .2057918     .239581
                  1 1  |   .2685346   .0167344    16.05   0.000     .2357357    .3013335
      ----------------------------------------------------------------------------------


      Roman

      Comment


      • #4
        Hi Clyde,
        Just wondering if this issue is sorted. I am facing the similar problem.
        melogit stpn i.pm_centile26 sex vacynpcv13 smoker if week==26 & actualperruntime>=18|| cluster: , vce(robust) nolog

        Mixed-effects logistic regression Number of obs = 437
        Group variable: cluster Number of groups = 16

        Obs per group:
        min = 1
        avg = 27.3
        max = 53

        Integration method: mvaghermite Integration pts. = 7

        Wald chi2(12) = 413.21
        Log pseudolikelihood = -165.61797 Prob > chi2 = 0.0000
        (Std. Err. adjusted for 16 clusters in cluster)
        ------------------------------------------------------------------------------
        | Robust
        stpn | Coef. Std. Err. z P>|z| [95% Conf. Interval]
        -------------+----------------------------------------------------------------
        |
        pm_centile26 |
        2 | .1963519 .4183176 0.47 0.639 -.6235356 1.016239
        3 | 2.076125 .7616225 2.73 0.006 .5833727 3.568878
        4 | .7694861 .5451704 1.41 0.158 -.2990282 1.838
        5 | 1.385389 .389097 3.56 0.000 .6227727 2.148005
        6 | 1.01557 .4163496 2.44 0.015 .1995394 1.8316
        7 | .7431474 .4297225 1.73 0.084 -.0990933 1.585388
        8 | 1.198104 .6095183 1.97 0.049 .0034698 2.392738
        9 | 1.394681 .4566441 3.05 0.002 .4996748 2.289687
        10 | 1.739653 .871677 2.00 0.046 .0311979 3.448109
        |
        sex | -.5470586 .36124 -1.51 0.130 -1.255076 .1609588
        vacynpcv13 | .2427846 1.260505 0.19 0.847 -2.22776 2.713329
        smoker | .0914405 .3799396 0.24 0.810 -.6532273 .8361084
        _cons | 1.490247 1.252858 1.19 0.234 -.9653099 3.945804
        -------------+----------------------------------------------------------------
        cluster |
        var(_cons)| 4.21e-34 1.17e-33 1.86e-36 9.55e-32
        ------------------------------------------------------------------------------

        .

        . margins pm_centile26
        could not calculate numerical derivatives -- discontinuous region with missing values encountere
        Last edited by Mukesh Kumar; 07 Sep 2017, 07:50.

        Comment


        • #5
          Clyde, that was fixed in the July 20th update:

          12. margins has the following fixes:
          . . .
          b. margins, when an interaction was specified in marginslist after dfactor, gsem, mecloglog, meglm, meintreg, melogit, menbreg, menl, meologit, meoprobit, mepoisson, meprobit,
          mestreg, metobit, mgarch, nl, nlsur, sem, spivregress, spregress, spxtregress, sspace, or ucm, produced margins for each factor variable separately instead of for the level
          combinations specified by the interactions. This has been fixed.


          What I don't understand is why your -update query- still leaves you with the June 29th update and not with anything later. By the way, there's a September 5th update now.

          Comment


          • #6
            Joseph, my original post predates the July 20th update. I did get that update when it came out, and for me the problem is now solved. (And I'm now running the September 5 update.)

            Mukesh, this is not related to the problem originally posted and would have better been done as a new thread. Be that as it may, you may have an easy way out. Looking at your -melogit- output, the cluster-level variance component is, for all practical purposes zero. So you can forget about the cluster level in your model and just do a plain -logit-. You may have better luck with -margins- following that.

            Comment


            • #7
              Thought the thread was contemporary and didn't notice the date, sorry.

              Comment

              Working...
              X