View source: R/rlib_multi_util.R
Fit y ~ x + 1 with elastic net using nested cross-validation. By "nested", we mean determine MSE using multiple partitions (K) instead of only one in vanilla cross-validation. The procedure is: 1. determine lambda sequence and fit y ~ x at different lambda values; 2. take in K copies of the partition of the input (one of the input, cv_fold_ids). For instance, 5-fold partition if you'd like 5-fold CV; 3. compute CV MSE at each lambda value for each fold in each partition; 4. compute CV MSE for each lambda as the mean of CV MSE of all partitions; 5. select the best model with the smallest CV MSE at that lambda.
1 | do_elastic_net(cis_gt, expr_adj, n_folds, cv_fold_ids, alpha, ...)
|
cis_gt |
x (genotype matrix, sample x variant) |
expr_adj |
y (expression level vector) |
n_folds |
cross-validation fold |
cv_fold_ids |
K partitions with N-fold (sample x K, where each column is partition of samples into N parts represented by the index of each part) |
alpha |
alpha parameter in glmnet |
... |
additional arguments passed to cv.glmnet |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.