rpact-com / rpact

rpact: Confirmatory Adaptive Clinical Trial Design and Analysis
https://rpact-com.github.io/rpact/
23 stars 5 forks source link

peculiarity in getSimulationSurvival() in one iteration #24

Closed grlm1 closed 8 months ago

grlm1 commented 8 months ago

Hello, I noticed a one-off issue with the getSimulationSurvival(). While I fixed the singular events at 10 for stage 2 in a 3-stage design, there was one iteration out of 1000 where the analysis was triggered at 9 instead. See the code below. Impact on results is low if any, but still seems worthy investigating, especially because this variance where there should not be any shows up in the output of showStatistics = T.

Kind regards, Tim

library(dplyr)
library(rpact)
#rpact developer version 3.5.1.9231 loaded

dIN <- getDesignInverseNormal(kMax = 3,
                              alpha = 0.025,
                              beta = 0.1,
                              sided = 1,
                              informationRates = c(0.4, 0.6, 1),
                              futilityBounds = c(-6, -1),
                              typeOfDesign = "asUser",
                              userAlphaSpending = c(0, 0.01, 0.025)
)

dIN_sim <- getSimulationSurvival(design = dIN,
                                 thetaH0 = 0.9,
                                 directionUpper = F,
                                 pi2 = 0.003,
                                 hazardRatio = c(0.9, 0.4, 0.35, 0.3, 0.25, 0.2), 
                                 eventTime = 12,
                                 dropoutRate1 = 0.08,
                                 dropoutRate2 = 0.08,
                                 dropoutTime = 12,
                                 accrualTime = c(0,0.01),
                                 maxNumberOfSubjects = 14000,    
                                 plannedEvents = c(0.4*50, 0.6*50, 50),
                                 maxNumberOfIterations = 1000,
                                 longTimeSimulationAllowed = T,
                                 seed = 1910,
                                 showStatistics = T,
                                 maxNumberOfRawDatasetsPerStage = 2,
                                 minNumberOfEventsPerStage = c(20, 10, 20),  #stage 2 triggered after 10 additional events after stage1
                                 maxNumberOfEventsPerStage = c(20, 10, 40), 
                                 conditionalPower = 0.9,
                                 thetaH1 = NA_real_
)

sims <- getData(dIN_sim)  %>% filter(hazardRatio %>% near(0.4))

table((sims %>% filter(stageNumber == 2))$eventsPerStage) #-> 1 iteration has 9 singular events instead of 10 at stage 2

sims %>% filter(iterationNumber == 757)
fpahlke commented 8 months ago

Hi Tim,

Thank you, we could reproduce the issue. It is due to the accuracy in the function that determines the analysis time. It would be possible to increase the accurary, however, on the cost of speed, and there is no or only a highly negligible impact on the results. We think that this is acceptable.

Thanks for pointing it out!

Best regards, Gernot and Friedrich