cv.pwexp.fit {PWEXP} | R Documentation |
Cross Validate a Piecewise Exponential Model
Description
Cross Validate a existing piecewise exponential model.
Usage
## Default S3 method:
cv.pwexp.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, ...)
## S3 method for class 'pwexp.fit'
cv.pwexp.fit(time, nfold=5, nsim=100, max_set=1000, seed=1818,
optimizer='mle', tol=1e-4, parallel=FALSE, mc.core=4, ...)
Arguments
time |
observed time from randomization or a |
event |
the status indicator. See |
nfold |
the number of folds used in CV. |
nsim |
the number of simulations. |
breakpoint |
pre-specified breakpoints. See |
nbreak |
total number of breakpoints. See |
exclude_int |
an interval that excludes any estimated breakpoints. See |
min_pt_tail |
the minimum number of events used for estimating the tail (the hazard rate of the last piece). See |
max_set |
maximum estimated combination of breakpoints. See |
seed |
a random seed. |
optimizer |
one of the optimizers: |
tol |
the minimum allowed gap between two breakpoints. The gap is calculated as |
parallel |
logical. If |
mc.core |
number of processes allowed to be run in parallel. |
... |
internal function reserved. |
Details
Use cross validation obtain the prediction log likelihood.
Value
A vector of length nsim
containing the CV log likelihood in each round of simulation.
Author(s)
Tianchen Xu zjph602xutianchen@gmail.com
See Also
Examples
event_dist <- function(n)rpwexp(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!!
cv0 <- cv.pwexp.fit(dat$followT, dat$event, nsim = 10, nbreak = 0)
cv1 <- cv.pwexp.fit(dat$followT, dat$event, nsim = 10, nbreak = 1)
cv2 <- cv.pwexp.fit(dat$followT, dat$event, nsim = 10, nbreak = 2)
sapply(list(cv0,cv1,cv2), median)