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 pwexp.fit or boot.pwexp.fit object. It is the event model for the primary endpoint.

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 event_model/event_model_boot. Value 0 means the subject had event or drop-out or death before the end of the trial; 1 means the subject didn't have any of these. See details.

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 pwexp.fit returned by the pwexp.fit function. It is the censoring model for drop-out and death.

censor_model_boot

an object of class boot.pwexp.fit returned by the boot.pwexp.fit function. It is the censoring model with bootstrapping for drop-out and death.

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 NULL if all subjects have been randomized. You can specify future rand rate and future total number of samples to be randomized by list(rand_rate= ,total_sample= ) or specify the future number of randomization each month by list(rand_n= ). See details.

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:

This returned list should be used in plot_event function for summarizing its result.

Author(s)

Tianchen Xu zjph602xutianchen@gmail.com

See Also

plot_event

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)

[Package PWEXP version 0.5.0 Index]