mediate_medfix {hdmed} | R Documentation |
Mediation Analysis via Fixed Effects Model
Description
mediate_medfix
fits a high-dimensional mediation model with
the adaptive LASSO approach as proposed by Zhang (2021) for the
special case of MedFix that there is only one exposure variable.
Usage
mediate_medfix(
A,
M,
Y,
C1 = NULL,
C2 = C1,
nlambda = 100,
nlambda2 = 50,
nfolds = 10,
seed = 1
)
Arguments
A |
length |
M |
|
Y |
length |
C1 |
optional numeric matrix of covariates to include in the outcome model.
Default is |
C2 |
optional numeric matrix of covariates to include in the mediator
model. Default is |
nlambda |
number of lambdas attempted in the adaptive LASSO.
See |
nlambda2 |
number of |
nfolds |
number of folds for cross-validation. See |
seed |
numeric random seed. |
Details
MedFix performs mediation analysis when there are multiple mediators by
applying adaptive LASSO to the outcome model. In order to fit the adaptive LASSO,
we first obtain an initial model fit using either LASSO (which deploys
the L1 penalty) or elastic net (which deploys both the L1 and L2 penalties)
depending on the provided nlambda2
. Estimates from this fit are then used
to compute the adaptive weights used in the adaptive LASSO. Once the final
adaptive LASSO estimates (\beta_m
) are obtained for the outcome model, estimates for
the p
mediator models (\alpha_a
) are obtained by linear regression. The
mediation contributions are computed as \alpha_a
times \beta_m
, and the p-value
is taken as the maximum of the \alpha_a
and beta_m
p-values. Last, the
global indirect effect is estimated by summing the mediation contributions, and the direct
effect is estimated by subtracting the global indirect effect from an estimate of
the total effect. This function is specific to applying MedFix to the special
case that there is only one exposure; for details on how to apply
MedFix when the exposures are high-dimensional, as proposed by the
authors, see the supplemental files of the referenced manuscript.
Value
A list containing:
-
contributions
: a data frame containing the estimates and p-values of the mediation contributions. -
effects
: a data frame containing the estimated direct, global mediation, and total effects.
References
Zhang, Q. High-Dimensional Mediation Analysis with Applications to Causal Gene Identification. Stat. Biosci. 14, 432-451 (2021).
Examples
A <- med_dat$Y
M <- med_dat$M
Y <- med_dat$Y
out <- mediate_medfix(A, M, Y, nlambda = 10, nlambda2 = 5, seed = 1)
out$effects
head(out$contributions)