I know how to perform single means meta-analysis with the metamean function of the meta package but, I want to do it with the escalc and rma functions of the metafor package. Unfortunataly I can't figure out how to do it (as can also not ChatGPT!).
Please find below a minimal working example:
study <- c("Study 1", "Study 2", "Study 3", "Study 4", "Study 5")
mean <- c(1.2, 1.6, 1.4, 1.5, 1.7)
sd <- c(0.1, 0.2, 0.15, 0.17, 0.18)
n <- c(100, 120, 110, 105, 115)
data <- data.frame(study, mean, sd, n)
data
study mean sd n
1 Study 1 1.2 0.10 100
2 Study 2 1.6 0.20 120
3 Study 3 1.4 0.15 110
4 Study 4 1.5 0.17 105
5 Study 5 1.7 0.18 115
library (meta)
mm <- metamean (n = n,
mean = mean,
sd = sd,
studlab = study,
data = data)
Number of studies: k = 5
Number of observations: o = 550
mean 95%-CI
Common effect model 1.4011 [1.3887; 1.4135]
Random effects model 1.4797 [1.3108; 1.6485]
Quantifying heterogeneity:
tau^2 = 0.0369 [0.0131; 0.3053]; tau = 0.1920 [0.1144; 0.5526]
I^2 = 99.5% [99.4%; 99.7%]; H = 14.80 [12.93; 16.93]
Test of heterogeneity:
Q d.f. p-value
875.75 4 < 0.0001
Details on meta-analytical method:
- Inverse variance method
- Restricted maximum-likelihood estimator for tau^2
- Q-Profile method for confidence interval of tau^2 and tau
- Untransformed (raw) means
library (metafor)
esc <- escalc (measure = "SMD",
m1i = mean,
sd1i = sd,
n1i = n,
slab = study,
data = data)
Error in escalc(measure = "SMD", m1i = mean, sd1i = sd, n1i = n, slab = study, : Cannot compute outcomes. Check that all of the required information is specified via the appropriate arguments (i.e., m1i, m2i, sd1i, sd2i, n1i, n2i (and di, ti, pi)).
Any idea ?
Thank you in advance for your help ?
Don't try to compute standardized mean differences (SMD) when you only have single group means. You want to use:
dat <- escalc(measure="MN", mi=mean, sdi=sd, ni=n, slab=study, data=data)
rma(yi, vi, data=dat)