Performs k-fold cross validation for penalized regression models over a grid of values of regularization parameter lambda.
Arguments
- data
an
dataframe
orlist
object that contains the variables in the model.- Y.char
name of the response variable from
data
as a character string, as inpp.lasso
function.- Z.char
names of covariates from
data
as vector of character strings, as inpp.lasso
function.- prov.char
name of provider IDs variable from
data
as a character string, as inpp.lasso
function.- penalize.x
a vector indicates whether the corresponding covariate will be penalized, as in
pp.lasso
function.- ...
extra arguments to be passed to function.
- nfolds
the number of cross-validation folds. Default is 10.
- seed
the seed of the random number generator in order to obtain reproducible results.
- fold
a vector that specifies the fold that observations belongs to. By default the observations are randomly assigned.
- trace.cv
cv.pp.lasso
will provide user with the progress of cross validation iftrace.cv = TRUE
. Default is FALSE.
Value
An object with S3 class cv.ppLasso
.
- cve
the error for each value of lambda, averaged across the cross-validation folds.
- cvse
the estimated standard error associated with each value of for cve.
- lambda
the sequence of regularization parameter values along which the cross-validation error was calculated.
- fit
the fitted
pp.lasso
object for the whole data.- fold
the fold assignments for cross-validation for each observation
- min
the index of lambda corresponding to lambda.min.
- lambda.min
the value of lambda with the minimum cross-validation error.
References
K. He, J. Kalbfleisch, Y. Li, and et al. (2013) Evaluating hospital readmission rates in dialysis facilities; adjusting for hospital effects.
Lifetime Data Analysis, 19: 490-512.
Examples
data(BinaryData)
data <- BinaryData$data
Y.char <- BinaryData$Y.char
prov.char <- BinaryData$prov.char
Z.char <- BinaryData$Z.char
cv.fit <- cv.pp.lasso(data, Y.char, Z.char, prov.char, nfolds = 10)
# the best lambda using cross validation
cv.fit$lambda.min
#> [1] 0.001517182