library(rpact)
packageVersion("rpact") # version should be version 3.0 or later
How to Create Admirable Plots with rpact
Utilities
Sample size
Power simulation
Preparation
First, load the rpact package
[1] '4.1.1'
Design plots
One-sided design with futility bounds
<- getDesignGroupSequential(
design kMax = 3,
typeOfDesign = "OF",
sided = 1,
futilityBounds = c(0, 0.1)
)
|> plot(type = 1) design
|> plot(type = 5, nMax = 10) design
|> plot(type = 6, nMax = 10) design
Two-sided design
<- getDesignGroupSequential(
design kMax = 4,
typeOfDesign = "OF",
sided = 2,
twoSidedPower = TRUE
)
|> plot(type = 1) design
|> plot(type = 5, nMax = 10) design
|> plot(type = 6, nMax = 10) design
Two-sided design with futility bound
<- getDesignGroupSequential(
design beta = 0.05,
kMax = 4,
typeOfDesign = "asOF",
typeBetaSpending = "bsOF",
sided = 2
)
|> plot(type = 1) design
|> plot(type = 5, nMax = 10) design
|> plot(type = 6, nMax = 10) design
Sample size plots
Sample size means (continuous endpoint)
Sample size means for a one-sided design with futility bounds
<- getDesignGroupSequential(
sampleSizeMeans1 sided = 1,
futilityBounds = c(0, 0.2)) |>
getSampleSizeMeans()
|> plot(type = 1) sampleSizeMeans1
|> plot(type = 2) sampleSizeMeans1
Sample size means for a two-sided design
<- getDesignGroupSequential(sided = 2) |>
sampleSizeMeans2 getSampleSizeMeans()
|> plot(type = 1) sampleSizeMeans2
|> plot(type = 2) sampleSizeMeans2
Sample size rates (binary endpoint)
Sample size rates for a one-sided design with futility bounds
<- getDesignGroupSequential(
sampleSizeRates1 sided = 1,
futilityBounds = c(0, 0.1)) |>
getSampleSizeRates()
|> plot(type = 1) sampleSizeRates1
|> plot(type = 2) sampleSizeRates1
Sample size rates for a two-sided design
<- getDesignGroupSequential(sided = 2) |>
sampleSizeRates2 getSampleSizeRates()
|> plot(type = 1) sampleSizeRates2
|> plot(type = 2) sampleSizeRates2
Sample size survival (survival endpoint)
Sample size survival for a one-sided design with futility bounds
<- getDesignGroupSequential(
design kMax = 3,
typeOfDesign = "OF",
sided = 1,
futilityBounds = c(-1, 0.5)
)
<- list(
piecewiseSurvivalTime "0 - <6" = 0.025,
"6 - <9" = 0.04,
"9 - <15" = 0.015,
"15 - <21" = 0.01,
">= 21" = 0.007
)
<- getSampleSizeSurvival(
sampleSizeSurvival1 design = design,
typeOfComputation = "Schoenfeld",
thetaH0 = 1,
allocationRatioPlanned = 1,
kappa = 1,
piecewiseSurvivalTime = piecewiseSurvivalTime,
hazardRatio = c(0.5, 0.9)
)
|> plot(type = 1) sampleSizeSurvival1
|> plot(type = 2) sampleSizeSurvival1
|> plot(type = 13, legendPosition = 1) sampleSizeSurvival1
|> plot(type = 14) sampleSizeSurvival1
Sample size survival for a two-sided design
<- getDesignGroupSequential(
design kMax = 3,
typeOfDesign = "OF",
sided = 2,
twoSidedPower = TRUE
)
<- list(
piecewiseSurvivalTime "0 - <14" = 0.015,
"14 - <24" = 0.01,
"24 - <44" = 0.005,
">= 44" = 0.0025
)<- getSampleSizeSurvival(
sampleSizeSurvival2 design = design,
typeOfComputation = "Schoenfeld",
thetaH0 = 1,
allocationRatioPlanned = 1,
kappa = 1,
piecewiseSurvivalTime = piecewiseSurvivalTime,
maxNumberOfSubjects = 0,
hazardRatio = c(0.1, 0.2, 0.5, 0.6)
)
|> plot(type = 1) sampleSizeSurvival2
|> plot(type = 2) sampleSizeSurvival2
|> plot(type = 13, legendPosition = 1) sampleSizeSurvival2
|> plot(type = 14) sampleSizeSurvival2
Power plots
Power means (continuous endpoint)
Power means for a one-sided design with futility bounds
<- getDesignGroupSequential(
powerMeans1 typeOfDesign = "OF",
sided = 1,
futilityBounds = c(0, 0.5)) |>
getPowerMeans(
groups = 1,
meanRatio = FALSE,
thetaH0 = 0,
alternative = c(-1, 4),
stDev = 2,
normalApproximation = FALSE,
maxNumberOfSubjects = 40
)
|> plot(type = 1) powerMeans1
|> plot(type = 2) powerMeans1
|> plot(type = 5) powerMeans1
|> plot(type = 6) powerMeans1
Power means for a two-sided design
<- getDesignGroupSequential(
powerMeans2 typeOfDesign = "OF",
sided = 2,
twoSidedPower = TRUE) |>
getPowerMeans(maxNumberOfSubjects = 30)
|> plot(type = 1) powerMeans2
|> plot(type = 2) powerMeans2
|> plot(type = 5) powerMeans2
|> plot(type = 6) powerMeans2
Power rates (binary endpoint)
Power rates for a one-sided design with futility bounds
<- getDesignGroupSequential(
powerRates1 kMax = 3,
typeOfDesign = "OF",
sided = 1,
futilityBounds = c(-1, 0.5)) |>
getPowerRates(
groups = 2,
riskRatio = TRUE,
thetaH0 = 0.2,
allocationRatioPlanned = 1,
pi1 = c(0.1, 0.4),
pi2 = 0.2,
maxNumberOfSubjects = 80
)
|> plot(type = 1) powerRates1
|> plot(type = 2) powerRates1
|> plot(type = 5) powerRates1
|> plot(type = 6) powerRates1
Power rates for a two-sided design
<- getDesignGroupSequential(
powerRates2 typeOfDesign = "OF",
sided = 2,
twoSidedPower = TRUE) |>
getPowerRates(maxNumberOfSubjects = 120)
|> plot(type = 1) powerRates2
|> plot(type = 2) powerRates2
|> plot(type = 5) powerRates2
|> plot(type = 6) powerRates2
Power survival (survival endpoint)
Power survival for a one-sided design with futility bounds
<- getDesignGroupSequential(
powerSurvival kMax = 3,
typeOfDesign = "OF",
sided = 1,
futilityBounds = c(0, 0)) |>
getPowerSurvival(
typeOfComputation = "Schoenfeld",
thetaH0 = 1,
allocationRatioPlanned = 1,
kappa = 1,
maxNumberOfSubjects = 2480,
maxNumberOfEvents = 70
)
|> plot(type = 1) powerSurvival
|> plot(type = 2) powerSurvival
|> plot(type = 5) powerSurvival
|> plot(type = 6) powerSurvival
|> plot(type = 7) powerSurvival
|> plot(type = 12) powerSurvival
Power for a piecewise exponential survival distribution
<- list(
piecewiseSurvivalTime "<5" = 0.04,
"5 - <10" = 0.02,
">= 10" = 0.008
)
<- getDesignGroupSequential(
powerSurvival1 kMax = 3,
typeOfDesign = "OF",
sided = 2,
twoSidedPower = TRUE
|>
) getPowerSurvival(
typeOfComputation = "Schoenfeld",
thetaH0 = 1,
allocationRatioPlanned = 1,
kappa = 1,
piecewiseSurvivalTime = piecewiseSurvivalTime,
maxNumberOfSubjects = 2480,
maxNumberOfEvents = 70,
hazardRatio = c(0.5, 2)
)
|> plot(type = 1) powerSurvival1
|> plot(type = 2) powerSurvival1
|> plot(type = 12) powerSurvival1
|> plot(type = 13, legendPosition = 1) powerSurvival1
|> plot(type = 14, legendPosition = 5) powerSurvival1
Power for a piecewise exponential survival distribution and a design with futility bounds
<- list(
piecewiseSurvivalTime "0 - <6" = 0.025,
"6 - <9" = 0.04,
"9 - <15" = 0.015,
"15 - <21" = 0.01,
">= 21" = 0.007
)
<- getDesignGroupSequential(
powerSurvival2 typeOfDesign = "OF",
sided = 1,
futilityBounds = c(0, 0.1)) |>
getPowerSurvival(
typeOfComputation = "Schoenfeld",
thetaH0 = 1,
allocationRatioPlanned = 1,
kappa = 1,
piecewiseSurvivalTime = piecewiseSurvivalTime,
maxNumberOfSubjects = 2480,
maxNumberOfEvents = 70,
hazardRatio = 0.8
)
|> plot(type = 1) powerSurvival2
|> plot(type = 2) powerSurvival2
|> plot(type = 13, legendPosition = 1) powerSurvival2
|> plot(type = 14) powerSurvival2
<- getDesignGroupSequential(
powerSurvival3 typeOfDesign = "OF",
sided = 1,
futilityBounds = c(0, 0.1)) |>
getPowerSurvival(
typeOfComputation = "Schoenfeld",
thetaH0 = 1,
allocationRatioPlanned = 1,
kappa = 1,
piecewiseSurvivalTime = c(0, 5, 10),
lambda2 = c(0.025, 0.04, 0.015),
lambda1 = c(0.02, 0.032, 0.012),
maxNumberOfSubjects = 2480,
maxNumberOfEvents = 70
)
|> plot(type = 1) powerSurvival3
|> plot(type = 2) powerSurvival3
|> plot(type = 13, legendPosition = 1) powerSurvival3
|> plot(type = 14) powerSurvival3
Power survival for one lambda
<- getPowerSurvival(
powerSurvival4 accrualTime = 12,
lambda2 = 0.04,
hazardRatio = 0.6,
maxNumberOfSubjects = 1400,
maxNumberOfEvents = 300
)
|> plot(type = 13, legendPosition = 1) powerSurvival4
|> plot(type = 14, legendPosition = 5) powerSurvival4
Power survival for default pi1 and pi2
<- getPowerSurvival(
powerSurvival5 maxNumberOfSubjects = 1400,
maxNumberOfEvents = 300
)
|> plot(type = 13, legendPosition = 1) powerSurvival5
|> plot(type = 14, legendPosition = 5) powerSurvival5
Simulation plots
Simulation means (continuous endpoint)
<- getSimulationMeans(
simulationResults1 design = getDesignFisher(kMax = 2),
plannedSubjects = c(20, 40),
maxNumberOfIterations = 1000,
seed = 12345
)
|> plot(type = "all", grid = 0) simulationResults1
|> plot(type = 4) simulationResults1
|> plot(type = 5) simulationResults1
|> plot(type = 6) simulationResults1
Simulation rates (binary endpoint)
<- getSimulationRates(
simulationResults1 design = getDesignFisher(kMax = 2),
plannedSubjects = c(20, 40), maxNumberOfIterations = 1000,
seed = 12345
)
plot(simulationResults1, type = 4)
plot(simulationResults1, type = 5)
plot(simulationResults1, type = 6)
Simulation plots survival (survival endpoint)
<- getSimulationSurvival(
simulationResults1 accrualTime = 12,
maxNumberOfSubjects = 1405,
plannedEvents = 300,
maxNumberOfIterations = 1000,
seed = 12345
)
|> plot(type = 5) simulationResults1
|> plot(type = 6) simulationResults1
|> plot(type = 7) simulationResults1
|> plot(type = 9) simulationResults1
|> plot(type = 10) simulationResults1
|> plot(type = 11) simulationResults1
|> plot(type = 12) simulationResults1
|> plot(type = 13) simulationResults1
|> plot(type = 14) simulationResults1
<- getSimulationSurvival(
simulationResults2 accrualTime = 12,
lambda2 = 0.03,
hazardRatio = 0.8,
maxNumberOfSubjects = 1405,
plannedEvents = 300,
maxNumberOfIterations = 1000,
seed = 23456
)
|> plot(type = 13) simulationResults2
|> plot(type = 14) simulationResults2
System: rpact 4.1.1, R version 4.4.2 (2024-10-31 ucrt), platform: x86_64-w64-mingw32
To cite R in publications use:
R Core Team (2024). R: A Language and Environment for Statistical Computing. R Foundation for Statistical Computing, Vienna, Austria. https://www.R-project.org/.
To cite package ‘rpact’ in publications use:
Wassmer G, Pahlke F (2024). rpact: Confirmatory Adaptive Clinical Trial Design and Analysis. R package version 4.1.1, https://www.rpact.com, https://github.com/rpact-com/rpact, https://rpact-com.github.io/rpact/, https://www.rpact.org.