# Sample Size Calculation Under Non-Proportional Hazards

#### Kaifeng Lu

#### 12/15/2021

This R Markdown document illustrates the sample size calculation for a delayed effect model using the lrsamplesize function from lrstat and verifies the result using the simulation tool.

Suppose that the survival distribution of the control group is exponential with a median survival time of 13 months. The survival distribution of the active treatment group is piecewise exponential with the same hazard rate as the control group for the first 6 months and with a hazard ratio of 0.58 afterwards. The accrual has a ramp-up period of 9 months to reach 26 patients per months thereafter, and the total duration of the enrollment is 22 months. In addition, the annual drop rate is 5% for each treatment group.

We would like to know the total number of events needed to achieve 80% power for a two-stage group sequential trial with O’Brien-Fleming spending function and with the interim analysis to be conducted after observing 80% of the target total number of events. First we load the packages:

    library(lrstat)
    library(rpact)

We use the getDesignGroupSequential function from rpact to find the stopping boundaries for the planned two-stage group sequential design.

    (design = getDesignGroupSequential(kMax = 2, informationRates = c(0.8, 1),
                                       alpha = 0.025, typeOfDesign = "asOF"))

    ## Design parameters and output of group sequential design:
    ##
    ## User defined parameters:
    ##   Type of design                               : O'Brien & Fleming type alpha spending
    ##   Information rates                            : 0.800, 1.000
    ##
    ## Derived from user defined parameters:
    ##   Maximum number of stages                     : 2
    ##   Stages                                       : 1, 2
    ##
    ## Default parameters:
    ##   Significance level                           : 0.0250
    ##   Type II error rate                           : 0.2000
    ##   Two-sided power                              : FALSE
    ##   Test                                         : one-sided
    ##   Tolerance                                    : 1e-08
    ##   Type of beta spending                        : none
    ##
    ## Output:
    ##   Cumulative alpha spending                    : 0.01221, 0.02500
    ##   Critical values                              : 2.250, 2.025
    ##   Stage levels (one-sided)                     : 0.01221, 0.02144

Next we use the lrsamplesize function to obtain the follow-up time and the target number of events.

    lrsamplesize(beta = 0.2, kMax = 2, informationRates = c(0.8, 1),
                 criticalValues = c(2.250, 2.025),
                 accrualTime = seq(0, 9),
                 accrualIntensity = c(26/9*seq(1, 9), 26),
                 piecewiseSurvivalTime = c(0, 6),
                 lambda2 = rep(log(2)/13, 2),
                 lambda1 = c(log(2)/13, 0.58*log(2)/13),
                 gamma1 = -log(1-0.05)/12, gamma2 = -log(1-0.05)/12,
                 accrualDuration = 22, followupTime = NA)

    ##                          stage 1 stage 2
    ## informationRates           0.800   1.000
    ## efficacyBounds             2.250   2.025
    ## futilityBounds              -Inf   2.025
    ## cumulativeRejection        0.450   0.800
    ## cumulativeFutility         0.000   0.200
    ## cumulativeAlphaSpent       0.012   0.025
    ## numberOfEvents           252.186 315.232
    ## numberOfSubjects         468.000 468.000
    ## analysisTime              31.391  41.519
    ## efficacyHR                 0.753   0.795
    ## futilityHR                   Inf   0.795
    ## efficacyP                  0.012   0.021
    ## futilityP                  1.000   0.021
    ## information               62.807  78.025
    ## logRankHR                  0.765   0.723
    ## overallReject              0.800
    ## alpha                      0.025
    ## numberOfEvents           315.232
    ## expectedNumberOfEvents   286.840
    ## numberOfSubjects         468.000
    ## expectedNumberOfSubjects 468.000
    ## studyDuration             41.519
    ## expectedStudyDuration     36.958
    ## accrualDuration           22.000
    ## followupTime              19.519
    ## fixedFollowup              0.000
    ## rho1                       0.000
    ## rho2                       0.000

Thus we need to observe 315 events with 468 subjects, and the maximum study duration is 41.5 months with an expected study duration of 37 months.

To verify this requirement, we resort to the getSimulationSurvival function from rpact.

    getSimulationSurvival(design, directionUpper = FALSE,
                          piecewiseSurvivalTime = c(0, 6),
                          lambda2 = rep(log(2)/13, 2),
                          lambda1 = c(log(2)/13, 0.58*log(2)/13),
                          accrualTime = seq(0, 9),
                          accrualIntensity = c(26/9*seq(1, 9), 26),
                          dropoutRate1 = 0.05, dropoutRate2 = 0.05,
                          dropoutTime = 12, maxNumberOfSubjects = 468,
                          plannedEvents = c(252, 315),
                          maxNumberOfIterations = 10000, seed = 12345)

    ## Simulation of survival data (group sequential design):
    ##
    ## Design parameters:
    ##   Information rates                            : 0.800, 1.000
    ##   Critical values                              : 2.250, 2.025
    ##   Futility bounds (non-binding)                : -Inf
    ##   Cumulative alpha spending                    : 0.01221, 0.02500
    ##   Local one-sided significance levels          : 0.01221, 0.02144
    ##   Significance level                           : 0.0250
    ##   Test                                         : one-sided
    ##
    ## User defined parameters:
    ##   Maximum number of iterations                 : 10000
    ##   Seed                                         : 12345
    ##   Direction upper                              : FALSE
    ##   Planned cumulative events                    : 252, 315
    ##   Maximum number of subjects                   : 468
    ##   Accrual time                                 : 1, 2, 3, 4, 5, 6, 7, 8, 9, 22
    ##   Accrual intensity                            : 2.9, 5.8, 8.7, 11.6, 14.4, 17.3, 20.2, 23.1, 26.0, 26.0
    ##   Drop-out rate (1)                            : 0.050
    ##   Drop-out rate (2)                            : 0.050
    ##   Piecewise survival times                     : 0, 6
    ##   lambda(1)                                    : 0.0533, 0.0309
    ##   lambda(2)                                    : 0.0533, 0.0533
    ##   Delayed response enabled                     : TRUE
    ##
    ## Default parameters:
    ##   Planned allocation ratio                     : 1
    ##   Conditional power                            : NA
    ##   Drop-out time                                : 12.00
    ##   Theta H0                                     : 1
    ##   Allocation 1                                 : 1
    ##   Allocation 2                                 : 1
    ##   kappa                                        : 1
    ##
    ## Results:
    ##   Hazard ratio                                 : 1.000, 0.580
    ##   Analysis times [1]                           : 31.46
    ##   Analysis times [2]                           : 41.24
    ##   Expected study duration                      : 36.97
    ##   Events not achieved [1]                      : 0.000
    ##   Events not achieved [2]                      : 0.000
    ##   Number of subjects [1]                       : 468.0
    ##   Number of subjects [2]                       : 468.0
    ##   Iterations [1]                               : 10000
    ##   Iterations [2]                               : 5528
    ##   Overall reject                               : 0.7992
    ##   Reject per stage [1]                         : 0.4472
    ##   Reject per stage [2]                         : 0.3520
    ##   Futility stop per stage                      : 0.0000
    ##   Early stop                                   : 0.4472
    ##   Expected number of subjects                  : 468.0
    ##   Expected number of events                    : 286.8
    ##   Cumulative number of events [1]              : 252.0
    ##   Cumulative number of events [2]              : 315.0
    ##   Conditional power (achieved) [1]             : NA
    ##   Conditional power (achieved) [2]             : 0.3114
    ##
    ## Legend:
    ##   (i): values of treatment arm i
    ##   [k]: values at stage k

The simulation results confirm the analytic calculations.