sample_fun: Draw survival times based on study settings

View source: R/paket_nph_2-1_1.R

sample_funR Documentation

Draw survival times based on study settings

Description

Simulates data for a randomized controlled survival study.

Usage

sample_fun(
  A,
  B,
  r0 = 0.5,
  eventEnd,
  lambdaRecr,
  lambdaCens,
  maxRecrCalendarTime,
  maxCalendar
)

Arguments

A

An object of class mixpch, resembling the survival function in treatment group 0

B

An object of class mixpch, resembling the survival function in treatment group 1

r0

Allocation ratio to group 0 (must be a number between 0 and 1)

eventEnd

Number of events, after which the study stops

lambdaRecr

Rate per day for recruiting patients, assuming recruitung follows a Poisson process

lambdaCens

Rate per day for random censoring, assuming censoring times are exponential

maxRecrCalendarTime

Maximal duration of recruitment in days

maxCalendar

Maximal total study duration in days, after which the study stops

Details

For simulating the data, patients are allocated randomly to either group (unrestricted randomization).

Value

A data frame with each line representing data for one patient and the following columns:

group

Treatment group

inclusion

Start of observation in terms of calendar time

y

Observed survival/censored time

yCalendar

End of observation in terms of calendar time.

event

logical, TRUE indicates the observation ended with an event, FALSE corresponds to censored times

adminCens

logical, True indicates that the observation is subject to administrative censoring, i.e. the subject was observed until the end of the study without an event.

cumEvents

Cumulative number of events over calendar time of end of observation

The data frame is ordered by yCalendar

Author(s)

Robin Ristl, robin.ristl@meduniwien.ac.at

References

Robin Ristl, Nicolas Ballarini, Heiko Götte, Armin Schüler, Martin Posch, Franz König. Delayed treatment effects, treatment switching and heterogeneous patient populations: How to design and analyze RCTs in oncology. Pharmaceutical statistics. 2021; 20(1):129-145.

See Also

rSurv_fun, rSurv_conditional_fun, sample_conditional_fun

Examples

A <- pop_pchaz(Tint = c(0, 90, 1500),
  lambdaMat1 = matrix(c(0.2, 0.1, 0.4, 0.1), 2, 2) / 365,
 lambdaMat2 = matrix(c(0.5, 0.2, 0.6, 0.2), 2, 2) / 365,
 lambdaProg = matrix(c(0.5, 0.5, 0.4, 0.4), 2, 2) / 365,
 p = c(0.8, 0.2), 
 timezero = FALSE, discrete_approximation = TRUE)
B <- pop_pchaz(Tint = c(0, 90, 1500),
  lambdaMat1 = matrix(c(0.2, 0.1, 0.4, 0.1), 2, 2) / 365,
 lambdaMat2 = matrix(c(0.5, 0.1, 0.6, 0.1), 2, 2) / 365,
 lambdaProg = matrix(c(0.5, 0.5, 0.04, 0.04), 2, 2) / 365,
 p = c(0.8, 0.2), 
 timezero = FALSE, discrete_approximation = TRUE)
plot(A)
plot(B, add = TRUE)
dat <- sample_fun(A, B, r0 = 0.5, eventEnd = 30, lambdaRecr = 0.5,
  lambdaCens = 0.25 / 365, maxRecrCalendarTime = 2 * 365,
  maxCalendar = 4 * 365)

nph documentation built on May 17, 2022, 1:06 a.m.