Announcement

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

  • svy: melogit mixed effect fails to converge; melogit mixed effect converges

    Hello Statalist,

    I tried searching the forum boards/internet and could not find a thread that solved my issue, nor one that appeared to point me to a source to investigate further. I'm still looking at the time of writing this as well. Any help would be greatly appreciated.

    Data background
    Looking at an outcome variable that is binary (0 n=150; 1 n=1,365) and have 2 time points (2016 and 2017) as well as demographics (age, sex, and education level). The data is in long form.

    Analysis
    Looking to see the effect of being in the program for a year on the outcome variable adjusted for the demographics. Using a mixed effects logistic regression with random intercept at the participant level.

    Issue
    Model fails to converge with -svy- prefix; the following code fails:

    Code:
    svy: melogit trytoquit i.yr_dummy, or || respondentid:
    with the following error:
    r(403);
    convergence not achieved
    an error occurred when svy executed melogit


    Attempted the model without the -svy- prefix and it runs just fine; the following code does work:

    Code:
    melogit trytoquit i.yr_dummy, or || respondentid:


    I apologize in advance if I did not include any information that would help diagnose the issue. I also would like to thank you all in advance for any help and advice.

    Best,

    Corey

  • #2
    As you know, in survey estimation, each observation has a different probability of selection, so you weight them by the inverse of the selection probability. This makes everything a bit more complicated.

    It's hard to explain in English why certain models have trouble converging. One thing that can happen is where the variance of the random intercept gets very close to zero. When you ran the model in unimputed data, what was the variance of the random effect? Or, when you ran -svy: melogit...-, I think it will still spit out estimated parameters even if it didn't converge. While those parameters aren't valid, what was the estimate of the variance of the random effect? If it was too close to zero (e.g. 1 * 10^-15 or within a few orders of magnitude of that), then maybe that's the problem. Otherwise, in general, simplifying your model if it's complex can help, but that looks like it might not be the problem.

    You can try saving the parameters from your non-svy -melogit- command, and then fitting -svy: melogit- from those parameters as start values. This can sometimes help the maximizer find its way to the correct solution.

    Code:
    melogit trytoquit i.yr_dummy, or || respondentid:
    matrix b = e(b)
    svy: melogit trytoquit i.yr_dummy, or || respondentid:, from(b)
    Note: I don't normally work with survey data, and while this should work, I'm not 100% certain it will.

    Side note: Outside of the survey context, you should note the alternative command -meqrlogit-, which is just (I think) a different estimator for the same problem that can sometimes alleviate convergence trouble. Problem is, this command doesn't allow the -svy- prefix.
    Be aware that it can be very hard to answer a question without sample data. You can use the dataex command for this. Type help dataex at the command line.

    When presenting code or results, please use the code delimiters format them. Use the # button on the formatting toolbar, between the " (double quote) and <> buttons.

    Comment


    • #3
      Hey Weiwen,

      Thanks for your note. Unfortunately it does not produce any output for myself since the model does not converge; I have seen it produce output for others on this forum when there was no convergence though. Maybe it has to do with my version of Stata (15.1).

      The current model I'm troubleshooting with is as simplistic as it can be, 1 binary DV (trytoquit) and 1 categorical IV with 2 levels (yr_dummy). I did also try running the model without yr_dummy and the outcome was the same (no convergence and no output).

      I appreciate the example/test code that you provided, unfortunately the outcome was also the same.

      I am still looking, and appreciate the help.

      Best,

      Corey

      Comment


      • #4
        All who come across this and Weiwen,

        I wanted to update, I still haven't found the cause or a work around method that works for this particular model in the thread. I would put up the data, but I cannot due to contractual reasons.

        I would like to note that I encountered another model that also failed to converge using the -svy- prefix; however for this second model with convergence failure, the method that Weiwen proposed worked.

        Comment


        • #5

          melogit also has integration options and many options for the optimizing the quasi-likelihood. For a start, try the difficult option in addition to Weiwen's suggestion.
          Last edited by Steve Samuels; 07 Sep 2018, 12:40.
          Steve Samuels
          Statistical Consulting
          [email protected]

          Stata 14.2

          Comment


          • #6
            Originally posted by Corey Bryant View Post
            All who come across this and Weiwen,

            I wanted to update, I still haven't found the cause or a work around method that works for this particular model in the thread. I would put up the data, but I cannot due to contractual reasons.

            I would like to note that I encountered another model that also failed to converge using the -svy- prefix; however for this second model with convergence failure, the method that Weiwen proposed worked.
            I forgot to ask earlier: is there any iteration log at all? Or do you just immediately get a message about non-convergence? If you have an iteration log, then its likely that messing with the integration options will help. As Steve stated, the difficult option (which you can just add to your code) can help if you were stuck in a non-concave region. You can also experiment with maximization techniques other than the default, as detailed in the manual for likelihood maximization. For example,

            Code:
            svy: melogit trytoquit i.yr_dummy || respondentid:, or difficult
            svy: melogit trytoquit i.yr_dummy || respondentid:, or method(bhhh)
            Also, there's a non-zero chance that the issue could be in how you -svyset- your data. It might be worth confirming if you did so correctly. I'm totally unfamiliar with how survey settings interface with multilevel models. There's a chance you may need to contact Stata support if that's the case; it would help them if you gave a log file with your svyset command as well. If you don't know how to do log files, an example is:

            Code:
            cd "(some directory path, e.g. My Documents")
            log using svy_melogit
            svyset respondentid [pweight = pweight1], strata(stratum)
            svy: melogit trytoquit i.yr_dummy || respondentid:, or
            log close
            Then, you'll have a file called svy_melogit.smcl in your directory.
            Be aware that it can be very hard to answer a question without sample data. You can use the dataex command for this. Type help dataex at the command line.

            When presenting code or results, please use the code delimiters format them. Use the # button on the formatting toolbar, between the " (double quote) and <> buttons.

            Comment


            • #7
              Hey everyone,

              First I'd like to apologize for taking so long to respond to this post. Thank you for all the help and specifically Weiwen for pointing me to the manual for likelihood maximization where I was able to find my solution.

              The solution that worked for myself used a combination of maximization methods for varying number of iterations. This helped get through the non-concave regions. The code that worked is below.

              Code:
              svy: melogit trytoquit i.yr_dummy ||respondentid:, or technique(bhhh 10 nr 5 dfp 10)
              The number after the technique indicates to Stata to switch to the next method after X number of iterations, once Stata uses all the methods stated for the stated number of iterations it cycles back through the list until convergence is reached.


              Thanks again everybody,

              Corey

              Comment

              Working...
              X