predict {PWEXP} | R Documentation |
Predict Events for Piecewise Exponential Model
Description
Obtians event prediction and (optionally) confidence interval from a piecewise exponential model.
Usage
## S3 method for class 'pwexp.fit'
predict(object, cut_indicator=NULL, analysis_time, censor_model=NULL,
n_each=100, future_rand=NULL, seed=1818, ...)
## S3 method for class 'boot.pwexp.fit'
predict(object, cut_indicator=NULL, analysis_time,
censor_model_boot=NULL, n_each=10, future_rand=NULL,
seed=1818, ...)
Arguments
object |
a |
cut_indicator |
(optional) A vector indicates which subject is censored due to the end of the trial. The length of the vector is the number of rows of the data used in |
analysis_time |
the analysis time. This is the time length from the start of the trial to the time collecting data for the model. |
censor_model |
an object of class |
censor_model_boot |
an object of class |
n_each |
the number of iterations for each bootstrapping sample to obtain predicitive CI. Typically, a value of 10 to 100 should be enough. |
future_rand |
the randomization curve in the following times. Can be |
seed |
a random seed. |
... |
internal function reserved. |
Details
The prediction will have a confidence interval only if the event model and censor model are bootstrap models.
cut_indicator
indicates the status of each subject in the event_model
/event_model_boot
model at the end of the trial. Value 1 means the subject didn't have events, drop-out or death at the end of the trial (or say, the subject was censored due to the end of the trial). When cut_indicator
is NOT provided, we assign value 1 to the subject who didn't have event (or drop-out, or death) in both event_model
/event_model_boot
and censor_model
/censor_model_boot
models.
future_rand
is a list determining the parameter of randomization curve in the following times. For example, you specify randomization rate=10pt/month and total sample size=1000 by list(rand_rate=10 ,total_sample=1000)
or specify the number of randomization each month (e.g., 10,15,30,30 in four months) by list(n_rand=c(10,15,30,30))
.
Value
A list containing:
-
event_fun
number of events vs. time curve function in each bootstrap. -
time_fun
time vs. number of events curve function in each bootstrap.
This returned list should be used in plot_event
function for summarizing its result.
Author(s)
Tianchen Xu zjph602xutianchen@gmail.com
See Also
Examples
set.seed(1818)
event_dist <- function(n)rpwexp(n, rate = c(0.1, 0.2), breakpoint = 14)
dat <- simdata(rand_rate = 20, drop_rate = 0.03, total_sample = 500,
advanced_dist = list(event_dist=event_dist),
add_column = c('censor_reason','event','followT','followT_abs'))
cut <- quantile(dat$randT, 0.8)
train <- cut_dat(var_randT = 'randT', cut = cut, data = dat,
var_followT = 'followT', var_followT_abs = 'followT_abs',
var_event = 'event', var_censor_reason = 'censor_reason')
fit_res3 <- pwexp.fit(train$followT, train$event, nbreak = 1)
fit_res_boot <- boot.pwexp.fit(fit_res3, nsim = 8) # here nsim=8 is for demo purpose,
# pls increase it in practice
drop_indicator <- ifelse(train$censor_reason=='drop_out' & !is.na(train$censor_reason),1,0)
fit_res_censor <- pwexp.fit(train$followT, drop_indicator, nbreak = 0)
fit_res_censor_boot <- boot.pwexp.fit(fit_res_censor, nsim = 8)
cut_indicator <- train$censor_reason=='cut'
cut_indicator[is.na(cut_indicator)] <- 0
predicted_boot <- predict(fit_res_boot, cut_indicator = cut_indicator,
analysis_time = cut, censor_model_boot=fit_res_censor_boot,
future_rand=list(rand_rate=20, total_sample=NROW(dat)-NROW(train)))
plot_event(train$followT_abs, train$event, xlim=c(0,69), ylim=c(0,800))
plot_event(predicted_boot, eval_at = 40:90)
plot_event(train$followT_abs, train$event, xyswitch = TRUE, ylim=c(0,69), xlim=c(0,800))
plot_event(predicted_boot, xyswitch = TRUE, eval_at = 600:900)