Skip to contents

Performs k-fold cross validation for group penalized regression models over a grid of values of regularization parameter lambda.

Usage

cv.grp.lasso(
  data,
  Y.char,
  Z.char,
  prov.char,
  group = 1:length(Z.char),
  ...,
  nfolds = 10,
  seed,
  fold,
  trace.cv = FALSE
)

Arguments

data

an dataframe or list object that contains the variables in the model.

Y.char

name of the response variable from data as a character string, as in grp.lasso function.

Z.char

names of covariates from data as vector of character strings, as in grp.lasso function.

prov.char

name of provider IDs variable from data as a character string, as in grp.lasso function.

group

a vector describing the grouping of the coefficients. If there are coefficients to be included in the model without being penalized, assign them to group 0 (or "0").

...

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.grp.lasso will provide user with the progress of cross validation if trace.cv = TRUE. Default is FALSE.

Value

An object with S3 class cv.gr_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 gr_ppLasso 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
group <- BinaryData$group
cv.fit <- cv.grp.lasso(data, Y.char, Z.char, prov.char, group = group, nfolds = 10)
# the best lambda using cross validation
cv.fit$lambda.min
#> [1] 0.001427324