Skip to content
Prev 1779 / 5636 Next

[R-meta] Duplicating the results of the metabin() function

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.