Skip to content
Prev 4202 / 5632 Next

[R-meta] Comparing heterogeneity explained from different meta-regression models with the same moderator

Dear Zhenyu,

Making inferences about the (pseudo) R^2 statistic is a bit tricky, since it is computed by essentially comparing the tau^2 estimate from the random-effects model and the mixed-effects meta-regression model, so two different models. Hence, computing some kind of standard error for R^2 would be quite tricky. To get a CI for R^2, one could use bootstrapping. For example:

library(metafor)
library(boot)

dat <- dat.bangertdrowns2004
dat <- dat[!is.na(dat$minutes),]

rma(yi, vi, mods = ~ minutes, data=dat)  

boot.func <- function(dat, indices) {
   res <- try(suppressWarnings(rma(yi, vi, mods = ~ minutes, data=dat[indices,])), silent=TRUE)
   ifelse(inherits(res, "try-error"), NA, res$R2)
}

set.seed(1234)
res.boot <- boot(dat, boot.func, R=10000)
res.boot

hist(res.boot$t, breaks=50)

boot.ci(res.boot)

You will see that the bootstrap distribution of R^2 is quite weird, so I would recommend the percentile CI (which also avoids the possibility of getting bounds below 0% or above 100%). And the bootstrap CIs are super wide. That's to be expected when k is 'only' 24. Precise estimates of R^2 require quite large datasets.

The same applies if one would want to compare R^2 from two different models. The only way I could think of doing this is to use bootstrapping. How to set this up requires some thought. Are the two outcomes coming from the same set of studies? In that case, one might want to sample studies, not estimates. Then calculate R^2 for the two different models, take the difference, and repeat. If the data are in wide format (so the two outcomes are different columns and so you have one row per study), then this should work:

boot.func <- function(dat, indices) {
   res1 <- try(suppressWarnings(rma(y1i, v1i, mods = ~ x, data=dat[indices,])), silent=TRUE)
   res2 <- try(suppressWarnings(rma(y2i, v2i, mods = ~ x, data=dat[indices,])), silent=TRUE)
   ifelse(inherits(res1, "try-error") || inherits(res2, "try-error"), NA, res1$R2-res2$R2)
}

Best,
Wolfgang