nlasso_cv {natural} | R Documentation |
Cross-validation for natural lasso
Description
Provide natural lasso estimate (of the error standard deviation) using cross-validation to select the tuning parameter value The output also includes the cross-validation result of the naive estimate and the degree of freedom adjusted estimate of the error standard deviation.
Usage
nlasso_cv(x, y, lambda = NULL, intercept = TRUE, nlam = 100,
flmin = 0.01, nfold = 5, foldid = NULL, thresh = 1e-08,
glmnet_output = NULL)
Arguments
x |
An |
y |
A response vector of size |
lambda |
A user specified list of tuning parameter. Default to be NULL, and the program will compute its own |
intercept |
Indicator of whether intercept should be fitted. Default to be |
nlam |
The number of |
flmin |
The ratio of the smallest and the largest values in |
nfold |
Number of folds in cross-validation. Default value is 5. If each fold gets too view observation, a warning is thrown and the minimal |
foldid |
A vector of length |
thresh |
Threshold value for underlying optimization algorithm to claim convergence. Default to be |
glmnet_output |
Should the estimate be computed using a user-specified output from |
Value
A list object containing:
n
andp
:The dimension of the problem.
lambda
:The path of tuning parameter used.
beta
:Estimate of the regression coefficients, in the original scale, corresponding to the tuning parameter selected by cross-validation.
a0
:Estimate of intercept
mat_mse
:The estimated prediction error on the test sets in cross-validation. A matrix of size
nlam
bynfold
. Ifglmnet_output
is notNULL
, thenmat_mse
will be NULL.cvm
:The averaged estimated prediction error on the test sets over K folds.
cvse
:The standard error of the estimated prediction error on the test sets over K folds.
ibest
:The index in
lambda
that attains the minimal mean cross-validated error.foldid
:Fold assignment. A vector of length
n
.nfold
:The number of folds used in cross-validation.
sig_obj
:Natural lasso estimate of standard deviation of the error, with the optimal tuning parameter selected by cross-validation.
sig_obj_path
:Natural lasso estimates of standard deviation of the error. A vector of length
nlam
.sig_naive
:Naive estimates of the error standard deviation based on lasso regression, i.e.,
||y - X \hat{\beta}||_2 / \sqrt n
, selected by cross-validation.sig_naive_path
:Naive estimate of standard deviation of the error based on lasso regression. A vector of length
nlam
.sig_df
:Degree-of-freedom adjusted estimate of standard deviation of the error, selected by cross-validation. See Reid, et, al (2016).
sig_df_path
:Degree-of-freedom adjusted estimate of standard deviation of the error. A vector of length
nlam
.type
:whether the output is of a natural or an organic lasso.
See Also
Examples
set.seed(123)
sim <- make_sparse_model(n = 50, p = 200, alpha = 0.6, rho = 0.6, snr = 2, nsim = 1)
nl_cv <- nlasso_cv(x = sim$x, y = sim$y[, 1])