rpact: Confirmatory Adaptive Clinical Trial Design and Analysis


getSimulationMeans {rpact}R Documentation

Get Simulation Means

Description

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

Usage

getSimulationMeans(design = NULL, ..., groups = 2L,
  meanRatio = FALSE, thetaH0 = ifelse(meanRatio, 1, 0),
  alternative = C_ALTERNATIVE_POWER_SIMULATION_DEFAULT,
  stDev = C_STDEV_DEFAULT, plannedSubjects = NA_real_,
  directionUpper = C_DIRECTION_UPPER_DEFAULT,
  allocationRatioPlanned = NA_real_,
  minNumberOfSubjectsPerStage = NA_real_,
  maxNumberOfSubjectsPerStage = NA_real_, conditionalPower = NA_real_,
  thetaH1 = NA_real_,
  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.

meanRatio

If meanRatio = TRUE is specified, the design characteristics for one-sided testing of H0: mu1/mu2 = 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.

alternative

The alternative hypothesis value. This can be a vector of assumed alternatives, default is seq(0,1,0.2).

stDev

The standard deviation under which the conditional power calculation is performed, default is 1. If meanRatio = TRUE is specified, stDev defines the coefficient of variation sigma/mu2.

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.

thetaH1

If specified, the value of the alternative under which the conditional power calculation is performed.

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 with specified minNumberOfSubjectsPerStage and maxNumberOfSubjectsPerStage (see details and examples).

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, meanRatio, thetaH0, groups, plannedSubjects, sampleSizesPerStage, directionUpper, allocationRatioPlanned, minNumberOfSubjectsPerStage, maxNumberOfSubjectsPerStage, conditionalPower, conditionalCriticalValue, thetaStandardized. The function has to obtain the three-dots arument '...' (see examples).

Value

Returns a SimulationResultsMeans 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 <- getSimulationMeans(plannedSubjects = 40)
simulationResults$show(showStatistics = FALSE)

Example 2:
simulationResults <- getSimulationMeans(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. alternative: The alternative hypothesis value.

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

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

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

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

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

  9. effectEstimate: Standardized overall simulated effect estimate.

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

  11. 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 thetaH1.

Examples


# Fixed sample size with minimum required definitions, 
# alternative = c(0, 1, 2, 3, 4), standard deviation = 5  
getSimulationMeans(getDesignGroupSequential(), alternative = 40, 
    stDev = 50, plannedSubjects = c(20, 40, 60), thetaH1 = 60, 
    maxNumberOfIterations = 50)



# Increase number of simulation iterations and compare results 
# with power calculator using normal approximation 
getSimulationMeans(alternative = 0:4, stDev = 5, 
    plannedSubjects = 40, maxNumberOfIterations = 50)
getPowerMeans(alternative = 0:4, stDev = 5, 
    maxNumberOfSubjects = 40, normalApproximation = TRUE)

# Do the same for a three-stage O'Brien&Fleming inverse 
# normal group sequential design with non-binding futility stops
designIN <- getDesignInverseNormal(typeOfDesign = "OF", futilityBounds = c(0, 0))
x <- getSimulationMeans(designIN, alternative = c(0:4), stDev = 5, 
    plannedSubjects = c(20, 40, 60), maxNumberOfIterations = 1000)
getPowerMeans(designIN, alternative = 0:4, stDev = 5, 
    maxNumberOfSubjects = 60, normalApproximation = TRUE)

# Assess power and average sample size if a sample size increase is foreseen 
# at conditional power 80% for each subsequent stage based on observed overall 
# effect and specified minNumberOfSubjectsPerStage and
# maxNumberOfSubjectsPerStage
getSimulationMeans(designIN, alternative = 0:4, stDev = 5, 
    plannedSubjects = c(20, 40, 60), 
    minNumberOfSubjectsPerStage = c(20, 20, 20), 
    maxNumberOfSubjectsPerStage = c(80, 80, 80),
    conditionalPower = 0.8,	
	   maxNumberOfIterations = 50)

# Do the same under the assumption that a sample size increase only takes 
# place at the first interim. The sample size for the third stage is set equal 
# to the second stage sample size.
mySampleSizeCalculationFunction <- function(..., stage, 
        minNumberOfSubjectsPerStage,
        maxNumberOfSubjectsPerStage,
        sampleSizesPerStage,
        conditionalPower,
        conditionalCriticalValue,
        thetaStandardized) {
    if (stage == 2) {
        stageSubjects <- 4 * (max(0, conditionalCriticalValue + 
            stats::qnorm(conditionalPower)))^2 / (max(1e-12, thetaStandardized))^2
        stageSubjects <- min(max(minNumberOfSubjectsPerStage[stage], 
            stageSubjects), maxNumberOfSubjectsPerStage[stage])
    } else {
        stageSubjects <- sampleSizesPerStage[stage - 1]
    }
    return(stageSubjects)
}
getSimulationMeans(designIN, alternative = 2:4, stDev = 5, 
    plannedSubjects = c(20, 40, 60), 
    minNumberOfSubjectsPerStage = c(20, 20, 20), 
    maxNumberOfSubjectsPerStage = c(40, 160, 160),
    conditionalPower = 0.8, 
    calcSubjectsFunction = mySampleSizeCalculationFunction, 
    maxNumberOfIterations = 50)




[Package rpact version 2.0.5 Index | www.rpact.org]