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

Use getFromNamespace instead of ::: to fix S3 dispatch for as_gt() #492

Merged
merged 1 commit into from
Nov 15, 2024

Conversation

jdblischak
Copy link
Collaborator

Removes the NOTE from R CMD check (#490)

xref: Merck/simtrial#284, #467, Merck/simtrial#287

Demonstration that it still works:

library("simtrial")
packageVersion("simtrial")
## [1] ‘0.4.2’
library("gsDesign2")
##
## Attaching package: ‘gsDesign2’
##
## The following object is masked from ‘package:simtrial’:
##
##   as_gt
##
packageVersion("gsDesign2")
## [1] ‘1.1.3’

# Parameters for enrollment
enroll_rampup_duration <- 4 # Duration for enrollment ramp up
enroll_duration <- 16 # Total enrollment duration
enroll_rate <- define_enroll_rate(
  duration = c(
    enroll_rampup_duration, enroll_duration - enroll_rampup_duration),
  rate = c(10, 30))

# Parameters for treatment effect
delay_effect_duration <- 3 # Delay treatment effect in months
median_ctrl <- 9 # Survival median of the control arm
median_exp <- c(9, 14) # Survival median of the experimental arm
dropout_rate <- 0.001
fail_rate <- define_fail_rate(
  duration = c(delay_effect_duration, 100),
  fail_rate = log(2) / median_ctrl,
  hr = median_ctrl / median_exp,
  dropout_rate = dropout_rate)

# Other related parameters
alpha <- 0.025 # Type I error
beta <- 0.1 # Type II error
ratio <- 1 # Randomization ratio (experimental:control)

# Build a one-sided group sequential design
design <- gs_design_ahr(
  enroll_rate = enroll_rate, fail_rate = fail_rate,
  ratio = ratio, alpha = alpha, beta = beta,
  analysis_time = c(12, 24, 36),
  upper = gs_spending_bound,
  upar = list(sf = gsDesign::sfLDOF, total_spend = alpha),
  lower = gs_b,
  lpar = rep(-Inf, 3))

# Define cuttings of 2 IAs and 1 FA
ia1_cut <- create_cut(target_event_overall = ceiling(design$analysis$event[1]))
ia2_cut <- create_cut(target_event_overall = ceiling(design$analysis$event[2]))
fa_cut <- create_cut(target_event_overall = ceiling(design$analysis$event[3]))

# Run simulations
simulation <- sim_gs_n(
  n_sim = 3,
  sample_size = ceiling(design$analysis$n[3]),
  enroll_rate = design$enroll_rate,
  fail_rate = design$fail_rate,
  test = wlr,
  cut = list(ia1 = ia1_cut, ia2 = ia2_cut, fa = fa_cut),
  weight = fh(rho = 0, gamma = 0.5))

# Summarize simulation and compare with the planned design
class(simulation)
## [1] "simtrial_gs_wlr" "data.frame"
simulation |> summary(design = design) |> as_gt()

@jdblischak
Copy link
Collaborator Author

@LittleBeannie R CMD check returned Status: OK for all 5 builds

Copy link
Collaborator

@LittleBeannie LittleBeannie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @jdblischak !

@LittleBeannie LittleBeannie merged commit 3c094b0 into Merck:main Nov 15, 2024
7 checks passed
@jdblischak jdblischak deleted the getfromnamespace branch November 15, 2024 21:15
@yihui
Copy link
Contributor

yihui commented Nov 15, 2024

The CRAN incoming queue is empty at the moment: https://cran.r-project.org/incoming/pretest/ I guess it shouldn't take more than 10 minutes for the new submission of pass the auto check if you submit this afternoon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants