Announcement

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

  • need to get odds ratios from multilevel coefficients

    Hi, I need to get and plot OR for random effects of a multilevel model:

    . sysuse auto, clear
    . mixed price weight length || foreign:
    . coefplot, drop(_cons) xline(1) eform xtitle(Odds ratio)

    I need to get the OR for the random effects part. Then, as you can see, can get a nice graph for weight and length (1st-level or fixed effect variables) but need to plot foreign (2nd- level, random effects variable), as well
    Many thanks!

    R

  • #2
    Welcome to the Stata Forum / Statalist,

    To start, you shall not get odds ratios by using - mixed - command, for the following reason: the Yvar is supposed to be continuous.

    To end, I fear there are several "issues" concerning your query (data set, data display, commands, aims, etc.) , which basically stem from the need to get a good grasp of mixed models.
    Last edited by Marcos Almeida; 02 Oct 2017, 13:39.
    Best regards,

    Marcos

    Comment


    • #3
      Many thanks Marcos. So sorry I tweaked the dataset but sent the link for the original one with a wrong regression equation. Anyway, mine has two categorical variables: foreign (level-2) and fuel (outcome), plus other explanatory (continuous) variables.

      Output is as follows:

      Mixed-effects logistic regression Number of obs = 74
      Group variable: foreign Number of groups = 2
      Wald chi2(2) = 2.05
      Log likelihood = -46.603558 Prob > chi2 = 0.3591
      ------------------------------------------------------------------------------
      fuel | Odds Ratio Std. Err. z P>|z| [95% Conf. Interval]
      -------------+----------------------------------------------------------------
      weight | 1.001473 .0011674 1.26 0.207 .9991874 1.003764
      length | .9444001 .0379664 -1.42 0.155 .8728435 1.021823
      _cons | 526.3988 2377.919 1.39 0.165 .075189 3685324
      -------------+----------------------------------------------------------------
      foreign |
      var(_cons)| .8404103 1.112498 .0627637 11.25316
      ------------------------------------------------------------------------------
      LR test vs. logistic model: chibar2(01) = 3.80 Prob >= chibar2 = 0.0256



      Then, I'd like to plot odds ratios for a) weight and length, and b) foreign variable.

      . coefplot, drop(_cons) xline(1) eform xtitle(Odds ratio) produces a plot with weight and length, but I need a plot for the random effects level (foreign). The aim is drawing a plot with more different 2nd-level variables I have in my real dataset, for presentation purposes.

      Hope somebody would help with this.
      Best

      r


      Comment


      • #4
        Ricardo, it always helps to provide a reproducible example so that interested parties can play around with it. I suspect you are using -melogit-, and that the following reproducible example illustrates what you are trying to do.

        Code:
        use http://www.stata-press.com/data/r15/bangladesh, clear
        summarize c_use urban age child* district
        
        melogit c_use urban age child* || district: ,or
        coefplot, drop(_cons) xline(1) eform xtitle(Odds ratio)
        I think you are asking if there is a way to make another plot showing the variance of the random intercepts. Is that right?

        Regarding the output you showed earlier, you used the dichotomous variable foreign as a level 2 variable. IIRC, many authors suggest that a level 2 variable should have at least 10 levels. With too few levels, the variance of the random intercepts cannot be estimated with any precision.

        Reference for -coefplot-: Jann, B. 2014. Plotting regression coefficients and other estimates. Stata Journal 14:708-737.

        HTH.
        --
        Bruce Weaver
        Email: [email protected]
        Version: Stata/MP 19.5 (Windows)

        Comment

        Working...
        X