Skip to contents

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

Usage

cv.pp.DiscSurv(
  data,
  Event.char,
  prov.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.

prov.char

name of provider IDs variable in data as a character string.

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

Value

An object with S3 class cv.pp.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
prov.char <- DiscTime$prov.char
Z.char <- DiscTime$Z.char
Time.char <- DiscTime$Time.char
cv.fit <- cv.pp.DiscSurv(data, Event.char, prov.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.5536994 0.4635804 0.4519723 0.4422659 0.4341065 0.4272753 0.4216070
#>   [8] 0.4158419 0.4098801 0.4040894 0.3991393 0.3949940 0.3915235 0.3885731
#>  [15] 0.3860438 0.3838311 0.3818779 0.3801677 0.3786650 0.3773935 0.3763252
#>  [22] 0.3754223 0.3742408 0.3726386 0.3710895 0.3698456 0.3688344 0.3680012
#>  [29] 0.3673003 0.3667266 0.3662740 0.3659188 0.3656171 0.3653780 0.3651955
#>  [36] 0.3650605 0.3649295 0.3648325 0.3647630 0.3647175 0.3646884 0.3646760
#>  [43] 0.3646711 0.3646772 0.3646887 0.3647062 0.3647269 0.3647486 0.3647732
#>  [50] 0.3647983 0.3648241 0.3648485 0.3648729 0.3648964 0.3649172 0.3649400
#>  [57] 0.3649605 0.3649794 0.3649982 0.3650151 0.3650319 0.3650461 0.3650609
#>  [64] 0.3650738 0.3650834 0.3650963 0.3651058 0.3651142 0.3651252 0.3651315
#>  [71] 0.3651395 0.3651457 0.3651525 0.3651572 0.3651631 0.3651667 0.3651729
#>  [78] 0.3651746 0.3651803 0.3651821 0.3651852 0.3651878 0.3651912 0.3651934
#>  [85] 0.3651958 0.3651986 0.3652000 0.3651998 0.3652017 0.3652036 0.3652050
#>  [92] 0.3652066 0.3652064 0.3652087 0.3652081 0.3652095 0.3652124 0.3652120
#>  [99] 0.3652116 0.3652125
cv.fit$lambda.min
#> [1] 0.003215807