Conduct K-fold cross validation for sparse mediation with elastic net with multiple tuning parameters

cv.sparse.mediation(X, M, Y, tol = 10^(-10), K = 5, max.iter = 100,
  lambda = log(1 + (1:15)/50), lambda2 = c(0.2, 0.5), alpha = 1,
  tau = c(1), multicore = 1, seednum = 1e+06, verbose = FALSE)

Arguments

X

One-dimensional predictor

M

Multivariate mediator

Y

Outcome

tol

(default -10^(-10)) convergence criterion

K

(default=5) number of cross-validation folds

max.iter

(default=100) maximum iteration

lambda

(default=log(1+(1:30)/100)) tuning parameter for L1 penalization

lambda2

(default=c(0.2,0.5)) tuning parameter for inverse covariance matrix sparsity. Only used if n>(2*V).

alpha

(defult=1) tuning parameter for L2 penalization

tau

(default=1) tuning parameter for differential weight for L1 penalty.

multicore

(default=1) number of multicore

seednum

(default=10000) seed number for cross validation

verbose

(default=FALSE)

Value

cv.lambda: optimal lambda

cv.tau: optimal tau

cv.alpha: optimal tau

cv.mse: minimum MSE value

mse: Array of MSE, length(alpha) x length(lambda) x length (tau)

lambda: vector of lambda

tau: vector of tau used

alpha: vector of alpha used

z: cross-valication results

References

TBA

Examples

library(sparsemediation) N=200 V=50 set.seed(1234) a = rep(0,V);a[1:3]<-1;b<-a X = rnorm(N) M = X %*% t(a)+ matrix(rnorm(N*V),N,V) Y = as.vector(X + M %*% b + rnorm(N)) #cvfit<-cv.sparse.mediation(X, M, Y, K = 4)