Announcement

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

  • Why is my margins command taking too long after melogit?

    Hello,

    I have finalized a two-level logit model with melogit using Stata 15. The model has fixed effects at both levels and interactions but has no random effects. When I run my margins command, it is just taking too long. I ran a simple margins command which worked but the one that I really want is taking too long (hours)
    Code:
    melogit im i.matgr##i.anc  i.matgr##i.wlth i.matgr##i.rel  c.pc_A_c c.pc_B_c c.pc_C_c [pweight=pwt1]||SID:, cov(unstruct) from (a) vce(cluster SID)
    margins matgr, vsquish post vce(unconditional)
    * worked 
    margins , dydx(matgr##anc) at (wlth=(0 1 2 3 4)) vsquish post vce(unconditional)
    margins , dydx(matgr##anc) atmeans(c) at(wlth=(0 1 2 3 4) rel=2 rural=0) vsquish post vce(unconditional)
    The above is just one of the commands I want to get the results for. I have tried several different ones. I thought that maybe the second margins command is asking too much so decided to fix some parameters in my third command but it has not helped so far. I understand that this being a multilevel model, margins will take more time but I am not sure how much time it should take.

    I am now wondering if there is an error in my command. If not, is there some way to make this faster? I will really appreciate any understanding on this issue.

    Thank you
    Deepali Godha

  • #2
    Please ignore the above post. It just takes time.
    Deepali Godha

    Comment


    • #3
      If you can live without the standard errors, the nose option may speed things up.
      -------------------------------------------
      Richard Williams, Notre Dame Dept of Sociology
      StataNow Version: 19.5 MP (2 processor)

      EMAIL: [email protected]
      WWW: https://www3.nd.edu/~rwilliam

      Comment


      • #4
        Thanks Richard- very helpful advice. Though I still need my CIs, it helps to get a quick insight.
        Deepali Godha

        Comment


        • #5
          Deepali, it's not just meologit. Margins also runs slowly after latent class analysis. My guess is that when there are any sort of random effects involved, they take a longer time to produce standard errors. In your case, I can see you only have a random intercept, but you are asking for margins at quite a few different levels of -at-. Also, in your command as typed, you asked for unstructured covariance between random effects, and if you had more than one random effect, I bet that takes a lot of time as well (NB: in your command as typed, there's only a random intercept, so is unstructured covariance applicable?)

          In latent class analysis, I am guessing that margins has to repeat its calculations over each latent class, which is what slows things down. My last margins command with 6 classes took maybe 30 minutes to run, which is not as slow as yours, but is still quite some time.
          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


          • #6
            Hmmm... That makes sense. Thanks for the detailed explanation Weiwen. I did get that standard errors were the main culprit behind, given that Richard's advice worked beautifully- but this helps in clarifying concepts. As for the unstructured variance, thanks for pointing that out. I just left it there from my previous commands- makes sense to remove it.
            Deepali Godha

            Comment

            Working...
            X