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 multi test into simfix #17

Open
LittleBeannie opened this issue Aug 5, 2022 · 4 comments
Open

Add multi test into simfix #17

LittleBeannie opened this issue Aug 5, 2022 · 4 comments
Assignees
Labels

Comments

@LittleBeannie
Copy link
Collaborator

LittleBeannie commented Aug 5, 2022

# Define different WLR tests into a list
tests <- list(
  test1 = tibble(rho = 0, gamma = 0),
  test2 = tibble(rho = 0, gamma = 0.5)
)

# Define a function to simulate one test method
sim1test <- function(x) {
  ans <- simfix(
    nsim = 3, sampleSize = 500, targetEvents = 350,
    strata = tibble(Stratum = "All", p = 1),
    enrollRates = tibble(duration = c(2, 2, 10), rate = c(3, 6, 9)),
    failRates = tibble(Stratum = "All", duration = c(3, 100), failRate = log(2) / c(9, 18), hr = c(.9, .6), dropoutRate = rep(.001, 2)),
    totalDuration = 30,
    block = rep(c("Experimental", "Control"), 2),
    timingType = 1:5,
    rg = x
  )
  return(ans)
}

# Run over different test methods
lapply(tests, FUN = sim1test)
@LittleBeannie LittleBeannie self-assigned this Aug 5, 2022
@LittleBeannie LittleBeannie added the development New feature or request label Aug 5, 2022
@elong0527
Copy link
Collaborator

I thought it is more general to provide a list of functions with standardized input and output.

Use case; what if you want to perform simulation to compare WLR, RMST and milestone test.

In this way, you also have a framework to allow user defined function.

@nanxstats
Copy link
Collaborator

Perhaps something like this?

simfix(
  sampleSize = 500,
  targetEvents = 350,
  strata = strata_df(...),
  enrollRates = enroll_rates(...),
  failRates = fail_rates(...),
  totalDuration = 30,
  block = rep(c("Experimental", "Control"), 2),
  timingType = 1:5
) |>
  test_name_1() |>
  test_name_2(arg1 = 0, arg2 = 0)|>
  test_name_2(arg1 = 0, arg2 = 0.5) |>
  run_sim(n = 3)

@LittleBeannie LittleBeannie removed their assignment May 10, 2023
@LittleBeannie LittleBeannie added future and removed development New feature or request labels May 10, 2023
@LittleBeannie
Copy link
Collaborator Author

LittleBeannie commented Aug 4, 2023

Decision: let's focus on the data table first, and save this issue as low priority for now. The test list should be independent of rg. Better to have function calls for different tests.

@LittleBeannie LittleBeannie mentioned this issue Aug 4, 2023
@nanxstats nanxstats changed the title add multi test into simfix Add multi test into simfix Aug 4, 2023
@nanxstats
Copy link
Collaborator

Now after talking about this today I think Yilong's suggestion makes sense. For defining the tests, a function factory pattern like the ggplot2 scales or encapsulated OOP like R6 might be good solutions. We do need to change the arguments from the simple rg.

@LittleBeannie LittleBeannie self-assigned this Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants