Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a stratified design example to sim_fix_n #305

Open
LittleBeannie opened this issue Jan 10, 2025 · 0 comments
Open

Add a stratified design example to sim_fix_n #305

LittleBeannie opened this issue Jan 10, 2025 · 0 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@LittleBeannie
Copy link
Collaborator

LittleBeannie commented Jan 10, 2025

The following lines of code generate a stratified design simulation of using sim_fixed_n().

This example assumes there are two strata (biomarker-positive and biomarker-negative) with equal prevalence of 0.5 for each. In the control arm, the median survival time is 12 months for biomarker-positive subjects and 8 months for biomarker-negative subjects. For both strata, the hazard ratio is 1 for the first 3 months, after which it decreases to 0.6 for biomarker-positive subjects and 0.7 for biomarker-negative subjects. The dropout rate is contently 0.001 for both strata over time.

sim_fixed_n(
  n_sim = 100,
  sample_size = 500,
  target_event = 350,
  stratum = data.frame(stratum = c("Biomarker-positive", "Biomarker-negative"), 
                       p = c(0.5, 0.5)),
  enroll_rate = data.frame(stratum = c("Biomarker positive", "Biomarker negative"),
                           duration = c(12, 12), rate = c(250 / 12, 250 / 12)),
  fail_rate = data.frame(stratum = c(rep("Biomarker-positive", 2), rep("Biomarker-negative", 2)), 
                         duration = c(3, Inf, 3, Inf), 
                         fail_rate = log(2) / c(12, 12, 8, 8), 
                         hr = c(1, 0.6, 1, 0.7), 
                         dropout_rate = rep(0.001, 4)),
  total_duration = 30,
  block = rep(c("experimental", "control"), 2),
  timing_type = 1:5,
  rho_gamma = data.frame(rho = 0, gamma = 0)
)

It gives me the following error message, which looks like possibly caused by rbinding simulations results?
image

@LittleBeannie LittleBeannie added the documentation Improvements or additions to documentation label Jan 10, 2025
@LittleBeannie LittleBeannie self-assigned this Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant