Does k-fold cross validation for glinternet and returns a
value of lambda
.
glinternet.cv(X, Y, numLevels, nFolds = 10, lambda=NULL, nLambda=50,
lambdaMinRatio=0.01, interactionCandidates=NULL, interactionPairs=NULL,
screenLimit=NULL, family=c("gaussian", "binomial"), tol=1e-5, maxIter=5000,
verbose=FALSE, numCores=1)
X
matrix as in glinternet
.
Target Y
as in glinternet
.
Number of levels numLevels
as in glinternet
.
Number of folds - default is 10.
lambda
as in glinternet
.
nLambda
as in glinternet
.
lambdaMinRatio
as in glinternet
.
interactionCandidates
as in
glinternet
.
interactionPairs
as in glinternet
.
screenLimit
as in glinternet
.
family
as in glinternet
.
tol
as in glinternet
.
maxIter
as in glinternet
.
verbose
as in glinternet
.
numCores
as in glinternet
.
An object of class glinternet.cv
with the components
The user function call.
Glinternet object fitted on the full data using a
lambda sequence that terminates at lambdaHat
.
Vector for fitted values (same length as Y
). This
is from the model fitted at lambdaHat
.
activeSet
is a list variables found for the
model fitted with lambdaHat
.
Unstandardized coefficients for the variables in
activeSet
.
The actual sequence of lambda
values used for the
cross validation.
The value of lambda
that minimizes the cv
error curve.
The largest value of lambda
that produces
a cv error that is within 1 standard deviation of the minimum cv
error. This will always be at least as large as lambdaHat
.
The vector of cross validation errors. Same length as
lambda
.
Standard deviation for cv errors across the
nFolds
folds.
The response type.
Input number of levels for each variable.
The number of folds used.
The lambda
sequence is computed using all the
data. nFolds
models are fit, each time with one of the folds
omitted. The error is accumulated, and the average error and standard deviation over the
folds is computed. The lambda
value that minimizes the average
error is returned, and a model with this lambda
is fit to the
full data set.
glinternet
, predict.glinternet
,
predict.glinternet.cv
, plot.glinternet.cv
# NOT RUN {
Y = rnorm(100)
numLevels = sample(1:5, 10, replace=TRUE)
X = sapply(numLevels, function(x) if (x==1)
rnorm(100) else sample(0:(x-1), 100, replace=TRUE))
fit = glinternet.cv(X, Y, numLevels, nFolds=3)
# }
Run the code above in your browser using DataLab