+ Reply to Thread
Results 1 to 4 of 4

Thread: Odds ratio plot on log scale

  1. #1
    Points: 1,145, Level: 18
    Level completed: 45%, Points required for next Level: 55

    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Odds ratio plot on log scale




    Greetings,

    I have had difficulties plotting results from GLM logit models to show up as odds ratios on a log scale. Ultimately I want to obtain estimates from different models and plot the results on one graph as shown here (https://www.ctspedia.org/do/view/CTS...ClinAEGraph001). Do you have any insight?

  2. #2
    Omega Contributor
    Points: 39,022, Level: 100
    Level completed: 0%, Points required for next Level: 0
    hlsmith's Avatar
    Location
    Not Ames, IA
    Posts
    7,069
    Thanks
    402
    Thanked 1,192 Times in 1,153 Posts

    Re: Odds ratio plot on log scale

    ???

    If you are trying to emulate that figure, it is just a forest plot and the results are odds ratios, not on a log scale. Model coefficients may be log odds, but they get exponentiated and are then the odds(ratios) we are used to.

    I would imagine there are lots of code for forest plot. If you can't find any let use know. Also let us know it you are really trying to put something on the log scale. It is extremely unusual for odd ratios to naturely greater than 10, at least in medicine.

    PS, the link figure is less than ideal in that the <1 side looks like 0.5 is equivalent to the magnitude of 1.5, which is definitely not the case!
    Stop cowardice, ban guns!

  3. #3
    Points: 21,235, Level: 91
    Level completed: 77%, Points required for next Level: 115

    Posts
    570
    Thanks
    51
    Thanked 20 Times in 19 Posts

    Re: Odds ratio plot on log scale

    https://visard.shinyapps.io/forest

    I've included the option to plot on the log scale

  4. #4
    Points: 1,145, Level: 18
    Level completed: 45%, Points required for next Level: 55

    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Odds ratio plot on log scale


    Thanks for your reply. Here i code I have been aiming to tweak to input my own information but have not been able to do so. This makes exactly what is needed but how can I enter the odds? I see dat.bcg but haven't been able to open save or modify or figure out the format of a spreadsheet to use...

    Code: 
    library(metafor)
     
    ### decrease margins so the full space is used
    par(mar=c(4,4,1,2))
     
    ### fit random-effects model (use slab argument to define study labels)
    res <- rma(ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg, measure="RR",
               slab=paste(author, year, sep=", "), method="REML")
     
    ### set up forest plot (with 2x2 table counts added; rows argument is used
    ### to specify exactly in which rows the outcomes will be plotted)
    forest(res, xlim=c(-16, 6), at=log(c(0.05, 0.25, 1, 4)), atransf=exp,
           ilab=cbind(dat.bcg$tpos, dat.bcg$tneg, dat.bcg$cpos, dat.bcg$cneg),
           ilab.xpos=c(-9.5,-8,-6,-4.5), cex=0.75, ylim=c(-1, 27),
           order=order(dat.bcg$alloc), rows=c(3:4,9:15,20:23),
           xlab="Risk Ratio", mlab="", psize=1)
     
    ### add text with Q-value, dfs, p-value, and I^2 statistic
    text(-16, -1, pos=4, cex=0.75, bquote(paste("RE Model for All Studies (Q = ",
         .(formatC(res$QE, digits=2, format="f")), ", df = ", .(res$k - res$p),
         ", p = ", .(formatC(res$QEp, digits=2, format="f")), "; ", I^2, " = ",
         .(formatC(res$I2, digits=1, format="f")), "%)")))
     
    ### set font expansion factor (as in forest() above) and use bold italic
    ### font and save original settings in object 'op'
    op <- par(cex=0.75, font=4)
     
    ### add text for the subgroups
    text(-16, c(24,16,5), pos=4, c("Systematic Allocation",
                                   "Random Allocation",
                                   "Alternate Allocation"))
     
    ### switch to bold font
    par(font=2)
     
    ### add column headings to the plot
    text(c(-9.5,-8,-6,-4.5), 26, c("TB+", "TB-", "TB+", "TB-"))
    text(c(-8.75,-5.25),     27, c("Vaccinated", "Control"))
    text(-16,                26, "Author(s) and Year",  pos=4)
    text(6,                  26, "Risk Ratio [95% CI]", pos=2)
     
    ### set par back to the original settings
    par(op)
     
    ### fit random-effects model in the three subgroups
    res.s <- rma(ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg, measure="RR",
                 subset=(alloc=="systematic"), method="REML")
    res.r <- rma(ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg, measure="RR",
                 subset=(alloc=="random"), method="REML")
    res.a <- rma(ai=tpos, bi=tneg, ci=cpos, di=cneg, data=dat.bcg, measure="RR",
                 subset=(alloc=="alternate"), method="REML")
     
    ### add summary polygons for the three subgroups
    addpoly(res.s, row=18.5, cex=0.75, atransf=exp, mlab="")
    addpoly(res.r, row= 7.5, cex=0.75, atransf=exp, mlab="")
    addpoly(res.a, row= 1.5, cex=0.75, atransf=exp, mlab="")
     
    ### add text with Q-value, dfs, p-value, and I^2 statistic for subgroups
    text(-16, 18.5, pos=4, cex=0.75, bquote(paste("RE Model for Subgroup (Q = ",
         .(formatC(res.s$QE, digits=2, format="f")), ", df = ", .(res.s$k - res.s$p),
         ", p = ", .(formatC(res.s$QEp, digits=2, format="f")), "; ", I^2, " = ",
         .(formatC(res.s$I2, digits=1, format="f")), "%)")))
    text(-16, 7.5, pos=4, cex=0.75, bquote(paste("RE Model for Subgroup (Q = ",
         .(formatC(res.r$QE, digits=2, format="f")), ", df = ", .(res.r$k - res.r$p),
         ", p = ", .(formatC(res.r$QEp, digits=2, format="f")), "; ", I^2, " = ",
         .(formatC(res.r$I2, digits=1, format="f")), "%)")))
    text(-16, 1.5, pos=4, cex=0.75, bquote(paste("RE Model for Subgroup (Q = ",
         .(formatC(res.a$QE, digits=2, format="f")), ", df = ", .(res.a$k - res.a$p),
         ", p = ", .(formatC(res.a$QEp, digits=2, format="f")), "; ", I^2, " = ",
         .(formatC(res.a$I2, digits=1, format="f")), "%)")))

+ Reply to Thread

           




Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts






Advertise on Talk Stats