Title: | ADMM for High-Dimensional Mediation Models |
---|---|
Description: | We use the Alternating Direction Method of Multipliers (ADMM) for parameter estimation in high-dimensional, single-modality mediation models. To improve the sensitivity and specificity of estimated mediation effects, we offer the sure independence screening (SIS) function for dimension reduction. The available penalty options include Lasso, Elastic Net, Pathway Lasso, and Network-constrained Penalty. The methods employed in the package are based on Boyd, S., Parikh, N., Chu, E., Peleato, B., & Eckstein, J. (2011). <doi:10.1561/2200000016>, Fan, J., & Lv, J. (2008) <doi:10.1111/j.1467-9868.2008.00674.x>, Li, C., & Li, H. (2008) <doi:10.1093/bioinformatics/btn081>, Tibshirani, R. (1996) <doi:10.1111/j.2517-6161.1996.tb02080.x>, Zhao, Y., & Luo, X. (2022) <doi:10.4310/21-sii673>, and Zou, H., & Hastie, T. (2005) <doi:10.1111/j.1467-9868.2005.00503.x>. |
Authors: | Pei-Shan Yen [aut, cre] |
Maintainer: | Pei-Shan Yen <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.0 |
Built: | 2025-01-30 04:06:57 UTC |
Source: | https://github.com/psyen0824/hdmaadmm |
HDMAADMM
PackageThis package enables the estimation of single-modality high-dimensional mediation models. We employ penalized maximum likelihood and solve the estimation using the Alternating Direction Method of Multipliers (ADMM) to provide high-dimensional mediator estimates. To improve the sensitivity and specificity of non-zero mediators, we offer the sure independence screening (SIS) function for dimension reduction. The available penalty options include Lasso, Elastic Net, Pathway Lasso, and Network-constrained Penalty.
Maintainer: Pei-Shan Yen [email protected] (ORCID)
Authors:
Ching-Chuan Chen [email protected] (ORCID)
Tibshirani, R. (1996). Regression Shrinkage and Selection via the Lasso. Journal of the Royal Statistical Society. Series B (Methodological), 58(1), 267–288.
Zou, H., & Hastie, T. (2005). Regularization and Variable Selection via the Elastic Net. Journal of the Royal Statistical Society. Series B (Statistical Methodology), 67(2), 301–320.
Li, C., Li, H. (2008). Network-constrained regularization and variable selection for analysis of genomic data, Bioinformatics, 24(9), 1175–1182,
Zhao, Y., & Luo, X. (2022). Pathway Lasso: pathway estimation and selection with high-dimensional mediators. Statistics and its interface, 15(1), 39.
Useful links:
Cross Validation for High-dimensional Single Mediation Models
cvSingleModalityAdmm( X, Y, M1, numFolds = 10, typeMeasure = "rmse", lambda1a, lambda1b, lambda1g, lambda2a, lambda2b, rho = 1, penalty = "ElasticNet", penaltyParameterList = list(), SIS = FALSE, SISThreshold = 2, maxIter = 3000, tol = 1e-04, verbose = FALSE, debug = FALSE )
cvSingleModalityAdmm( X, Y, M1, numFolds = 10, typeMeasure = "rmse", lambda1a, lambda1b, lambda1g, lambda2a, lambda2b, rho = 1, penalty = "ElasticNet", penaltyParameterList = list(), SIS = FALSE, SISThreshold = 2, maxIter = 3000, tol = 1e-04, verbose = FALSE, debug = FALSE )
X |
The matrix of independent variables (exposure/treatment/group). |
Y |
The vector of dependent variable (outcome response). |
M1 |
The single-modality mediator. |
numFolds |
The number of folds. The default is 10. Although nfolds can be as large as the sample size (leave-one-out CV), it is not recommended for large datasets. Smallest value allowable is nfolds=3. |
typeMeasure |
Default is "rmse". |
rho , lambda1g , lambda1a , lambda1b , lambda2a , lambda2b , penaltyParameterList
|
Allow to put sequences for each parameter. Please refer to the function, |
penalty , SIS , SISThreshold , maxIter , tol , verbose , debug
|
Please refer to the function, |
An cvSingleModalityAdmm
object which is a matrix containing all the combinations of parameter sequences with an additional column called measure
.
## Generate Empirical Data simuData <- modalityMediationDataGen(seed = 20231201) ## Cross-Validation for ElasticNet penalty cvElasticNetResults <- cvSingleModalityAdmm( X = simuData$MediData$X, Y = simuData$MediData$Y, M1 = simuData$MediData$M1, numFolds = 5, typeMeasure = "rmse", rho = c(0.9, 1, 1.1), lambda1a = c(0.1, 0.5, 1), lambda1b = c(0.1, 0.3), lambda1g = c(1, 2), lambda2a = c(0.5, 1), lambda2b = c(0.5, 1), penalty = "ElasticNet" ) ## Cross-Validation for Pathway Lasso penalty (lambda2a, lambda2b are not tuned.) cvPathwayLassoResults <- cvSingleModalityAdmm( X = simuData$MediData$X, Y = simuData$MediData$Y, M1 = simuData$MediData$M1, numFolds = 5, typeMeasure = "rmse", rho = c(0.9, 1, 1.1), lambda1a = c(0.1, 0.5, 1), lambda1b = c(0.1, 0.3), lambda1g = c(1, 2), lambda2a = 1, lambda2b = 1, penalty = "PathwayLasso", penaltyParameterList = list(kappa = c(0.5, 1), nu = c(1, 2)) )
## Generate Empirical Data simuData <- modalityMediationDataGen(seed = 20231201) ## Cross-Validation for ElasticNet penalty cvElasticNetResults <- cvSingleModalityAdmm( X = simuData$MediData$X, Y = simuData$MediData$Y, M1 = simuData$MediData$M1, numFolds = 5, typeMeasure = "rmse", rho = c(0.9, 1, 1.1), lambda1a = c(0.1, 0.5, 1), lambda1b = c(0.1, 0.3), lambda1g = c(1, 2), lambda2a = c(0.5, 1), lambda2b = c(0.5, 1), penalty = "ElasticNet" ) ## Cross-Validation for Pathway Lasso penalty (lambda2a, lambda2b are not tuned.) cvPathwayLassoResults <- cvSingleModalityAdmm( X = simuData$MediData$X, Y = simuData$MediData$Y, M1 = simuData$MediData$M1, numFolds = 5, typeMeasure = "rmse", rho = c(0.9, 1, 1.1), lambda1a = c(0.1, 0.5, 1), lambda1b = c(0.1, 0.3), lambda1g = c(1, 2), lambda2a = 1, lambda2b = 1, penalty = "PathwayLasso", penaltyParameterList = list(kappa = c(0.5, 1), nu = c(1, 2)) )
Fitted Response of SingleModalityAdmm Fits
## S3 method for class 'SingleModalityAdmm' fitted(object, ...)
## S3 method for class 'SingleModalityAdmm' fitted(object, ...)
object |
A fitted obejct of class inheriting from |
... |
further arguments passed to or from other methods. |
fitted.SingleModalityAdmm returns a vector which is fitted values.
Function Generate Laplacian Matrix
generateLaplacianMatrix(X, Y, M1, type = "beta", interaction = FALSE)
generateLaplacianMatrix(X, Y, M1, type = "beta", interaction = FALSE)
X , Y , M1
|
The input data for the single modality mediation model. Details see |
type |
A string to specify the generated Laplacian matrix is for |
interaction |
A logical value to specify whether to refer interation effect. |
Data Generation for High-Dimensional Mediation Model
modalityMediationDataGen( n = 100, p = 50, sigmaY = 1, sizeNonZero = c(3, 3, 4), alphaMean = c(6, 4, 2), alphaSd = 0.1, betaMean = c(6, 4, 2), betaSd = 0.1, sigmaM1 = NULL, gamma = 3, laplacianA = TRUE, laplacianB = TRUE, laplacianInteractionA = FALSE, laplacianInteractionB = FALSE, seed = 20231201 )
modalityMediationDataGen( n = 100, p = 50, sigmaY = 1, sizeNonZero = c(3, 3, 4), alphaMean = c(6, 4, 2), alphaSd = 0.1, betaMean = c(6, 4, 2), betaSd = 0.1, sigmaM1 = NULL, gamma = 3, laplacianA = TRUE, laplacianB = TRUE, laplacianInteractionA = FALSE, laplacianInteractionB = FALSE, seed = 20231201 )
n |
The number of subjects for the high-dimensional mediation model) |
p |
The number of high-dimensional mediators. |
sigmaY |
The argument "sigmaY" represents the standard deviation (SD) of the error distribution for the dependent variable. |
sizeNonZero |
The number of nonzero mediators. Here, we provide simulated scenarios that could produce large, medium, and small mediated effects, generating from a normal distribution. |
alphaMean , alphaSd
|
The mean and SD vector of the effect between the mediator and independent variable. |
betaMean , betaSd
|
The mean and SD vector of the effect between the mediator and dependent variable. |
sigmaM1 |
The covariance matrix of the error distribution among mediators. Default is |
gamma |
The true value of direct effect. |
laplacianA , laplacianB
|
Default is TRUE. These two logical values indicate whether to generate the laplacian matrix for network penalty. Details see |
laplacianInteractionA , laplacianInteractionB
|
A logical value to specify to use interaction term. Details see |
seed |
The random seed. Default is NULL to use the current seed. |
A object with three elements.
MediData: The simulated data for high-dimensional mediation model.
MediPara: The true value for mediated effect and direct effect.
Info : The output includes random seed, parameter setting, and Laplacian matrix for generating mediation model.
simuData <- modalityMediationDataGen(seed = 20231201)
simuData <- modalityMediationDataGen(seed = 20231201)
Predict Method for SingleModalityAdmm Fits
## S3 method for class 'SingleModalityAdmm' predict(object, newdata, ...)
## S3 method for class 'SingleModalityAdmm' predict(object, newdata, ...)
object |
A fitted obejct of class inheriting from |
newdata |
Default is |
... |
further arguments passed to or from other methods. |
predict.SingleModalityAdmm returns a vector which is the predicted values based on newdata
.
The single modality mediation model is expressed as below:
Eq. 1:
Eq. 2:
The penalty options are listed as below:
Elastic Net: +
+
Pathway Lasso: +
+
Network: +
+
Pathway Network: +
+
where
and
which and
are the laplacian matrices which we use
laplacianMatrixA
and laplacianMatrixB
to represent in the code.
Note that in the original work of the Pathway Lasso, certain restrictions are defined for the tuning parameters,
including , and
.
In addition,
and
must be at least 0.5 to ensure that the penalty remains convex for optimization purpose.
singleModalityAdmm( X, Y, M1, rho = 1, lambda1a, lambda1b, lambda1g, lambda2a, lambda2b, penalty = "ElasticNet", penaltyParameterList = list(), SIS = FALSE, SISThreshold = 2, maxIter = 3000L, tol = 0.001, verbose = FALSE, verboseOptions = list(numIter = 10L, numAlpha = 1L, numBeta = 1L, numGamma = 1L) )
singleModalityAdmm( X, Y, M1, rho = 1, lambda1a, lambda1b, lambda1g, lambda2a, lambda2b, penalty = "ElasticNet", penaltyParameterList = list(), SIS = FALSE, SISThreshold = 2, maxIter = 3000L, tol = 0.001, verbose = FALSE, verboseOptions = list(numIter = 10L, numAlpha = 1L, numBeta = 1L, numGamma = 1L) )
X |
The matrix of independent variables (exposure/treatment/group). |
Y |
The vector of dependent variable (outcome response). |
M1 |
The single modality mediator. |
rho |
The augmented Lagrangian parameter for ADMM. |
lambda1a |
The L1-norm penalty for the effect between mediator and independent variables. |
lambda1b |
The L1-norm penalty for the effect between mediator and dependent variable. |
lambda1g |
The L1-norm penalty for the direct effect. Default is 10 to address overestimate issue. |
lambda2a |
The L2-norm penalty for the effect between mediator and independent variables. |
lambda2b |
The L2-norm penalty for the effect between mediator and dependent variable. |
penalty |
A string to specify the penalty. Default is |
penaltyParameterList |
|
SIS |
A logical value to specify whether to perform sure independence screening (SIS). |
SISThreshold |
The threshold value for the target reduced dimension for mediators. The default is "2," which reduces the dimension to 2*n/log(n). |
maxIter |
The maximum iterations. Default is |
tol |
The tolerance of convergence threshold. Default is |
verbose |
A logical value to specify whether to print the iteration process. |
verboseOptions |
A list of values:
|
A object, SingleModalityAdmm, with three elements.
gamma: estimated direct effect.
alpha: estimate effect between mediator and independent variables.
beta : estimate effect between mediator and dependent variable.
## Generate Empirical Data simuData <- modalityMediationDataGen(seed = 20231201) ## Parameter Estimation for ElasticNet penalty modelElasticNet <- singleModalityAdmm( X = simuData$MediData$X, Y = simuData$MediData$Y, M1 = simuData$MediData$M1, rho = 1, lambda1a = 1, lambda1b = 0.1, lambda1g = 2, lambda2a = 1, lambda2b = 1, penalty = "ElasticNet" ) # fitted & predict fitted(modelElasticNet) predict(modelElasticNet, matrix(c(0, 1), ncol=1)) ## Parameter Estimation for Pathway Lasso penalty modelPathwayLasso <- singleModalityAdmm( X = simuData$MediData$X, Y = simuData$MediData$Y, M1 = simuData$MediData$M1, rho = 1, lambda1a = 1, lambda1b = 0.1, lambda1g = 2, lambda2a = 1, lambda2b = 1, penalty = "PathwayLasso", penaltyParameterList = list(kappa = 1) ) ## Parameter Estimation for Network penalty modelNetwork <- singleModalityAdmm( X = simuData$MediData$X, Y = simuData$MediData$Y, M1 = simuData$MediData$M1, rho = 1, lambda1a = 1, lambda1b = 0.1, lambda1g = 2, lambda2a = 1, lambda2b = 1, penalty = "Network", penaltyParameterList = list( laplacianMatrixA = simuData$Info$laplacianMatrixA, laplacianMatrixB = simuData$Info$laplacianMatrixB ) ) ## Parameter Estimation for Pathway Network penalty modelPathwayNetwork <- singleModalityAdmm( X = simuData$MediData$X, Y = simuData$MediData$Y, M1 = simuData$MediData$M1, rho = 1, lambda1a = 1, lambda1b = 0.1, lambda1g = 2, lambda2a = 1, lambda2b = 1, penalty = "Network", penaltyParameterList = list( kappa = 1, lambda2aStar = 1, lambda2bStar = 1, laplacianMatrixA = simuData$Info$laplacianMatrixA, laplacianMatrixB = simuData$Info$laplacianMatrixB ) ) ## Parameter Estimation for Network penalty with a customized Laplacian matrix set.seed(20231201) p <- ncol(simuData$MediData$M1) Wa <- matrix(0, nrow = p, ncol = p) Wa[lower.tri(Wa)] <- runif(p*(p-1)/2, 0, 1) Wa[upper.tri(Wa)] <- t(Wa)[upper.tri(Wa)] diag(Wa) <- 1 La <- weightToLaplacian(Wa) Wb <- matrix(0, nrow = p, ncol = p) Wb[lower.tri(Wb)] <- runif(p*(p-1)/2, 0, 1) Wb[upper.tri(Wb)] <- t(Wb)[upper.tri(Wb)] diag(Wb) <- 1 Lb <- weightToLaplacian(Wb) modelNetwork <- singleModalityAdmm( X = simuData$MediData$X, Y = simuData$MediData$Y, M1 = simuData$MediData$M1, rho = 1, lambda1a = 1, lambda1b = 0.1, lambda1g = 2, lambda2a = 1, lambda2b = 1, penalty = "Network", penaltyParameterList = list( laplacianMatrixA = La, laplacianMatrixB = Lb ) ) ## With sure independence screening simuData <- modalityMediationDataGen( n = 50, p = 1000, seed = 20231201, laplacianA = FALSE, laplacianB = FALSE ) ## Parameter Estimation for ElasticNet penalty modelElasticNetSIS <- singleModalityAdmm( X = simuData$MediData$X, Y = simuData$MediData$Y, M1 = simuData$MediData$M1, rho = 1, lambda1a = 1, lambda1b = 0.1, lambda1g = 2, lambda2a = 1, lambda2b = 1, penalty = "ElasticNet", SIS = TRUE ) fitted(modelElasticNetSIS) predict(modelElasticNetSIS, matrix(c(0, 1), ncol=1))
## Generate Empirical Data simuData <- modalityMediationDataGen(seed = 20231201) ## Parameter Estimation for ElasticNet penalty modelElasticNet <- singleModalityAdmm( X = simuData$MediData$X, Y = simuData$MediData$Y, M1 = simuData$MediData$M1, rho = 1, lambda1a = 1, lambda1b = 0.1, lambda1g = 2, lambda2a = 1, lambda2b = 1, penalty = "ElasticNet" ) # fitted & predict fitted(modelElasticNet) predict(modelElasticNet, matrix(c(0, 1), ncol=1)) ## Parameter Estimation for Pathway Lasso penalty modelPathwayLasso <- singleModalityAdmm( X = simuData$MediData$X, Y = simuData$MediData$Y, M1 = simuData$MediData$M1, rho = 1, lambda1a = 1, lambda1b = 0.1, lambda1g = 2, lambda2a = 1, lambda2b = 1, penalty = "PathwayLasso", penaltyParameterList = list(kappa = 1) ) ## Parameter Estimation for Network penalty modelNetwork <- singleModalityAdmm( X = simuData$MediData$X, Y = simuData$MediData$Y, M1 = simuData$MediData$M1, rho = 1, lambda1a = 1, lambda1b = 0.1, lambda1g = 2, lambda2a = 1, lambda2b = 1, penalty = "Network", penaltyParameterList = list( laplacianMatrixA = simuData$Info$laplacianMatrixA, laplacianMatrixB = simuData$Info$laplacianMatrixB ) ) ## Parameter Estimation for Pathway Network penalty modelPathwayNetwork <- singleModalityAdmm( X = simuData$MediData$X, Y = simuData$MediData$Y, M1 = simuData$MediData$M1, rho = 1, lambda1a = 1, lambda1b = 0.1, lambda1g = 2, lambda2a = 1, lambda2b = 1, penalty = "Network", penaltyParameterList = list( kappa = 1, lambda2aStar = 1, lambda2bStar = 1, laplacianMatrixA = simuData$Info$laplacianMatrixA, laplacianMatrixB = simuData$Info$laplacianMatrixB ) ) ## Parameter Estimation for Network penalty with a customized Laplacian matrix set.seed(20231201) p <- ncol(simuData$MediData$M1) Wa <- matrix(0, nrow = p, ncol = p) Wa[lower.tri(Wa)] <- runif(p*(p-1)/2, 0, 1) Wa[upper.tri(Wa)] <- t(Wa)[upper.tri(Wa)] diag(Wa) <- 1 La <- weightToLaplacian(Wa) Wb <- matrix(0, nrow = p, ncol = p) Wb[lower.tri(Wb)] <- runif(p*(p-1)/2, 0, 1) Wb[upper.tri(Wb)] <- t(Wb)[upper.tri(Wb)] diag(Wb) <- 1 Lb <- weightToLaplacian(Wb) modelNetwork <- singleModalityAdmm( X = simuData$MediData$X, Y = simuData$MediData$Y, M1 = simuData$MediData$M1, rho = 1, lambda1a = 1, lambda1b = 0.1, lambda1g = 2, lambda2a = 1, lambda2b = 1, penalty = "Network", penaltyParameterList = list( laplacianMatrixA = La, laplacianMatrixB = Lb ) ) ## With sure independence screening simuData <- modalityMediationDataGen( n = 50, p = 1000, seed = 20231201, laplacianA = FALSE, laplacianB = FALSE ) ## Parameter Estimation for ElasticNet penalty modelElasticNetSIS <- singleModalityAdmm( X = simuData$MediData$X, Y = simuData$MediData$Y, M1 = simuData$MediData$M1, rho = 1, lambda1a = 1, lambda1b = 0.1, lambda1g = 2, lambda2a = 1, lambda2b = 1, penalty = "ElasticNet", SIS = TRUE ) fitted(modelElasticNetSIS) predict(modelElasticNetSIS, matrix(c(0, 1), ncol=1))
Helper function to convert Weight Matrix to Laplacian Matrix
weightToLaplacian(W)
weightToLaplacian(W)
W |
The weight matrix for n nodes which should be |
L n
xn
Laplacian matrix.
set.seed(20231201) p <- 5 W <- matrix(0, nrow = p, ncol = p) W[lower.tri(W)] <- runif(p*(p-1)/2, 0, 1) W[upper.tri(W)] <- t(W)[upper.tri(W)] diag(W) <- 1 (L <- weightToLaplacian(W))
set.seed(20231201) p <- 5 W <- matrix(0, nrow = p, ncol = p) W[lower.tri(W)] <- runif(p*(p-1)/2, 0, 1) W[upper.tri(W)] <- t(W)[upper.tri(W)] diag(W) <- 1 (L <- weightToLaplacian(W))