Skip to content
Prev 2898 / 5632 Next

[R-meta] Which method to compute 95% confidence intervals around individual effect sizes (standardized mean differences) ?

Dear Dakis,

Method 3 should give the same results. The yi and vi elements in 'mod' are just the original data -- these are not modified or changed by the model that is fitted. 

Here is a fully reproducible example (using one of the Gleser & Olkin, 2009, examples) showing that all three methods give the exact same CIs:

library(metafor)

dat <- data.frame(study=c(1,1,2,3,3,3), trt=c(1,2,1,1,2,3),
                  ai=c( 40, 40, 10,150,150,150), n1i=c(1000,1000,200,2000,2000,2000),
                  ci=c(100,150, 15, 40, 80, 50), n2i=c(4000,4000,400,1000,1000,1000))
dat$pti <- with(dat, ci / n2i)
dat$pci <- with(dat, ai / n1i)
dat <- escalc(measure="OR", ai=ai, ci=ci, n1i=n1i, n2i=n2i, data=dat)
 
calc.v <- function(x) {
   v <- matrix(1/(x$n1i[1]*x$pci[1]*(1-x$pci[1])), nrow=nrow(x), ncol=nrow(x))
   diag(v) <- x$vi
   v
}
 
V <- bldiag(lapply(split(dat, dat$study), calc.v))
 
res <- rma.mv(yi, V, mods = ~ factor(trt) - 1, data=dat)
res

cbind(dat$yi - sqrt(dat$vi)*qnorm(0.05/2, lower.tail=FALSE), 
      dat$yi + sqrt(dat$vi)*qnorm(0.05/2, lower.tail=FALSE))

cbind(summary(dat)$ci.lb, summary(dat)$ci.ub)

cbind(res$yi - sqrt(res$vi)*qnorm(0.05/2, lower.tail = FALSE),
      res$yi + sqrt(res$vi)*qnorm(0.05/2, lower.tail = FALSE))

Best,
Wolfgang