cv.lambda1 {dpcid} | R Documentation |
K-fold Crossvalidation for the ridge step
Description
K-fold crossvalidation for the choice of the lambda1.
Usage
cv.lambda1(A,B, nfold,seq_lambda1,niter=1000,tol=1e-6,scaling=FALSE)
Arguments
A |
An observed dataset from the first condition. |
B |
An observed dataset from the second condition. |
nfold |
the number of folds in the crossvalidation(i.e., K in K-fold cross validation) |
seq_lambda1 |
A sequence of tuning parameters for the ridge penalty |
niter |
A total number of iterations in the block-wise coordinate descent. |
tol |
A tolerance for the convergence. |
scaling |
a logical flag for scaling variable to have unit variance. Default is FALSE. |
Details
cv.lambda1 returns a vector of the K-fold crossvalidated errors and matrices of the initial estimates of the precision matrices.
Value
cv |
A vector of crossvalidated errors corresponding to a given sequence of tuning paramters. |
pm1 |
A matrix of the inverse of the linear shrinkage covariance estimates for the first condition. |
pm2 |
A matrix of the inverse of the linear shrinkage covariance estimates for the second condition. |
References
Yu, D., Lee, S. H., Lim, J., Xiao, G., Craddock, R. C., and Biswal, B. B. (2018). Fused Lasso Regression for Identifying Differential Correlations in Brain Connectome Graphs. Statistical Analysis and Data Mining, 11, 203–226.
Examples
library(MASS)
## True precision matrix
omega1 <- matrix(0,5,5)
omega1[1,2] <- omega1[1,3] <- omega1[1,4] <- 1
omega1[2,3] <- omega1[3,4] <- 1.5
omega1 <- t(omega1) + omega1
diag(omega1) <- 3
omega2 <- matrix(0,5,5)
omega2[1,3] <- omega2[1,5] <- 1.5
omega2[2,3] <- omega2[2,4] <- 1.5
omega2 <- t(omega2) + omega2
diag(omega2) <- 3
Sig1 = solve(omega1)
Sig2 = solve(omega2)
X1 = mvrnorm(50,rep(0,5),Sig1)
X2 = mvrnorm(50,rep(0,5),Sig2)
nfold = 5
seq_lam1 = seq(0.5,3,by=0.5)
cv_vec = cv.lambda1(X1,X2,nfold,seq_lam1,niter=1000,tol=1e-6)$cv