cv.clogitL1: Cross validation of conditional logistic regression with...

Description Usage Arguments Details Value References See Also Examples

Description

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

Usage

1
 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 λ.

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
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)

Example output

Loading required package: Rcpp

clogitL1 documentation built on May 2, 2019, 3 p.m.