Learn R Programming

rpact (version 2.0.6)

getSimulationRates: Get Simulation Rates

Description

Returns the simulated power, stopping probabilities, conditional power, and expected sample size for testing rates in a one or two treatment groups testing situation.

Usage

getSimulationRates(
  design = NULL,
  ...,
  groups = 2L,
  riskRatio = FALSE,
  thetaH0 = ifelse(riskRatio, 1, 0),
  pi1 = C_PI_1_DEFAULT,
  pi2 = NA_real_,
  plannedSubjects = NA_real_,
  directionUpper = C_DIRECTION_UPPER_DEFAULT,
  allocationRatioPlanned = NA_real_,
  minNumberOfSubjectsPerStage = NA_real_,
  maxNumberOfSubjectsPerStage = NA_real_,
  conditionalPower = NA_real_,
  pi1H1 = NA_real_,
  pi2H1 = 0.2,
  maxNumberOfIterations = C_MAX_SIMULATION_ITERATIONS_DEFAULT,
  seed = NA_real_,
  calcSubjectsFunction = NULL
)

Arguments

design

The trial design. If no trial design is specified, a fixed sample size design is used. In this case, alpha, beta, and sided can be directly entered as argument.

...

Ensures that all arguments are be named and that a warning will be displayed if unknown arguments are passed.

groups

The number of treatment groups (1 or 2), default is 2.

riskRatio

If riskRatio = TRUE is specified, the design characteristics for one-sided testing of H0: pi1/pi2 = thetaH0 are simulated, default is FALSE.

thetaH0

The null hypothesis value. For one-sided testing, a value != 0 (or a value != 1 for testing the mean ratio) can be specified, default is 0 or 1 for difference and ratio testing, respectively.

pi1

The assumed probability in the active treatment group if two treatment groups are considered, or the alternative probability for a one treatment group design, default is seq(0.2,0.5,0.1).

pi2

The assumed probability in the reference group if two treatment groups are considered, default is 0.2.

plannedSubjects

plannedSubjects is a vector of length kMax (the number of stages of the design) that determines the number of cumulated (overall) subjects when the interim stages are planned.

directionUpper

Specifies the direction of the alternative, only applicable for one-sided testing, default is TRUE.

allocationRatioPlanned

The planned allocation ratio for a two treatment groups design, default is 1.

minNumberOfSubjectsPerStage

When performing a data driven sample size recalculation, the vector with length kMax minNumberOfSubjectsPerStage determines the minimum number of subjects per stage (i.e., not cumulated), the first element is not taken into account.

maxNumberOfSubjectsPerStage

When performing a data driven sample size recalculation, the vector with length kMax maxNumberOfSubjectsPerStage determines the maximum number of subjects per stage (i.e., not cumulated), the first element is not taken into account.

conditionalPower

The conditional power for the subsequent stage under which the sample size recalculation is performed.

pi1H1

If specified, the assumed probability in the active treatment group if two treatment groups are considered, or the assumed probability for a one treatment group design, for which the conditional power was calculated.

pi2H1

If specified, the assumed probability in the reference group if two treatment groups are considered, for which the conditional power was calculated, default is 0.2.

maxNumberOfIterations

The number of simulation iterations.

seed

The seed to reproduce the simulation, default is a random seed.

calcSubjectsFunction

Optionally, a function can be entered that defines the way of performing the sample size recalculation. By default, sample size recalulation is performed with conditional power and specified minNumberOfSubjectsPerStage and maxNumberOfSubjectsPerStage (see details and examples).

Value

Returns a SimulationResultsRates object.

Simulation Data

The summary statistics "Simulated data" contains the following parameters: median [range]; mean +/-sd

$show(showStatistics = FALSE) or $setShowStatistics(FALSE) can be used to disable the output of the aggregated simulated data.

Example 1: simulationResults <- getSimulationRates(plannedSubjects = 40) simulationResults$show(showStatistics = FALSE)

Example 2: simulationResults <- getSimulationRates(plannedSubjects = 40) simulationResults$setShowStatistics(FALSE) simulationResults

getData can be used to get the aggregated simulated data from the object as data.frame. The data frame contains the following columns:

  1. iterationNumber: The number of the simulation iteration.

  2. stageNumber: The stage.

  3. pi1: The assumed or derived event rate in the treatment group (if available).

  4. pi2: The assumed or derived event rate in the control group (if available).

  5. numberOfSubjects: The number of subjects under consideration when the (interim) analysis takes place.

  6. rejectPerStage: 1 if null hypothesis can be rejected, 0 otherwise.

  7. futilityPerStage: 1 if study should be stopped for futility, 0 otherwise.

  8. testStatistic: The test statistic that is used for the test decision, depends on which design was chosen (group sequential, inverse normal, or Fisher combination test)'

  9. testStatisticsPerStage: The test statistic for each stage if only data from the considered stage is taken into account.

  10. overallRates1: The overall rate in treatment group 1.

  11. overallRates2: The overall rate in treatment group 2.

  12. stagewiseRates1: The stagewise rate in treatment group 1.

  13. stagewiseRates2: The stagewise rate in treatment group 2.

  14. sampleSizesPerStage1: The stagewise sample size in treatment group 1.

  15. sampleSizesPerStage2: The stagewise sample size in treatment group 2.

  16. trialStop: TRUE if study should be stopped for efficacy or futility or final stage, FALSE otherwise.

  17. conditionalPowerAchieved: The conditional power for the subsequent stage of the trial for selected sample size and effect. The effect is either estimated from the data or can be user defined with pi1H1 and pi2H1.

