cvTune | R Documentation |
This function selects the optimal set of tuning parameters for the Random Covariance Clustering Model (RCCM) based on cross-validation.
cvTune( x, G, lambs, methods = c("RCCM", "GGL", "GLasso", "FGL", "RCM"), folds = 5 )
x |
List of K data matrices each of dimension n_k x p |
G |
Number of groups or clusters. |
lambs |
A data frame of candidate tuning parameter values with three columns: lambda1, lambda2, and lambda3. |
methods |
Methods to implement cross-validation for. Must be a vector containing one or more of "FGL", "GGL", "GLasso", "RCCM", or "RCM". |
folds |
Number of folds to use for cross-validation. |
A data frame of optimally selected tuning parameter values and the correspond average negative log-likelihoods across the folds number of folds with five columns: lambda1, lambda2, lambda3, nll, and method.
Andrew DiLernia
# Generate data with 2 clusters with 12 and 10 subjects respectively, # 15 variables for each subject, 100 observations for each variable for each subject, # the groups sharing about 50% of network connections, and 10% of differential connections # within each group set.seed(1994) G <- 2 myData <- rccSim(G = G, clustSize = 10, p = 10, n = 177, overlap = 0.20, rho = 0.10) # Analyze simulated data with RCCM & GLasso using 5-fold CV lambdas <- expand.grid(lambda1 = c(5, 10, 15), lambda2 = c(50, 100), lambda3 = 0.10) cvLambdas <- cvTune(x = myData$simDat, G = G, lambs = lambdas, methods = c("RCCM", "GLasso"), folds = 5) # RCCM with CV selected tuning parameters resRCCM <- rccm(x = myData$simDat, lambda1 = cvLambdas[which(cvLambdas$method == "RCCM"), ]$lambda1, lambda2 = cvLambdas[which(cvLambdas$method == "RCCM"), ]$lambda2, lambda3 = cvLambdas[which(cvLambdas$method == "RCCM"), ]$lambda3, nclusts = 2) # GLasso with CV selected tuning parameters resGLasso <- lapply(myData$simDat, FUN = function(x) { glasso::glasso(cov(x), rho = cvLambdas[which(cvLambdas$method == "GLasso"), ]$lambda1, penalize.diagonal = FALSE)$wi})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.