View source: R/paket_nph_2-1_1.R
sample_fun | R Documentation |
Simulates data for a randomized controlled survival study.
sample_fun( A, B, r0 = 0.5, eventEnd, lambdaRecr, lambdaCens, maxRecrCalendarTime, maxCalendar )
A |
An object of class |
B |
An object of class |
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 |
For simulating the data, patients are allocated randomly to either group (unrestricted randomization).
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
Robin Ristl, robin.ristl@meduniwien.ac.at
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.
rSurv_fun
, rSurv_conditional_fun
, sample_conditional_fun
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.