Announcement

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

  • predicted probabilities and caterpillar (ie residual) plots after bayes: melogit

    Hello,

    I am trying to obtain a caterpillar plot of group-level residuals and group-level predicted probabilities generated from a multilevel logistic model. For context, I have individuals at level 1 nested within groups at level 2, and I am using the "bayes: melogit".

    Code:
    bayes, prior({outcome:_cons}, flat): melogit outcome || group:, cov(un) 
    bayes, showreffects({U0[1/16]}) 
    
    egen pickone = tag(group)
    generate pred_prob = invlogit({outcome:_cons} + {U0[group]})  
    list group pred_prob if pickone==1
    However, I keep getting an error that says the syntax is invalid for the generate pred_prob command. Also, I am unsure how to go about obtaining a caterpillar plot using the bayes command; normally I use "serrbar" if just using xtmelogit for example. Any help would be appreciated!

    Thank you!!

  • #2
    In case this was confusing, by caterpillar plots, I mean a plot of the group random effects. Thanks!

    Comment


    • #3
      These are not stored in matrix e(b) as regular regression coefficients, so you should look at how the matrix storing the results is named from

      Code:
      ereturn list
      In future, provide a reproducible example using dataex. The following example illustrates how you can generate your predictions (Stata 16), but I cannot help with graphing as I do not understand what you are after.

      Code:
      webuse bangladesh, clear
      bayes, prior({ c_use :_cons}, flat): melogit c_use || urban :, cov(un)
      bayes, showreffects({U0[1/2]})
      mat list e(mean)
      gen pred_prob=.
      levelsof urban, local(urban)
      foreach gr of local urban{
         replace pred_prob = invlogit(e(mean)[1,"c_use:_cons"]+ e(mean)[1,"U0[urban]:`gr'"]) if urban==`gr'
      }

      Comment


      • #4
        thank you very much!

        Comment

        Working...
        X