Announcement

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

  • Non convergence of melogit

    Dear all,

    I am having some trouble running a multi-level logistic regression on my dataset. I am using stata 15.1 and the melogit command. My dataset consists of 615 patients (MRN) with 1'050 observations. Each patients had his bone density (NECK_BMD) and his fracture status (hip) measured multiple times. I am trying to run a multi-level logistic regression in order to see if bone density predicts fracture status.

    My code is the following:
    Code:
    melogit hip NECK_BMD || MRN:
    It seemed pretty straightforward but unfortunately the model does not converge even after a few hundreds iterations. Some iterations are indicated as non concave.

    I tried with the meqrlogit as follows:
    Code:
    meqrlogit hip NECK_BMD || MRN:
    . Here stata tells me: "Initial values not feasible".

    Could it be a rare event problem as my dependent variable hip has 49 "1" and 1'001 "0"...


    Thanks a lot for your help colleagues.


    David J




  • #2
    It may well be a rare event problem.

    But there are a few things you can try before giving up.

    1. Do a 1-level logit and use the coefficients from that as starting values for -melogit- and -meqrlogit- in the -from()- option.

    2. Try -xtlogit, re-. Since your model is only two levels, this will give you yet a third attempt to estimate the very same model.

    Comment


    • #3
      Thank you Clyde,

      Well as a new member here, I have to say it is really fascinating to get inputs from knowledgeable experts so quickly!

      Regarding my problem and your advices:

      1. Are you referring to the following?
      Code:
      logit hip NECK_BMD
      matrix b1=e(b)
      melogit hip NECK_BMD || MRN:, from(b1)
      If yes, then this seems to provide the same result as follows:
      Code:
       melogit hip NECK_BMD || MRN:, from(b1)
      
      Fitting fixed-effects model:
      
      Iteration 0:   log likelihood = -216.22445  
      Iteration 1:   log likelihood = -193.31742  
      Iteration 2:   log likelihood =  -192.8179  
      Iteration 3:   log likelihood = -192.81481  
      Iteration 4:   log likelihood = -192.81481  
      
      Refining starting values:
      
      Grid node 0:   log likelihood = -177.02026
      
      Fitting full model:
      
      Iteration 0:   log likelihood = -177.02026  
      Iteration 1:   log likelihood = -151.69781  
      Iteration 2:   log likelihood = -142.50958  
      Iteration 3:   log likelihood = -136.12992  (not concave)
      Iteration 4:   log likelihood = -137.83233  (not concave)
      Iteration 5:   log likelihood =  -139.2216  (not concave)
      Iteration 6:   log likelihood = -141.75031  (not concave)
      Iteration 7:   log likelihood = -142.85161  (not concave)
      Iteration 8:   log likelihood = -144.81176  (not concave)
      Iteration 9:   log likelihood = -136.97946  (not concave)
      Iteration 10:  log likelihood = -137.69679  (not concave)
      Iteration 11:  log likelihood =  -137.8033  
      --Break--
      For some reason, the equivalent command with meqrlogit does not work:
      Code:
      . meqrlogit hip NECK_BMD || MRN:, from(b1)
      extra parameter hip:NECK_BMD found
      specify skip option if necessary
      r(111);


      2. Regarding your second suggestion, I am not sure of to use xtlogit. Specifically, I could not find of to specify the grouping variable with the re option.

      Is it like this?
      Code:
      xtset MRN
      xtlogit hip NECK_BMD ,re
      If it is, it converges after 11 iterations (although some are designed as not concave):

      Code:
      Random-effects logistic regression              Number of obs     =      1,050
      Group variable: MRN                             Number of groups  =        615
      
      Random effects u_i ~ Gaussian                   Obs per group:
                                                                    min =          1
                                                                    avg =        1.7
                                                                    max =          8
      
      Integration method: mvaghermite                 Integration pts.  =         12
      
                                                      Wald chi2(1)      =      13.55
      Log likelihood  = -129.08839                    Prob > chi2       =     0.0002
      
      ------------------------------------------------------------------------------
               hip |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
          NECK_BMD |  -9.277258   2.520705    -3.68   0.000    -14.21775   -4.336767
             _cons |  -3.490505   1.641277    -2.13   0.033    -6.707349   -.2736604
      -------------+----------------------------------------------------------------
          /lnsig2u |   3.518823   .1248423                      3.274136    3.763509
      -------------+----------------------------------------------------------------
           sigma_u |   5.809017   .3626056                      5.140077    6.565013
               rho |   .9111676   .0101049                      .8892683    .9290813
      ------------------------------------------------------------------------------
      LR test of rho=0: chibar2(01) = 127.45                 Prob >= chibar2 = 0.000

      Does it help to narrow the problem in some way?

      Comment


      • #4
        1. So yes, it would be -meqrlogit hip NECK_BMD || MRN:, from(b1, skip)-.

        2. Yes, that's exactly it, and it converged! So you have your solution. It does not matter if some iterations along the way are "not concave," so long as it doesn't say that at the final iteration.

        Comment


        • #5
          Ok that is brilliant!

          Well, I won't even try to understand why an algorithm struggles with convergences while another deals with this dataset without trouble but hey... it indeed solved my problem!



          Thanks a lot Clyde.

          Best regards

          david

          Comment


          • #6
            Originally posted by David Jaques View Post
            Ok that is brilliant!

            Well, I won't even try to understand why an algorithm struggles with convergences while another deals with this dataset without trouble but hey... it indeed solved my problem!



            Thanks a lot Clyde.

            Best regards

            david
            Hello, I encounter the similar problem.
            Very insightful!
            Last edited by Fred Lee; 13 Oct 2020, 00:34.

            Comment


            • #7
              Originally posted by Clyde Schechter View Post
              1. So yes, it would be -meqrlogit hip NECK_BMD || MRN:, from(b1, skip)-.

              2. Yes, that's exactly it, and it converged! So you have your solution. It does not matter if some iterations along the way are "not concave," so long as it doesn't say that at the final iteration.
              If the nonconvergence happens for mixed models, how to solve that? The from option is not valid for mixed command.
              Thanks a lot!

              Comment


              • #8
                My recommendation is

                1. Find the place in the iteration log where the log-likelihood stopped progressing. Then rerun the command adding the -iterate(#)- option (where # is just a little larger than the iteration number at which Stata got stuck). Stata will then go to that iteration and stop, showing interim results. Examine the output for variables whose standard errors or coefficients are missing or unreasonably large or small. (Often it is one of the random effects--if an actual variance component is zero or negative, you will see an estimate that is very close to zero, but the algorithm can never converge to zero or a negative value.) Then, check the data to see if there is something wrong with that variable. If so, fix the data; if not, remove that variable (those variables) from the model and try again.

                2. If the interim output generating in step 1 does not point towards any particular variables as the source of the problem, start over. Use a very simple model: just a single predictor, and only one random effects level. Start with the ones that are, from a scientific perspective, the most important. Then add in more variables or levels, one at a time, to build the model that is closest to your original desire, but still converges.

                Comment


                • #9
                  Originally posted by Clyde Schechter View Post
                  My recommendation is

                  1. Find the place in the iteration log where the log-likelihood stopped progressing. Then rerun the command adding the -iterate(#)- option (where # is just a little larger than the iteration number at which Stata got stuck). Stata will then go to that iteration and stop, showing interim results. Examine the output for variables whose standard errors or coefficients are missing or unreasonably large or small. (Often it is one of the random effects--if an actual variance component is zero or negative, you will see an estimate that is very close to zero, but the algorithm can never converge to zero or a negative value.) Then, check the data to see if there is something wrong with that variable. If so, fix the data; if not, remove that variable (those variables) from the model and try again.

                  2. If the interim output generating in step 1 does not point towards any particular variables as the source of the problem, start over. Use a very simple model: just a single predictor, and only one random effects level. Start with the ones that are, from a scientific perspective, the most important. Then add in more variables or levels, one at a time, to build the model that is closest to your original desire, but still converges.
                  Thanks, I will try!

                  Comment

                  Working...
                  X