This function is an internal function
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | cv.glmnet.raw_cue(
x,
y,
weights,
offset,
lambda,
type.measure,
nfolds,
foldid,
alignment,
grouped,
keep,
parallel,
trace.it,
glmnet.call,
cv.call,
...
)
|
x |
x matrix as in glmnet. |
y |
response y as in glmnet. |
weights |
Observation weights; defaults to 1 per observation |
offset |
Offset vector (matrix) as in glmnet |
lambda |
Optional user-supplied lambda sequence; default is NULL, and glmnet chooses its own sequence |
type.measure |
loss to use for cross-validation. Currently five options, not all available for all models. The default is type.measure="deviance", which uses squared-error for gaussian models (a.k.a type.measure="mse" there), deviance for logistic and poisson regression, and partial-likelihood for the Cox model. type.measure="class" applies to binomial and multinomial logistic regression only, and gives misclassification error. type.measure="auc" is for two-class logistic regression only, and gives area under the ROC curve. type.measure="mse" or type.measure="mae" (mean absolute error) can be used by all models except the "cox"; they measure the deviation from the fitted mean to the response. type.measure="C" is Harrel's concordance measure, only available for cox models. |
nfolds |
number of folds - default is 10. Although nfolds can be as large as the sample size (leave-one-out CV), it is not recommended for large datasets. Smallest value allowable is nfolds=3 |
foldid |
an optional vector of values between 1 and nfold identifying what fold each observation is in. If supplied, nfold can be missing. |
alignment |
This is an experimental argument, designed to fix the problems users were having with CV, with possible values "lambda" (the default) else "fraction". With "lambda" the lambda values from the master fit (on all the data) are used to line up the predictions from each of the folds. In some cases this can give strange values, since the effective lambda values in each fold could be quite different. With "fraction" we line up the predictions in each fold according to the fraction of progress along the regularization. If in the call a lambda argument is also provided, alignment="fraction" is ignored (with a warning). |
grouped |
This is an experimental argument, with default TRUE, and can be ignored by most users. For all models except the "cox", this refers to computing nfolds separate statistics, and then using their mean and estimated standard error to describe the CV curve. If grouped=FALSE, an error matrix is built up at the observation level from the predictions from the nfold fits, and then summarized (does not apply to type.measure="auc"). For the "cox" family, grouped=TRUE obtains the CV partial likelihood for the Kth fold by subtraction; by subtracting the log partial likelihood evaluated on the full dataset from that evaluated on the on the (K-1)/K dataset. This makes more efficient use of risk sets. With grouped=FALSE the log partial likelihood is computed only on the Kth fold |
keep |
If keep=TRUE, a prevalidated array is returned containing fitted values for each observation and each value of lambda. This means these fits are computed with this observation and the rest of its fold omitted. The folid vector is also returned. Default is keep=FALSE. If relax=TRUE, then a list of such arrays is returned, one for each value of 'gamma'. Note: if the value 'gamma=1' is omitted, this case is included in the list since it corresponds to the original 'glmnet' fit. |
parallel |
If TRUE, use parallel foreach to fit each fold. Must register parallel before hand, such as doMC or others. See the example below. |
trace.it |
If trace.it=1, then progress bars are displayed; useful for big models that take a long time to fit. Limited tracing if parallel=TRUE |
... |
Other arguments that can be passed to glmnet |
gamma |
The values of the parameter for mixing the relaxed fit with the regularized fit, between 0 and 1; default is gamma = c(0, 0.25, 0.5, 0.75, 1) |
relax |
If TRUE, then CV is done with respect to the mixing parameter gamma as well as lambda. Default is relax=FALSE |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.