
Simulate a binary relapse outcome from relapse counts
Source:R/simulate_binary.R
simulate_binary.RdGenerate synthetic relapse counts over a common follow-up period with
simulate_count(), then define an event when the relapse count exceeds
a chosen threshold. The data-generating model and its
coefficients are illustrative, not clinical estimates.
Arguments
- n
Positive integer sample size. Default is 4,000.
- seed
Integer seed, or
NULLto use the current random-number state. Supplying a seed sets R's random-number state.- followup
Positive finite common follow-up in years. Default is 1.
- threshold
Non-negative integer relapse count above which an event is recorded. The default, 0, defines an event as at least one relapse.
- ...
Additional arguments to
simulate_count(), such asconditional_rr,ps_weights,lp_weights, ordispersion. Do not supplyfollowup_range; follow-up is fixed byfollowup.
Value
A data frame with the same covariates, treatment and years as
simulate_count(), a 0/1 outcome y, and the underlying count
relapse_count. A value of 1 means the count exceeds the threshold.
Treatment labels are drug0 and drug1.
Details
The binary outcome is fully observed at the common horizon; there is no censoring. A treatment effect on the relapse rate generally implies a different effect on the event probability, depending on follow-up, the threshold, covariates and count distribution. The model does not reconstruct any patient population or individual patient records.
Author
Thomas Debray tdebray@fromdatatowisdom.com
Examples
d <- simulate_binary(n = 500, seed = 1, followup = 1, threshold = 0)
table(d$trt, d$y)
#>
#> 0 1
#> drug0 114 110
#> drug1 152 124
