Learn R Programming

goldilocks (version 0.3.0)

pwe_sim: Simulate piecewise exponential time-to-event outcomes

Description

Simulate time-to-event outcomes using the piecewise constant hazard exponential function.

Usage

pwe_sim(n = 1, hazard = 1, cutpoints = 0, maxtime = NULL)

Arguments

n

integer. The number of random samples to generate. Default is n=1.

hazard

vector. The constant hazard rates for exponential failures.

cutpoints

vector. The change-point vector indicating time when the hazard rates change. Note the first element of cutpoints should always be 0.

maxtime

scalar. Maximum time before end of study.

Value

A data frame with simulated follow-up times (time) and respective event indicator (event, 1 = event occurred, 0 = censoring).

Details

See pwe_impute for details.

Examples

Run this code
# NOT RUN {
pwe_sim(10, hazard = c(0.005, 0.001), cutpoints = c(0, 3), maxtime = 36)
y <- pwe_sim(n = 1, hazard = c(2.585924e-02, 3.685254e-09),
             cutpoints = c(0, 12))
# }

Run the code above in your browser using DataLab