
Build and cross validate a piecewise exponential model.
cv.pwexpm_fit(time, event, nfold=5, nsim=100, breakpoint=NULL,
nbreak=0, exclude_int=NULL, min_pt_tail=5, max_set=1000, seed=1818,
optimizer='mle', tol=1e-4, parallel=FALSE, mc.core=4, ...)
A object of class "cv.pwexpm
" is a numeric vector containing the CV log likelihood in each round of simulation. The plot
function can be used to make a boxplot of the CV log likelihoods from pwexpm
.
observed time from randomization.
the status indicator. See pwexpm_fit
.
the number of folds used in CV.
the number of simulations.
pre-specified breakpoints. See pwexpm_fit
.
total number of breakpoints. See pwexpm_fit
.
an interval that excludes any estimated breakpoints. See pwexpm_fit
.
the minimum number of events used for estimating the tail (the hazard rate of the last piece). See pwexpm_fit
.
maximum estimated combination of breakpoints. See pwexpm_fit
.
a random seed. Do not set seed if seed=NULL
.
one of the optimizers: mle
, ols
, or hybrid
. See pwexpm_fit
.
the minimum allowed gap between two breakpoints. The gap is calculated as (max(time)-min(time))*tol
. Keep it as default in most cases.
logical. If TRUE
, use doSNOW package to run in parallel.
number of processes allowed to be run in parallel.
internal function reserved.
Tianchen Xu zjph602xutianchen@gmail.com
Use cross validation obtain the prediction log likelihood.
cv.pwexpm
event_dist <- function(n)rpwexpm(n, rate = c(0.1, 0.01, 0.2), breakpoint = c(5,14))
dat <- simdata(rand_rate = 20, drop_rate = 0.03, total_sample = 1000,
advanced_dist = list(event_dist=event_dist),
add_column = c('censor_reason','event','followT','followT_abs'))
# here nsim=10 is for demo purpose, pls increase it in practice!!
# \donttest{
cv0 <- cv.pwexpm_fit(dat$followT, dat$event, nsim = 10, nbreak = 0)
cv1 <- cv.pwexpm_fit(dat$followT, dat$event, nsim = 10, nbreak = 1)
cv2 <- cv.pwexpm_fit(dat$followT, dat$event, nsim = 10, nbreak = 2)
sapply(list(cv0,cv1,cv2), median)
# }
Run the code above in your browser using DataLab