1
votes

I'm trying to plot odds ratios and corresponding 90% confidence intervals, which I have previously obtained from a proportional odds model using package brms. I've made vectors containing the odds ratios obtained from the model (medians of the posterior samples; x), as well as lower (ci.lb) and upper (ci.ub) confidence interval bounds, respectively, and used the following code to make a forest plot:

x <- c(6.587028, 10.67589, 1.578881, 1.396755, 5.447785, 1.852427, 1.828179, 1.725313, 1.526206, 1.993046, 1.191804, 0.7648945)

ci.lb <- c(2.682959, 4.196124, 0.6783311, 0.547960, 2.011936, 0.7649611, 0.7492622, 0.6538183, 0.5299715, 0.8348141, 0.4814904, 0.2945799)

ci.ub <- c(17.843931, 29.200081, 3.7121095, 3.612463, 15.466248, 4.6075681, 4.3162345, 4.3404646, 4.3962568, 4.7397496, 2.9739579, 1.9560032)

forest(x, ci.lb, ci.ub, annotate=TRUE, showweights=FALSE, 
       header=headers, top=3, steps=5, 
       refline=0, digits=2L, xlab="Odds ratios", 
       slab=labels, efac=1, pch=15, col) 

However, the confidence intervals on my forest plot do not correspond to those given in my ci.lb and ci.ub vectors. This is the plot I get:

Can someone tell me what I'm doing wrong?

2

2 Answers

1
votes

The forest plot the OP is showing comes from the metafor package, not the meta package. The latter loads metafor and the function being used when running forest(x, ci.lb, ci.ub) is metafor::forest.default(). If you take a look at the documentation for this function (https://wviechtb.github.io/metafor/reference/forest.default.html), you will see that the first five arguments are forest(x, vi, sei, ci.lb, ci.ub, ...). Hence, you are passing the ci.lb and ci.ub vectors to arguments vi and sei, which makes no sense. So use forest(x, ci.lb=ci.lb, ci.ub=ci.ub) to make sure these vectors are passed to the right arguments. Overall lesson here is not to rely on position matching of arguments.

0
votes

Most likely you are using forest from the package meta . If I load that library I get the exact plot as you:

library(meta)
forest(x, ci.lb, ci.ub)

enter image description here

This function requires an object of class meta. For what you have now, maybe this will work:

library(forestplot)
studynames = paste0("study",1:length(x))

naming = list(
       "study"= studynames ,
        "odds ratio[95% CI]" = paste(round(x,digits=2),
        "[",
        round(ci.lb,digits=2),"-",
        round(ci.ub,digits=2),"]")
          )


forestplot(labeltext=naming,mean=x,lower=ci.lb,upper=ci.ub)

enter image description here