| GADAG_CV | R Documentation |
Function to run k-fold cross-validation for GADAG to optimally tune the parameter of penalization.
GADAG_CV(
X,
Lambdas = NULL,
n.folds = 10,
threshold = 0.1,
GADAG.control = list(n.gen = 250, tol.Shannon = 1e-06, max.eval = 1e+07, pop.size = 5 *
ncol(X), p.xo = 0.25, p.mut = 0.05),
grad.control = list(tol.obj.inner = 1e-06, max.ite.inner = 50),
ncores = 1,
plot.CV = 0
)
X |
Design matrix, with samples (n) in rows and variables (p) in columns. |
Lambdas |
Optional user-supplied lambda sequence. Default is null and GADAG chooses its own sequence. |
n.folds |
Number of folds for cross-validation (10 by default). Can be as large as the sample size (leave-one-out cross validation) but not recommended for large data sets. |
threshold |
Thresholding value for the estimated edges. |
GADAG.control |
A list containing parameters for controlling GADAG (termination conditions and inherent parameters of the Genetic Algortihm). Some parameters (n.gen, max.eval and pop.size) are particularly critical for reducing the computational time.
|
grad.control |
A list containing the parameters for controlling the inner optimization, i.e. the gradient descent.
|
ncores |
Number of cores (>0, depending on your computer). |
plot.CV |
If 1, plots the averaged cross validation error given sequence of lambdas. |
The function runs GADAG n.folds times for each of the tested lambdas to compute the best solution associated to each omitted fold. The error is accumulated and the averaged error over the folds is computed. The best lambda lambda.min corresponds to the one that minimizes the error.
A list with the following elements:
lambda.min Value of lambda that minimizes the averaged cross validation error error.CV.
lambda.1se Largest value of lambda such that error.CV is within 1 % of the minimum.
nzero Number of non-zero coefficients at each lambda.
Lambdas The values of lambda used in the fits.
error.CVThe averaged cross validation error.
Magali Champion [aut, cre], Victor Picheny [aut], Matthieu Vignes [aut]
M. Champion, V. Picheny, M. Vignes, Inferring large graphs using l-1 penalized likelihood, Statistics and Computing (2017).
GADAG, GADAG_Run, GADAG_Analyze.
#############################################################
# Loading toy data
#############################################################
data(toy_data)
# toy_data is a list of two matrices corresponding to a "star"
# DAG (node 1 activates all other nodes):
# - toy_data$X is a 100x10 design matrix
# - toy_data$G is the 10x10 adjacency matrix (ground trough)
#############################################################
# Tuning the parameter of penalization
#############################################################
# Simple run, whithout specifying GADAG parameters
## Not run:
GADAG_CV_results <- GADAG_CV(X=toy_data$X)
print(GADAG_CV_results$lambda.1se) # best lambda
## End(Not run)
# If desired, additional plot for the averaged cross validation
# error
## Not run:
GADAG_CV_results <- GADAG_CV(X=toy_data$X,plot.CV=1)
## End(Not run)
# Given the best lambda, re-run GADAG
## Not run:
GADAG_results <- GADAG_Run(X=toy_data$X, lambda=GADAG_CV_results$lambda.1se)
print(GADAG_results$G.best) # optimal adjacency matrix graph
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.