Learn R Programming

natural (version 0.9.0)

olasso_cv: Cross-validation for organic lasso

Description

Provide organic lasso estimate (of the error standard deviation) using cross-validation to select the tuning parameter value

Usage

olasso_cv(x, y, lambda = NULL, intercept = TRUE, nlam = 100,
  flmin = 0.01, nfold = 5, foldid = NULL, thresh = 1e-08)

Arguments

x

An n by p design matrix. Each row is an observation of p features.

y

A response vector of size n.

lambda

A user specified list of tuning parameter. Default to be NULL, and the program will compute its own lambda path based on nlam and flmin.

intercept

Indicator of whether intercept should be fitted. Default to be TRUE.

nlam

The number of lambda values. Default value is 100.

flmin

The ratio of the smallest and the largest values in lambda. The largest value in lambda is usually the smallest value for which all coefficients are set to zero. Default to be 1e-2.

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 nfold = 3 is used.

foldid

A vector of length n representing which fold each observation belongs to. Default to be NULL, and the program will generate its own randomly.

thresh

Threshold value for underlying optimization algorithm to claim convergence. Default to be 1e-8.

Value

A list object containing:

n and p:

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 by nfold

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:

Organic lasso estimate of the error standard deviation, selected by cross-validation.

sig_obj_path:

Organic lasso estimates of the error standard deviation. A vector of length nlam.

type:

whether the output is of a natural or an organic lasso.

See Also

olasso_path, olasso

Examples

Run this code
# NOT RUN {
set.seed(123)
sim <- make_sparse_model(n = 50, p = 200, alpha = 0.6, rho = 0.6, snr = 2, nsim = 1)
ol_cv <- olasso_cv(x = sim$x, y = sim$y[, 1])
# }

Run the code above in your browser using DataLab