mediate_pcma
applies principal component mediation analysis
(Huang and Pan, 2013) to mediation settings in which the mediators are high-dimensional.
mediate_pcma(
A,
M,
Y,
var_per = 0.8,
n_pc = NULL,
sims = 1000,
boot_ci_type = "bca",
ci_level = 0.95,
seed = 1
)
A list containing:
loadings: a matrix of the PC loadings.
pcs: a matrix of the PCs.
var_explained: the cumulative proportion of variance explained by the PCs.
contributions: a data frame containing the estimates, confidence intervals, and p-values of the mediation contributions.
effects: a data frame containing the estimated direct, global mediation, and total effects
length n
numeric vector containing exposure variable
n x p
numeric matrix of high-dimensional mediators.
length n
numeric vector containing continuous outcome variable.
a numeric variable with the desired proportion of variance explained. Default is 0.8.
optional numeric variable with the desired number of PCs, in which case
var_per
is ignored. Default is NULL
and the number of PCs is
determined based on the desired proportion of variance explained.
number of Monte Carlo draws for nonparametric bootstrap or
quasi-Bayesian approximation (see mediation::mediate()
).
Default is 1000.
a character string indicating the type of bootstrap
confidence intervals for when boot = TRUE
. If "bca"
,
bias-corrected and accelerated (BCa) confidence intervals will be estimated.
If "perc"
, percentile confidence intervals will be estimated
(see mediation::mediate()
). Default is "bca".
the desired confidence level. Default is 0.95.
seed used for fitting single-mediator models after PCA
Principal component mediation analysis (PCMA) is a method for estimating
mediation effects when the mediators are high-dimensional. The first step
is to compute the residuals of mediator models (\(M|A\)), then perform
PCA on those residuals to reduce them to a smaller number of mediators
that efficiently explain the residual variance. Then, since those mediators
are linearly independent conditional on A, one can trivially perform
single-mediator mediation analysis for each PC on its own, in this case
by using the mediation::mediate()
function. The global mediation effect is estimated
by summing the mediation effects of the individual PCs.
Huang, Y.-T. & Pan, W.-C. Hypothesis test of mediation effect in causal mediation model with high-dimensional continuous mediators. Biometrics 72, 402-413 (2016).
A <- med_dat$A
M <- med_dat$M
Y <- med_dat$Y
# Fit PCMA with 3 principal components and print the effects. In practice one
# should choose n_pc (or var_per) and the number sims to be larger
out <- mediate_pcma(A, M, Y, n_pc = 3, sims = 10)
out$effects
Run the code above in your browser using DataLab