Contents
associate$mediation
Mediation analyses for a PolyGeniusStudy
associate$mediation() decomposes the effect of one exposure on one outcome
into an indirect (ACME), direct (ADE) and total effect through one mediator,
all resolved from a PolyGeniusStudy. Estimation is delegated to
mediation::mediate(), which is a suggested dependency and must be installed.
Usage
associate$mediation(
data,
exposure,
mediator,
outcome,
covariates = NULL,
outcome.model = c("auto", "lm", "glm"),
method = c("natural.effects", "baron.kenny"),
weights = NULL,
conf.level = 0.95,
output = c("summary", "models"),
...
)Arguments
| Argument | Description |
|---|---|
data | A PolyGeniusStudy. |
exposure | Unquoted exposure expression, resolved from data. Must resolve to exactly one column. |
mediator | Unquoted mediator expression, resolved from data. Must resolve to exactly one column. |
outcome | Unquoted outcome expression, resolved from data. Must resolve to exactly one column; it is fetched directly and is not parsed as an [outcome()](/reference/outcome/) or [surv()](/reference/surv/) descriptor. |
covariates | Unquoted adjustment expression, or NULL (default). Entered in both the mediator and the outcome model. |
outcome.model | One of "auto" (default), "lm", "glm". Outcome-model family; "auto" infers it from the outcome column's type. |
method | One of "natural.effects" (default), "baron.kenny". Recorded on every result row as the method key; it does not change the estimator, which is mediate() in both cases. |
weights | Unquoted expression resolving to one column, a numeric vector aligned with the mediation frame, or NULL (default). Passed as weights to both model fits. |
conf.level | Numeric scalar in (0, 1), default 0.95. Forwarded to mediate(), so lower/upper are its simulation percentile bounds at this level. Pass it here rather than through .... |
output | One of "summary" (default), "models". |
... | Further arguments forwarded to mediation::mediate() (for example sims), evaluated against the mediation frame. |
Value
With output = "summary" (default), a PolyGeniusAssociation:
$results — Exactly three rows following the schema-mediation schema --
effect/effect.type of "ACME"/"indirect", "ADE"/"direct" and
"Total effect"/"total" -- carrying method, outcome, exposure,
mediator, fit.id, estimate, se, lower, upper, statistic,
pval, adj.pval, adj.family.id and n.
$artifacts — effect.summary, a copy of the three result rows.
$diagnostics — Empty.
$fits — NULL -- mediation rows are already narrow.
$metadata — analysis.type = "mediation", schema.name,
outcome.type ("binary" for a glm outcome model, else
"continuous"). $provenance records the call.
$indices$multiplicity — The single declared BH family, keyed from
adj.family.id.
With output = "models", a named list: exposure, mediator, outcome and
method (the resolved column names and label), plus the fitted
mediator.model, outcome.model and the mediation object itself.
Details
Models fitted
The mediator model is always stats::lm(), whatever the mediator's type. The
outcome model is stats::lm() or a binomial stats::glm(); with
outcome.model = "auto" a factor, logical or {0, 1}-numeric outcome selects
"glm" and anything else selects "lm". Both models take exposure and
covariates; the outcome model additionally takes mediator. Survival
mediation is not implemented.
mediate() is called with robustSE = TRUE and conf.level, so intervals are
simulation percentile bounds. exposure, mediator and outcome must each
resolve to exactly one column, and the call aborts otherwise.
Missing data
Complete cases are taken once, over the exposure, mediator, outcome,
covariates and weights together, and both models are fitted on that one
subset. So n is the number of observations actually fitted, both models see
the same rows, and a missing outcome no longer aborts the call. The analysis
is complete-case; no imputation is performed.
Exactly three rows are produced, so adj.pval is a BH adjustment over those
three p-values, with no grouping and no way to change the method.
Standard errors and p-values
se is the standard deviation of mediate()'s simulation draws for each
effect, so it neither assumes the (often asymmetric) interval is symmetric nor
depends on conf.level. When a draw vector is missing or degenerate it falls
back to the interval half-width divided by the conf.level normal quantile.
pval is mediate()'s own simulation p-value and is authoritative;
statistic is estimate / se and is not the test that produced pval.
Examples
med <- associate$mediation(
data,
exposure = PRS_AD,
mediator = education,
outcome = dementia,
covariates = c(age, sex, PC1, PC2)
)
med$results[, c("effect", "estimate", "lower", "upper", "pval")]See Also
associate, PolyGeniusAssociation, associate$meta
Other associate-analyses:
associate-compare,
associate-meta,
associate-mr,
associate-regression,
associate-single-variant