mediate_pcma {hdmed} | R Documentation |
Principal Component Mediation Analysis for High-dimensional Mediators
Description
mediate_pcma
applies principal component mediation analysis
(Huang and Pan, 2013) to mediation settings in which the mediators are high-dimensional.
Usage
mediate_pcma(
A,
M,
Y,
var_per = 0.8,
n_pc = NULL,
sims = 1000,
boot_ci_type = "bca",
ci_level = 0.95,
seed = 1
)
Arguments
A |
length |
M |
|
Y |
length |
var_per |
a numeric variable with the desired proportion of variance explained. Default is 0.8. |
n_pc |
optional numeric variable with the desired number of PCs, in which case
|
sims |
number of Monte Carlo draws for nonparametric bootstrap or
quasi-Bayesian approximation (see |
boot_ci_type |
a character string indicating the type of bootstrap
confidence intervals for when |
ci_level |
the desired confidence level. Default is 0.95. |
seed |
seed used for fitting single-mediator models after PCA |
Details
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.
Value
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.
Source
https://rdrr.io/github/zhaoyi1026/spcma
References
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).
Examples
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