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, Crystal
[R-meta] Bootstrapping confidence intervals in metafor
3 messages · Crystal La Rue, Wolfgang Viechtbauer
11 days later
Dear Crystal, This is relevant: http://www.metafor-project.org/doku.php/tips:bootstrapping_with_ma 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: library(metafor) library(boot) dat <- dat.konstantopoulos2011 res <- rma.mv(yi, vi, random = ~ 1 | district/school, data=dat) res 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)) } set.seed(1234) 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: set.seed(1234) 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. Best, Wolfgang
-----Original Message----- From: R-sig-meta-analysis [mailto:r-sig-meta-analysis-bounces at r-project.org] On Behalf Of Crystal La Rue Sent: Friday, 03 April, 2020 10:24 To: r-sig-meta-analysis at 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, Crystal
8 days later
Thank you so much Wolfgang, this is really helpful! Warm regards, Crystal
From: Viechtbauer, Wolfgang (SP) <wolfgang.viechtbauer at maastrichtuniversity.nl>
Sent: Wednesday, 15 April 2020 1:02 AM
To: Crystal La Rue <cj.larue at uq.edu.au>; r-sig-meta-analysis at r-project.org <r-sig-meta-analysis at r-project.org>
Subject: RE: Bootstrapping confidence intervals in metafor
Sent: Wednesday, 15 April 2020 1:02 AM
To: Crystal La Rue <cj.larue at uq.edu.au>; r-sig-meta-analysis at r-project.org <r-sig-meta-analysis at r-project.org>
Subject: RE: Bootstrapping confidence intervals in metafor
Dear Crystal, This is relevant: http://www.metafor-project.org/doku.php/tips:bootstrapping_with_ma 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: library(metafor) library(boot) dat <- dat.konstantopoulos2011 res <- rma.mv(yi, vi, random = ~ 1 | district/school, data=dat) res 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)) } set.seed(1234) 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: set.seed(1234) 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. Best, Wolfgang >-----Original Message----- >From: R-sig-meta-analysis [mailto:r-sig-meta-analysis-bounces at r-project.org] >On Behalf Of Crystal La Rue >Sent: Friday, 03 April, 2020 10:24 >To: r-sig-meta-analysis at 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, >Crystal