Skip to contents

Implementation is based on this algorithm.

Usage

PiecewiseConstantExponentialRNG(n, risk, endpoint_name)

Arguments

n

number of random numbers

risk

a data frame of columns

end_time

End time for a constant risk in a time window. The start time of the first time window is 0.

piecewise_risk

A constant risk in a time window, which is absolute risk * relative risk, or (h0 * g) in the link.

hazard_ratio

An optional column for simulating an active arm. If absent, a column of 1s will be added. Equivalently, user can multiply piecewise_risk by hazard_ratio manually and ignore this column.

endpoint_name

name of endpoint

Examples

# example code
# In this example, absolute risk in [0, 1) and [26, 52] are 0.0181 and
# 0.0027, respectively.
risk <- data.frame(
  end_time = c(1, 4.33, 26.0, 52.0),
  piecewise_risk = c(1, 1.01, 0.381, 0.150) * exp(-4.01)
)
PiecewiseConstantExponentialRNG(10, risk, 'PFS')
#>           PFS PFS_event
#> 1  52.0000000         0
#> 2  52.0000000         0
#> 3   5.6219124         1
#> 4  52.0000000         0
#> 5  52.0000000         0
#> 6  29.6284513         1
#> 7  52.0000000         0
#> 8  52.0000000         0
#> 9  52.0000000         0
#> 10  0.9546304         1