guido-s / meta

Official Git repository of R package meta
http://cran.r-project.org/web/packages/meta/index.html
GNU General Public License v2.0
82 stars 32 forks source link

[BUG] Cannot get MH method to work in metabin under macOS #52

Closed wingsteel closed 1 year ago

wingsteel commented 1 year ago

I just updated meta to v6.5, I am running RStudio 2023.06.0+421 (last version).

I noticed something in one of my macOS system (meta + R last versions). When I launched a metabin function

res <- metabin (…, method = “MH”,…)

All I got back was an analysis with Inverse method. No way to fix it (hakn and MH.exact disabled changed nothing).

So I launched the same command on another macOS machine, and I had MH method working ! This macOS had not (yet) the 6.5 version of meta package. So obviously I updated to meta 6.5 and it was it : no more MH method…

I guess the problem is coming from meta 6.5-0

Thank you for your help !

guido-s commented 1 year ago

I can only guess as you did not provide the full R command.

The Mantel-Haenszel method is a method for the common effect model. Nevertheless, before meta, version 6.5-0, the printout reported "Mantel-Haenszel method" if argument common = FALSE.

The new printout reports both or either MH / inverse variance method. E.g.,

> m <- metabin(1:3, 11:13, 2 * 1:3, 11:13)
>
> ## Both common effect and random effects model
> m
Number of studies: k = 3
Number of observations: o = 72
Number of events: e = 18

                         RR           95%-CI     z p-value
Common effect model  0.5000 [0.2138; 1.1695] -1.60  0.1099
Random effects model 0.5000 [0.2145; 1.1657] -1.61  0.1085

Quantifying heterogeneity:
 tau^2 = 0; tau = 0; I^2 = 0.0% [0.0%; 89.6%]; H = 1.00 [1.00; 3.10]

Test of heterogeneity:
    Q d.f. p-value
 0.00    2  1.0000

Details on meta-analytical method:
- Mantel-Haenszel method
- Inverse variance method
- Restricted maximum-likelihood estimator for tau^2
>
> ## Only common effect model, i.e., Mantel-Haenszel method
> print(update(m, random = FALSE), overall.hetstat = FALSE)
Number of studies: k = 3
Number of observations: o = 72
Number of events: e = 18

                        RR           95%-CI     z p-value
Common effect model 0.5000 [0.2138; 1.1695] -1.60  0.1099

Details on meta-analytical method:
- Mantel-Haenszel method
>
> ## Only random effects model, i.e., inverse variance method
> update(m, common = FALSE)
Number of studies: k = 3
Number of observations: o = 72
Number of events: e = 18

                         RR           95%-CI     z p-value
Random effects model 0.5000 [0.2145; 1.1657] -1.61  0.1085

Quantifying heterogeneity:
 tau^2 = 0; tau = 0; I^2 = 0.0% [0.0%; 89.6%]; H = 1.00 [1.00; 3.10]

Test of heterogeneity:
    Q d.f. p-value
 0.00    2  1.0000

Details on meta-analytical method:
- Inverse variance method
- Restricted maximum-likelihood estimator for tau^2
wingsteel commented 1 year ago

I did not understand that MH model was only for common effect, I followed the well known guide, and we can see the code used to get random model with MH


m.bin <- metabin(event.e = event.e, 
                 n.e = n.e,
                 event.c = event.c,
                 n.c = n.c,
                 studlab = author,
                 data = DepressionMortality,
                 sm = "RR",
                 method = "MH",
                 MH.exact = TRUE,
                 fixed = FALSE,
                 random = TRUE,
                 method.tau = "PM",
                 hakn = TRUE,
                 title = "Depression and Mortality")
summary(m.bin)

and we get :

## Details on meta-analytical method:
## - Mantel-Haenszel method
## - Paule-Mandel estimator for tau^2
## - Q-profile method for confidence interval of tau^2 and tau
## - Hartung-Knapp adjustment for random effects model

Why one would you MH model if we want random model then ?

Thanks again for your precious time.

guido-s commented 1 year ago

The description in the book Doing meta-analysis in R is inaccurate. However, as I wrote about, the printout for metabin() has also been inaccurate until meta, version 6.5-0.

In metabin(), there is only the argument method to choose the method for the common effect or random effects meta-analysis. The setting method = "MH" implies that the Mantel-Haenszel method is used for the common effects model and the inverse variance method for the random effects model.

Running the following commands, you will see that the reported percentage weights for summary(m.bin) are (correctly) the random effects weights.

library("dmetar")
data(DepressionMortality)
##
m.bin <-
  metabin(event.e, n.e, event.c, n.c, studlab = author,
    data = DepressionMortality,
    common = FALSE, random = TRUE, MH.exact = TRUE,
    method.tau = "PM", method.random.ci = "HK",
    title = "Depression and Mortality")
##
print(summary(m.bin), ma = FALSE)
##
rbind(
  pweight.c = round(100 * m.bin$w.common / sum(m.bin$w.common), 1),
  pweight.r = round(100 * m.bin$w.random / sum(m.bin$w.random), 1)
)

However, the Mantel-Haenszel weights according to equation (4.9) in Doing meta-analysis in R are actually the common effect weights:

data.frame(
  eq4.9 = with(DepressionMortality, n.e * event.c / (n.e + n.c)),
  weight.c = m.bin$w.common, weight.r = m.bin$w.random
)

Since meta, version 6.5-0, an additional list element method.random describes the method used for the random effects model.

m.bin$method
m.bin$method.random
##
m.bin.iv <- update(m.bin, method = "Inverse")
m.bin.iv$method
m.bin.iv$method.random
##
m.bin.glmm <- update(m.bin, method = "GLMM")
m.bin.glmm$method
m.bin.glmm$method.random
##
m.bin.peto <- update(m.bin, method = "Peto", sm = "OR")
m.bin.peto$method
m.bin.peto$method.random

As a final comment, there is a random effects meta-analysis method considering the Mantel-Haenszel estimator in the calculation of the between-study variance:

update(m.bin, method.tau = "DL", Q.Cochrane = TRUE)

But the underlying meta-analysis method is still the inverse variance method.

wingsteel commented 1 year ago

Thank you so much for your clarity, this answer was very helpful !