Skip to content

Commit 89088a9

Browse files
Merge pull request #343 from Merck/305-add-a-stratified-design-example-to-sim_fix_n
Add a stratified example to `sim_fixed_n`
2 parents 88e1770 + d9098ff commit 89088a9

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

R/sim_fixed_n.R

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,26 @@
111111
#' plan("multisession", workers = 2)
112112
#' sim_fixed_n(n_sim = 10)
113113
#' plan("sequential")
114+
#'
115+
#' # Example 5: Stratified design with two strata
116+
#' sim_fixed_n(
117+
#' n_sim = 100,
118+
#' sample_size = 500,
119+
#' target_event = 350,
120+
#' stratum = data.frame(stratum = c("Biomarker-positive", "Biomarker-negative"),
121+
#' p = c(0.5, 0.5)),
122+
#' enroll_rate = data.frame(stratum = c("Biomarker positive", "Biomarker negative"),
123+
#' duration = c(12, 12), rate = c(250 / 12, 250 / 12)),
124+
#' fail_rate = data.frame(stratum = c(rep("Biomarker-positive", 2), rep("Biomarker-negative", 2)),
125+
#' duration = c(3, Inf, 3, Inf),
126+
#' fail_rate = log(2) / c(12, 12, 8, 8),
127+
#' hr = c(1, 0.6, 1, 0.7),
128+
#' dropout_rate = rep(0.001, 4)),
129+
#' total_duration = 30,
130+
#' block = rep(c("experimental", "control"), 2),
131+
#' timing_type = 1:5,
132+
#' rho_gamma = data.frame(rho = 0, gamma = 0)
133+
#' )
114134
#' }
115135
sim_fixed_n <- function(
116136
n_sim = 1000,

man/sim_fixed_n.Rd

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)