Announcement

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

  • Plotting the odds ratio of multiple multivariate logistic regressions in one plot

    Hi everyone! I am trying to plot the odds ratios of multiple multivariate logistic regressions (y1, y2, y3, and y4) in one plot, and I hope someone can help me with that. I’d like to have a plot that looks like the one below where only the odds ratio of the variable of interest (x1) is plotted not the control variables (x2, x3, and x4). I am using Stata 14.2 and very much appreciate your help in advance.
    Click image for larger version

Name:	Question for statalist.png
Views:	1
Size:	11.3 KB
ID:	1654800



    Here is how my code looks like:

    Code:
    local dichotomies y1 y2 y3 y4
    tempfile results
    capture postutil clear
    postfile handle str32 outcome_var str6 model float (x1 p lb ub) using `results'
     
    foreach d of local dichotomies {
             logit `d' i.x1 x2 i.x3 i.x4
             matrix M = r(table)
             post handle ("`d'") ("logit") (M[1, 2]) (M[4, 2]) (M[5, 2]) (M[6, 2])
    }
     
    postclose handle
    preserve
    use `results', clear
    gen odds_ratio = exp(x1)
    replace lb = exp(lb)
    replace ub = exp(ub)
    list, noobs clean
    export excel using "[…]\odds_ratio.xls", firstrow(variables) replace
    restore
    Last edited by Zakia Nouri; 16 Mar 2022, 21:48.

  • #2
    Take a look at ssc desc coefplot and https://www.stata-journal.com/articl...article=gr0059
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      If the 95% CIs (on the log scale) are symmetrical, you can use -meta- with the option of equal weights. Otherwise, you can use -metan-, which has many options.

      Comment


      • #4
        Thanks Maarten for your response. I did check the coefplot, but I couldn't find anything about how to drop the x2, x3, and x4 odds ratio. I am only interested to plot the odds ratio of x1 for y1, y2, y3, and y4. Do you know if there is anyway to do that?

        Comment


        • #5
          You can use the keep() and/or drop() options to select the coefficients you need to show

          To display odds ratios you need to use the eform option, as the odds ratio is the exponentiated coefficient in a logit regression.

          All that is explained in both the helpfile and the article I linked to in #2
          ---------------------------------
          Maarten L. Buis
          University of Konstanz
          Department of history and sociology
          box 40
          78457 Konstanz
          Germany
          http://www.maartenbuis.nl
          ---------------------------------

          Comment

          Working...
          X