[R-meta] Bootstrapping confidence intervals in metafor

Viechtbauer, Wolfgang (SP) wo||g@ng@v|echtb@uer @end|ng |rom m@@@tr|chtun|ver@|ty@n|
Tue Apr 14 17:02:43 CEST 2020

Dear Crystal,

This is relevant:


You just have to change boot.func() so that the appropriate model is being fitted (sounds like you are using rma.mv()) and change what is being returned (i.e., c(coef(res), vcov(res))) is probably all you need unless you want to create CIs for the variance components of the model). Here is a simple example for a non-parametric bootstrap using a three-level model:


dat <- dat.konstantopoulos2011
res <- rma.mv(yi, vi, random = ~ 1 | district/school, data=dat)

boot.func <- function(dat, indices) {
   sub <- dat[indices,]
   res <- try(rma.mv(yi, vi, random = ~ 1 | district/school, data=sub), silent=TRUE)
   if (is.element("try-error", class(res))) NA else c(coef(res), vcov(res))

res.boot <- boot(dat, boot.func, R=1000)
boot.ci(res.boot, index=1:2)

An interesting consideration is whether one should really do a stratified bootstrap here. This can be done with:

res.boot <- boot(dat, boot.func, R=1000, strata=dat$district)
boot.ci(res.boot, index=1:2)

Not sure which is more appropriate here.


>-----Original Message-----
>From: R-sig-meta-analysis [mailto:r-sig-meta-analysis-bounces using r-project.org]
>On Behalf Of Crystal La Rue
>Sent: Friday, 03 April, 2020 10:24
>To: r-sig-meta-analysis using r-project.org
>Subject: [R-meta] Bootstrapping confidence intervals in metafor
>Dear Wolfgang,
>I am conducting a three-level random-effects meta-analysis using metafor in
>R. I use Fisher's r-to-z transformed correlation coefficients and I have
>been advised to generate bootstrapped confidence intervals to capture a more
>accurate population standard error. I'm still quite new to R and am having
>trouble working out how to do this. Can you point me in the right direction?
>Many thanks,

More information about the R-sig-meta-analysis mailing list