Hi Meta Analysts,
I'm having trouble duplicating by hand the results produced by the
metabin() function. In particular the Q statistic.
Here's a toy example:
## get metabin() for a simple example
library(meta)
test.dat <- data.frame(exposed.events = c(3, 4, 5), exposed.n = c(10, 11,
12),
unexposed.events = c(14, 7, 2), unexposed.n = c(20,
11, 7))
result <- metabin(event.e = exposed.events, n.e = exposed.n, event.c =
unexposed.events, n.c = unexposed.n, data = test.dat, method.tau = "PM", sm
= 'OR')
## calculate Q by hand
OR <- result$TE
weights.fixed <- result$w.fixed
Q <- sum(weights.fixed * (OR - result$TE.fixed)**2)
## they don't seem to match
Q
[1] 3.963568
result$Q
[1] 3.049176
This is confusing to me because according to the literature I've read the
I^2 statistic is calculated directly from Cochran's Q. And performing a
simple calculation on Q to obtain I^2 matches the result of the package:
## calculate I^2 by hand from the result's Q
(result$Q - 2)/result$Q
[1] 0.3440851
result$I2
[1] 0.3440851
I'd appreciate any insight into why my Q calculation is different than the
packages. Or any literature about what other statistic Q can refer to in
this case other than Cochran's Q.
Thank you!
Sam Leonard
Hi Sam,
The discrepancy in your calculations can be explained as follows.
By default, R function metabin() uses the Mantel-Haenszel method
(argument 'method') under the fixed effect model. Accordingly, the fixed
effect weights in 'w.fixed' come from the Mantel-Haenszel method.
However, in order to calculate Cochran's Q, the fixed effect weights
from the inverse variance method are used (which are different from the
Mantel-Haenszel weights).
You could use the following assignment in your code to calculate Q by hand:
weights.fixed <- 1 / result$seTE^2
or
weights.fixed <- update(result, method = "Inverse")$w.fixed
Best wishes, Guido
P.S. 'OR <- result$TE' should actually be 'lnOR <- result$TE' as
metabin() stores the log odds ratio instead of the odds ratio.