Learn R Programming

PwePred (version 1.0.0)

boot.pwexpm: Bootstrap a Piecewise Exponential Model

Description

Bootstrap an existing piecewise exponential model or build a piecewise exponential model with bootstrapping.

Usage

# S3 method for default
boot.pwexpm(Surv, data, 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 pwexpm
boot.pwexpm(Surv, nsim=100, max_set=1000, seed=1818,
               optimizer='mle', tol=1e-4, parallel=FALSE, mc.core=4, ...)

Value

A object of class "boot.pwexpm" is a list containing the following components:

brk

estimated breakpoints in each row.

lam

estimated piecewise hazard rates in each row.

logLik

the log-likelihood of the original model.

AIC

the Akaike information criterion of the original model.

BIC

the Bayesian information criterion of the original model.

para

the parameters used to estimate the model.

The plot function can be used to make a simple plot for boot.pwexpm.

Arguments

Surv

a Surv object indicating event time and status or a pwexpm object.

data

a data frame in which to interpret the variables named in the Surv argument.

nsim

the number of repeated bootstrapping.

breakpoint

pre-specified breakpoints. See pwexpm.

nbreak

total number of breakpoints. See pwexpm.

exclude_int

an interval that excludes any estimated breakpoints. See pwexpm.

min_pt_tail

the minimum number of events used for estimating the tail (the hazard rate of the last piece). See pwexpm.

max_set

maximum estimated combination of breakpoints. See pwexpm.

seed

a random seed. Do not set seed if seed=NULL.

optimizer

one of the optimizers: mle, ols, or hybrid. See pwexpm.

tol

the minimum allowed gap between two breakpoints. The gap is calculated as (max(time)-min(time))*tol. Keep it as default in most cases.

parallel

logical. If TRUE, use doSNOW package to run in parallel.

mc.core

number of processes allowed to be run in parallel.

...

internal function reserved.

Author

Tianchen Xu zjph602xutianchen@gmail.com

Details

Use bootstrap to repeatdly call pwexpm to estimate the uncertainty of parameters.

See Also

boot.pwexpm_fit

Examples

Run this code
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'))

fit_res3 <- pwexpm(Surv(followT, event), data = dat, nbreak = 2)
fit_res_boot <- boot.pwexpm(fit_res3, nsim = 10) # here nsim=10 is for demo purpose,
                                                  # pls increase it in practice
plot_survival(dat$followT, dat$event, xlim=c(0,40))
plot_survival(fit_res_boot, col='red', CI_par = list(col='red'))
brk_ci <- apply(fit_res_boot$brk, 2, function(x)quantile(x,c(0.025,0.975)))
abline(v=brk_ci, col='grey', lwd=2)

Run the code above in your browser using DataLab