Skip to content
Prev 4418 / 5632 Next

[R-meta] calculate effect size and variance for prepost proportion data

Just a late follow-up to this:

This is actually implemented in escalc() in the metafor package. See:

https://wviechtb.github.io/metafor/reference/escalc.html#-b-measures-for-dichotomous-variables-2

References are also given there.

To illustrate:

library(metafor)

escalc(measure="MPOR", ai=30, bi=15,
                       ci= 5, di=20, digits=8)

# James' formulas give the same results
N <- 30 + 15 + 5 + 20
P7 <- (30 + 15) / N
P6 <- (30 +  5) / N
B <- 30 / N
log(P7 / (1 - P7)) - log(P6 / (1 - P6))
(P6 * (1 - P6) + P7 * (1 - P7) - 2 * (B - P6 * P7)) / (N * P6 * (1 - P6) * P7 * (1 - P7))

# alternatively, one can specify the pre-post correlation (phi coefficient)
ri <- (30*20 - 15*5) / sqrt((30+15) * (5+20) * (30+5) * (15+20))
escalc(measure="MPORM", ai=30+15, bi=5+20, ci=30+5, di=15+20, ri=ri, digits=8)

# this is useful if one just has the 'marginal' counts and one needs to
# guestimate the correlation

# show that the variance of the regular OR is the same as assuming ri=0
escalc(measure="OR", ai=30+15, bi=5+20, ci=30+5, di=15+20, digits=8)
escalc(measure="MPORM", ai=30+15, bi=5+20, ci=30+5, di=15+20, ri=0, digits=8)

Best,
Wolfgang