glinternet.cv {glinternet} | R Documentation |
Cross-validation for glinternet
Description
Does k-fold cross validation for glinternet and returns a
value of lambda
.
Usage
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)
Arguments
X |
|
Y |
Target |
numLevels |
Number of levels |
nFolds |
Number of folds - default is 10. |
lambda |
|
nLambda |
|
lambdaMinRatio |
|
interactionCandidates |
|
interactionPairs |
|
screenLimit |
|
family |
|
tol |
|
maxIter |
|
verbose |
|
numCores |
|
Details
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.
Value
An object of class glinternet.cv
with the components
call |
The user function call. |
glinternetFit |
Glinternet object fitted on the full data using a
lambda sequence that terminates at |
fitted |
Vector for fitted values (same length as |
activeSet |
|
betahat |
Unstandardized coefficients for the variables in
|
lambda |
The actual sequence of |
lambdaHat |
The value of |
lambdaHat1Std |
The largest value of |
cvErr |
The vector of cross validation errors. Same length as
|
cvErrStd |
Standard deviation for cv errors across the
|
family |
The response type. |
numLevels |
Input number of levels for each variable. |
nFolds |
The number of folds used. |
Author(s)
Michael Lim and Trevor Hastie
Maintainer: Michael Lim michael626@gmail.com
See Also
glinternet
, predict.glinternet
,
predict.glinternet.cv
, plot.glinternet.cv
Examples
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)