Skip to contents

Performs k-fold cross validation for penalized discrete survival model (without provider information) over a grid of values of regularization parameter lambda.

Usage

cv.DiscSurv(
  data,
  Event.char,
  Z.char,
  Time.char,
  penalize.x = rep(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.

Event.char

name of the event indicator in data as a character string. Event indicator should be a binary variable with 1 indicating that the event has occurred and 0 indicating (right) censoring.

Z.char

names of covariates in data as vector of character strings.

Time.char

name of the follow up time in data as a character string.

penalize.x

a vector indicates whether the corresponding covariate will be penalized, as in pp.DiscSurv 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.DiscSurv will provide user with the progress of cross validation if trace.cv = TRUE. Default is FALSE.

Value

An object with S3 class cv.DiscSurv.

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.DiscSurv 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(DiscTime)
data <- DiscTime$data
Event.char <- DiscTime$Event.char
Z.char <- DiscTime$Z.char
Time.char <- DiscTime$Time.char
cv.fit <- cv.DiscSurv(data, Event.char, Z.char, Time.char, nfolds = 10, trace.cv = T)
#> Starting CV fold #1...
#> Starting CV fold #2...
#> Starting CV fold #3...
#> Starting CV fold #4...
#> Starting CV fold #5...
#> Starting CV fold #6...
#> Starting CV fold #7...
#> Starting CV fold #8...
#> Starting CV fold #9...
#> Starting CV fold #10...
cv.fit$cve
#>   [1] 0.6164357 0.5859204 0.5588632 0.5359219 0.5162308 0.4975886 0.4806902
#>   [8] 0.4659590 0.4531315 0.4418893 0.4319920 0.4232525 0.4155636 0.4088219
#>  [15] 0.4029151 0.3977430 0.3932264 0.3892878 0.3858700 0.3829060 0.3803241
#>  [22] 0.3780872 0.3761650 0.3745262 0.3731255 0.3719438 0.3709422 0.3701069
#>  [29] 0.3694028 0.3688292 0.3683501 0.3681269 0.3679872 0.3676270 0.3667747
#>  [36] 0.3654981 0.3644171 0.3634951 0.3626943 0.3620166 0.3614478 0.3609877
#>  [43] 0.3606192 0.3603222 0.3600887 0.3599045 0.3597558 0.3596067 0.3594923
#>  [50] 0.3594062 0.3593382 0.3592856 0.3592503 0.3592230 0.3592091 0.3591973
#>  [57] 0.3591958 0.3591976 0.3592005 0.3592063 0.3592159 0.3592223 0.3592350
#>  [64] 0.3592457 0.3592534 0.3592699 0.3592784 0.3592864 0.3592978 0.3593071
#>  [71] 0.3593180 0.3593254 0.3593340 0.3593394 0.3593485 0.3593559 0.3593590
#>  [78] 0.3593665 0.3593720 0.3593761 0.3593798 0.3593841 0.3593899 0.3593930
#>  [85] 0.3593968 0.3593992 0.3594039 0.3594053 0.3594077 0.3594074 0.3594102
#>  [92] 0.3594133 0.3594160 0.3594162 0.3594175 0.3594173 0.3594194 0.3594204
#>  [99] 0.3594209 0.3594217
cv.fit$lambda.min
#> [1] 0.002327205