cv.clogitL1 {clogitL1}R Documentation

Cross validation of conditional logistic regression with elastic net penalties

Description

Find the best of a sequence of conditional logistic regression models with lasso or elastic net penalties using cross validation

Usage

 cv.clogitL1 (clObj, numFolds=10)

Arguments

clObj

an object of type clogitL1 on which to do cross validation.

numFolds

the number of folds used in cross validation. Defaults to the minimum of 10 or the number of observations

Details

Performs numFolds-fold cross validation on an object of type clogitL1. Using the sequence of regularisation parameters generated by clObj, the function chooses strata to leave out randomly. The penalised conditional logistic regression model is fit to the non-left-out strata in turn and its deviance compared to an out-of-sample deviance computed on the left-out strata. Fitting models to individual non-left-out strata proceeds using the cyclic coordinate descent-warm start-strong rule type algorithm used in clogitL1, only with a prespecified sequence of \lambda.

Value

An object of type cv.clogitL1 with the following fields:

cv_dev

matrix of size numLambda-by-numFolds containing the CV deviance in each fold for each value of the regularisation parameter.

lambda

vector of regularisation parameters.

folds

vector showing the folds membership of each observation.

mean_cv

vector containing mean CV deviances for each value of the regularisation parameter.

se_cv

vector containing an estimate of the standard error of the CV deviance at each value of the regularisation parameter.

minCV_lambda

value of the regularisation parameter at which we have minimum mean_cv

minCV1se_lambda

value of the regularisation parameter corresponding to the 1-SE rule. Selects the simplest model with estimate CV within 1 standard deviation of the minimum cv.

nz_beta

number of nonzero parameter estimates at each value of the regularisation parameter.

References

http://www.jstatsoft.org/v58/i12/

See Also

clogitL1, plot.cv.clogitL1

Examples

set.seed(145)

# data parameters
K = 10 # number of strata
n = 5 # number in strata
m = 2 # cases per stratum
p = 20 # predictors

# generate data
y = rep(c(rep(1, m), rep(0, n-m)), K)
X = matrix (rnorm(K*n*p, 0, 1), ncol = p) # pure noise
strata = sort(rep(1:K, n))

par(mfrow = c(1,2))
# fit the conditional logistic model
clObj = clogitL1(y=y, x=X, strata)
plot(clObj, logX=TRUE)

# cross validation
clcvObj = cv.clogitL1(clObj)
plot(clcvObj)

[Package clogitL1 version 1.5 Index]