mediate_spcma {hdmed} | R Documentation |
Sparse Principal Component Mediation Analysis for High-Dimensional Mediators
Description
mediate_spcma
applies sparse principal component mediation
analysis to mediation settings in which the mediators are high-dimensional.
Usage
mediate_spcma(
A,
M,
Y,
var_per = 0.8,
n_pc = NULL,
sims = 1000,
boot_ci_type = "bca",
ci_level = 0.95,
fused = FALSE,
gamma = 0,
per_jump = 0.7,
eps = 1e-04,
maxsteps = 2000,
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 |
character string indicating the type of bootstrap
confidence intervals for when |
ci_level |
the designated confidence level. Default 0.95. |
fused |
logical variable for whether the fused LASSO should be used
instead of the ordinary LASSO. Default is |
gamma |
numeric variable |
per_jump |
numeric value used for tuning parameter selection - the
quantile cut-off for total variance change under different |
eps |
numeric variable indicating the multiplier for the ridge penalty
in case |
maxsteps |
an integer specifying the maximum number of steps for the
algorithm before termination (see |
seed |
seed used for fitting single-mediator models after PCA |
Details
mediate_spcma
performs principal component mediation analysis, comparable
to mediate_pcma
, with the modification that the PC loadings are sparsified
by a flexible LASSO penalty. This has the potential make the PCs more interpretable,
since, unlike in PCA, they are only linear combinations of a subset of mediators
rather than all of them. The choice of LASSO penalties is determined by
the fused
argument - which, when set to TRUE
, deploys a fused
LASSO penalty that encourages the model to give consecutive mediators
similar loadings. The default is fused = FALSE
, and the standard
LASSO penalty is used instead of the fusion penalty. Once the sparse PCs are
computed, inference proceeds exactly like in PCMA, and the PC-mediators are
evaluated with methods from the mediate
package.
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
Zhao, Y., Lindquist, M. A. & Caffo, B. S. Sparse principal component based high-dimensional mediation analysis. Comput. Stat. Data Anal. 142, 106835 (2020).
Examples
A <- med_dat$A
M <- med_dat$M
Y <- med_dat$Y
# Fit SPCMA with the fused LASSO penalty while choosing the number of PCs based
# on the variance they explain. In practice, var_per and sims should be higher.
out <- mediate_spcma(A, M, Y, var_per = 0.25, fused = TRUE, gamma = 2, sims = 10)
out$effects