Details

At given design the function simulates the power, stopping probabilities, conditional power, and expected sample size at given number of subjects and parameter configuration. Additionally, an allocation ratio = n1/n2 can be specified where n1 and n2 are the number of subjects in the two treatment groups.

calcSubjectsFunction This function returns the number of subjects at given conditional power and conditional Type I error rate for specified testing situation. The function might depend on variables stage, riskRatio, thetaH0, groups, plannedSubjects, directionUpper, allocationRatioPlanned, minNumberOfSubjectsPerStage, maxNumberOfSubjectsPerStage, sampleSizesPerStage, conditionalPower, conditionalCriticalValue, overallRate, farringtonManningValue1, and farringtonManningValue2. The function has to obtain the three-dots arument '...' (see examples).

Examples

Run this code
# NOT RUN {
# Fixed sample size with minimum required definitions, pi1 = (0.3,0.4,0.5, 0.6) and pi2 = 0.3
getSimulationRates(pi1 = seq(0.3, 0.6, 0.1), pi2 = 0.3, 
    plannedSubjects = 120, maxNumberOfIterations = 50)

# }
# NOT RUN {
# Increase number of simulation iterations and compare results with power calculator
getSimulationRates(pi1 = seq(0.3, 0.6, 0.1), pi2 = 0.3, 
    plannedSubjects = 120, maxNumberOfIterations = 50)
getPowerRates(pi1 = seq(0.3, 0.6, 0.1), pi2 = 0.3, maxNumberOfSubjects = 120)

# Do the same for a two-stage Pocock inverse normal group sequential 
# design with non-binding futility stops
designIN <- getDesignInverseNormal(typeOfDesign = "P", futilityBounds = c(0))
getSimulationRates(designIN, pi1 = seq(0.3, 0.6, 0.1), pi2 = 0.3, 
    plannedSubjects = c(40, 80), maxNumberOfIterations = 50)
getPowerRates(designIN, pi1 = seq(0.3, 0.6, 0.1), pi2 = 0.3, maxNumberOfSubjects = 80)

# Assess power and average sample size if a sample size reassessment is 
# foreseen at conditional power 80% for the subsequent stage (decrease and increase) 
# based on observed overall rates and specified minNumberOfSubjectsPerStage 
# and maxNumberOfSubjectsPerStage

# Do the same under the assumption that a sample size increase only takes place 
# if the rate difference exceeds the value 0.1 at interim. For this, the sample 
# size recalculation method needs to be redefined:  
mySampleSizeCalculationFunction <- function(..., stage,
        plannedSubjects,
        minNumberOfSubjectsPerStage,
        maxNumberOfSubjectsPerStage,
        conditionalPower,
        conditionalCriticalValue,
        overallRate) {
    if (overallRate[1] - overallRate[2] < 0.1) {
        return(plannedSubjects[stage] - plannedSubjects[stage - 1]) 
    } else {
        rateUnderH0 <- (overallRate[1] + overallRate[2]) / 2 
        stageSubjects <- 2 * (max(0, conditionalCriticalValue * 
            sqrt(2 * rateUnderH0 * (1 - rateUnderH0)) + 
            stats::qnorm(conditionalPower) * sqrt(overallRate[1] * 
            (1 - overallRate[1]) + overallRate[2] * (1 - overallRate[2]))))^2 /
            (max(1e-12,	(overallRate[1] - overallRate[2])))^2
        stageSubjects <- ceiling(min(max(
            minNumberOfSubjectsPerStage[stage], 
            stageSubjects), maxNumberOfSubjectsPerStage[stage]))
        return(stageSubjects)
    }	
}
getSimulationRates(designIN, pi1 = seq(0.3, 0.6, 0.1), pi2 = 0.3, 
    plannedSubjects = c(40, 80), minNumberOfSubjectsPerStage = c(40, 20), 
    maxNumberOfSubjectsPerStage = c(40, 160), conditionalPower = 0.8, 
    calcSubjectsFunction = mySampleSizeCalculationFunction, maxNumberOfIterations = 50)

# }
# NOT RUN {
# }

Run the code above in your browser using DataLab