Skip to contents

Fits the exposure model \(P(X=1 | M, C)\), weights the exposed by the reciprocal of the exposure-mediator odds ratio, and refits the total-effect outcome model with those weights. The weighted fit is the natural direct effect; the difference from the unweighted total is the natural indirect effect, both on the log-odds scale.

Usage

morie_binary_mediation(x, m, y, covariates = NULL, B = 0L, alpha = 0.05)

Arguments

x

Binary exposure.

m

Mediator vector or matrix.

y

Binary outcome.

covariates

Optional baseline covariates.

B

Bootstrap replicates for standard errors.

alpha

Significance level for the bootstrap interval.

Value

Named list with total, direct, indirect, or_total, or_direct, or_indirect, se, ci_low, ci_high, n, B, method.

Details

This is not the linear machinery with a logit swapped in. Logistic coefficients are not comparable across models – each is scaled by its own residual variance – so the familiar \(ab\) and \(c - c'\) decompositions do not hold on the logit scale. That non-collapsibility is why morie_baron_kenny must not simply be pointed at a binary outcome.

No standard error is returned unless B > 0: the weights are themselves estimated, so a model-based standard error understates the uncertainty.

Mirrors morie.fn.binmed.

References

Tchetgen Tchetgen EJ (2013). Inverse odds ratio-weighted estimation for causal mediation analysis. Statistics in Medicine, 32(26), 4567-4580.

Examples

set.seed(1)
n <- 600
xx <- rbinom(n, 1, 0.5)
mm <- xx + rnorm(n)
yy <- rbinom(n, 1, plogis(-0.5 + 0.5 * xx + mm))
morie_binary_mediation(xx, mm, yy)$indirect
#> [1] 0.7140862