Search code examples
rr-forestplotmetafor

Metafor: Error with mlab in the forest function while passing CI bounds from df


I am working with vaccine effectiveness (VE) data and have the point estimates along with their confidence intervals (CI) in my df. I am trying to create a forest plot using the metafor package in R in the RevMan style, while passing the CI bounds from my dataset. However, I get the error "mlab" is not a graphical parameter when trying to get the mlab polygon to show up in the plot.

A reproducible example is below.

library(metafor)

dat <- data.frame(author = c("Amore-Coffea", "Deliciozza", "Kahve-Paradiso"),
                  year   = c(2000, 2004, 2002),
                  ve     = c(0.9, 0.85, 0.92),
                  ci_ll    = c(0.7, 0.7, 0.9),
                  ci_ul     = c(0.98, 0.9, 0.95))
                  
dat <- escalc(measure = "RR",              
              yi = log(1 - dat$ve),
              sei = (log(1 - dat$ci_ul) - log(1 - dat$ci_ll)) / (2 * 1.96),
              data = dat)
                  
res <- rma(yi, vi, data=dat, method="DL")
                  
sav <- forest(dat$ve, ci.lb=dat$ci_ll, ci.ub=dat$ci_ul, 
              slab = paste(dat$author, dat$year, sep = ", "),
              transf = function(x) x * 100,
              at = c(0, 25, 50, 75, 100),
              xlim = c(-200, 110), 
              xlab="", 
              efac=c(0,4), 
              textpos=c(-200,-25), 
              lty=c(1,1,0), 
              refline=NA,
              cex=0.78, 
              header=c("Study", "IV, Random, 95% CI"), 
              mlab="")

Is there a way to make mlab work in the forest function or should I be using addpoly? However, with addpoly, then the polygon shows up underneath the effect measure bar.


Solution

  • You are passing estimates to the forest() function, in which case forest.default() will be called. It does not have an mlab argument (since there won't be a pooled estimate, there is no point in having a label for it). So you should remove mlab="" from your call to forest(). Instead, you should make a bit of extra space at the bottom of the plot with ylim=c(-2,6) and then add the summary estimate with addpoly(res, row=-1, transf = function(x) (1-exp(x)) * 100).