```
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.0.1.9252'`

# Design plots

## One-sided design with futility bounds

```
<- getDesignGroupSequential(
design kMax = 3,
typeOfDesign = "OF", sided = 1,
futilityBounds = c(0, 0.1)
)
plot(design, type = 1)
```

`plot(design, type = 5, nMax = 10)`

`plot(design, type = 6, nMax = 10)`

## Two-sided design

```
<- getDesignGroupSequential(
design kMax = 4, typeOfDesign = "OF", sided = 2, twoSidedPower = TRUE
)
plot(design, type = 1)
```

`plot(design, type = 5, nMax = 10)`

`plot(design, type = 6, nMax = 10)`

## Two-sided design with futility bound

```
<- getDesignGroupSequential(
design beta = 0.05, kMax = 4, typeOfDesign = "asOF",
typeBetaSpending = "bsOF", sided = 2
)
plot(design, type = 1)
```

`plot(design, type = 5, nMax = 10)`

`plot(design, type = 6, nMax = 10)`

# Sample size plots

## Sample size means (continuous endpoint)

### Sample size means for a one-sided design with futility bounds

```
<- getSampleSizeMeans(
sampleSizeMeans1 getDesignGroupSequential(
sided = 1,
futilityBounds = c(0, 0.2)
)
)
plot(sampleSizeMeans1, type = 1)
```

`plot(sampleSizeMeans1, type = 2)`

### Sample size means for a two-sided design

```
<- getSampleSizeMeans(
sampleSizeMeans2 getDesignGroupSequential(sided = 2)
)
plot(sampleSizeMeans2, type = 1)
```

`plot(sampleSizeMeans2, type = 2)`

## Sample size rates (binary endpoint)

### Sample size rates for a one-sided design with futility bounds

```
<- getSampleSizeRates(
sampleSizeRates1 getDesignGroupSequential(
sided = 1,
futilityBounds = c(0, 0.1)
)
)
plot(sampleSizeRates1, type = 1)
```

`plot(sampleSizeRates1, type = 2)`

### Sample size rates for a two-sided design

```
<- getSampleSizeRates(
sampleSizeRates2 getDesignGroupSequential(sided = 2)
)
plot(sampleSizeRates2, type = 1)
```

`plot(sampleSizeRates2, type = 2)`

## 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(sampleSizeSurvival1, type = 1)
```

`plot(sampleSizeSurvival1, type = 2)`

`plot(sampleSizeSurvival1, type = 13, legendPosition = 1)`

`plot(sampleSizeSurvival1, type = 14)`

### 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(sampleSizeSurvival2, type = 1)
```

`plot(sampleSizeSurvival2, type = 2)`

`plot(sampleSizeSurvival2, type = 13, legendPosition = 1)`

`plot(sampleSizeSurvival2, type = 14)`

# Power plots

## Power means (continuous endpoint)

### Power means for a one-sided design with futility bounds

```
<- getDesignGroupSequential(
design typeOfDesign = "OF", sided = 1,
futilityBounds = c(0, 0.5)
)
<- getPowerMeans(design,
powerMeans1 groups = 1, meanRatio = FALSE,
thetaH0 = 0, alternative = c(-1, 4),
stDev = 2, normalApproximation = FALSE,
maxNumberOfSubjects = 40
)
plot(powerMeans1, type = 1)
```

`plot(powerMeans1, type = 2)`

`plot(powerMeans1, type = 5)`

`plot(powerMeans1, type = 6)`

### Power means for a two-sided design

```
<- getPowerMeans(
powerMeans2 getDesignGroupSequential(
typeOfDesign = "OF", sided = 2, twoSidedPower = TRUE
),maxNumberOfSubjects = 30
)
plot(powerMeans2, type = 1)
```

`plot(powerMeans2, type = 2)`

`plot(powerMeans2, type = 5)`

`plot(powerMeans2, type = 6)`

## Power rates (binary endpoint)

### Power rates for a one-sided design with futility bounds

```
<- getDesignGroupSequential(
design kMax = 3,
typeOfDesign = "OF",
sided = 1,
futilityBounds = c(-1, 0.5)
)
<- getPowerRates(design,
powerRates1 groups = 2, riskRatio = TRUE,
thetaH0 = 0.2, allocationRatioPlanned = 1,
pi1 = c(0.1, 0.4), pi2 = 0.2,
maxNumberOfSubjects = 80
)
plot(powerRates1, type = 1)
```

`plot(powerRates1, type = 2)`

`plot(powerRates1, type = 5)`

`plot(powerRates1, type = 6)`

### Power rates for a two-sided design

```
<- getPowerRates(
powerRates2 getDesignGroupSequential(
typeOfDesign = "OF", sided = 2, twoSidedPower = TRUE
),maxNumberOfSubjects = 120
)
plot(powerRates2, type = 1)
```

`plot(powerRates2, type = 2)`

`plot(powerRates2, type = 5)`

`plot(powerRates2, type = 6)`

## Power survival (survival endpoint)

### Power survival for a one-sided design with futility bounds

```
<- getDesignGroupSequential(
design kMax = 3,
typeOfDesign = "OF", sided = 1,
futilityBounds = c(0, 0)
)
<- getPowerSurvival(
powerSurvival design = design,
typeOfComputation = "Schoenfeld", thetaH0 = 1,
allocationRatioPlanned = 1, kappa = 1,
maxNumberOfSubjects = 2480,
maxNumberOfEvents = 70
)
plot(powerSurvival, type = 1)
```

`plot(powerSurvival, type = 2)`

`plot(powerSurvival, type = 5)`

`plot(powerSurvival, type = 6)`

`plot(powerSurvival, type = 7)`

`plot(powerSurvival, type = 12)`

### Power for a piecewise exponential survival distribution

```
<- getDesignGroupSequential(
design kMax = 3, typeOfDesign = "OF",
sided = 2, twoSidedPower = TRUE
)<- list(
piecewiseSurvivalTime "<5" = 0.04,
"5 - <10" = 0.02,
">= 10" = 0.008
)
<- getPowerSurvival(
powerSurvival1 design = design,
typeOfComputation = "Schoenfeld", thetaH0 = 1,
allocationRatioPlanned = 1, kappa = 1,
piecewiseSurvivalTime = piecewiseSurvivalTime,
maxNumberOfSubjects = 2480, maxNumberOfEvents = 70,
hazardRatio = c(0.5, 2)
)
plot(powerSurvival1, type = 1)
```

`plot(powerSurvival1, type = 2)`

`plot(powerSurvival1, type = 12)`

`plot(powerSurvival1, type = 13, legendPosition = 1)`

`plot(powerSurvival1, type = 14, legendPosition = 5)`

### Power for a piecewise exponential survival distribution and a design with futility bounds

```
<- getDesignGroupSequential(
design typeOfDesign = "OF", sided = 1,
futilityBounds = c(0, 0.1)
)
<- list(
piecewiseSurvivalTime "0 - <6" = 0.025,
"6 - <9" = 0.04,
"9 - <15" = 0.015,
"15 - <21" = 0.01,
">= 21" = 0.007
)
<- getPowerSurvival(
powerSurvival2 design = design,
typeOfComputation = "Schoenfeld", thetaH0 = 1,
allocationRatioPlanned = 1, kappa = 1,
piecewiseSurvivalTime = piecewiseSurvivalTime,
maxNumberOfSubjects = 2480, maxNumberOfEvents = 70,
hazardRatio = 0.8
)plot(powerSurvival2, type = 1)
```

`plot(powerSurvival2, type = 2)`

`plot(powerSurvival2, type = 13, legendPosition = 1)`

`plot(powerSurvival2, type = 14)`

```
<- getDesignGroupSequential(
design typeOfDesign = "OF", sided = 1,
futilityBounds = c(0, 0.1)
)
<- getPowerSurvival(
powerSurvival3 design = design,
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(powerSurvival3, type = 1)
```

`plot(powerSurvival3, type = 2)`

`plot(powerSurvival3, type = 13, legendPosition = 1)`

`plot(powerSurvival2, type = 14)`

### Power survival for one lambda

```
<- getPowerSurvival(
powerSurvival4 accrualTime = 12,
lambda2 = 0.04,
hazardRatio = 0.6,
maxNumberOfSubjects = 1400,
maxNumberOfEvents = 300
)
plot(powerSurvival4, type = 13, legendPosition = 1)
```

`plot(powerSurvival4, type = 14, legendPosition = 5)`

### Power survival for default pi1 and pi2

```
<- getPowerSurvival(
powerSurvival5 maxNumberOfSubjects = 1400,
maxNumberOfEvents = 300
)
plot(powerSurvival5, type = 13, legendPosition = 1)
```

`plot(powerSurvival5, type = 14, legendPosition = 5)`

# Simulation plots

## Simulation means (continuous endpoint)

```
<- getSimulationMeans(
simulationResults1 design = getDesignFisher(kMax = 2),
plannedSubjects = c(20, 40), maxNumberOfIterations = 1000,
seed = 12345
)
plot(simulationResults1, type = "all", grid = 0)
```

`plot(simulationResults1, type = 4)`

`plot(simulationResults1, type = 5)`

`plot(simulationResults1, type = 6)`

## 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(simulationResults1, type = 5)
```

`plot(simulationResults1, type = 6)`

`plot(simulationResults1, type = 7)`

`plot(simulationResults1, type = 9)`

`plot(simulationResults1, type = 10)`

`plot(simulationResults1, type = 11)`

`plot(simulationResults1, type = 12)`

`plot(simulationResults1, type = 13)`

`plot(simulationResults1, type = 14)`

```
<- getSimulationSurvival(
simulationResults2 accrualTime = 12,
lambda2 = 0.03,
hazardRatio = 0.8,
maxNumberOfSubjects = 1405,
plannedEvents = 300, maxNumberOfIterations = 1000,
seed = 23456
)
plot(simulationResults2, type = 13)
```

`plot(simulationResults2, type = 14)`

System: rpact 4.0.1.9252, R version 4.3.3 (2024-02-29 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.0.1.9252, https://www.rpact.com, https://github.com/rpact-com/rpact, https://rpact-com.github.io/rpact/, https://www.rpact.org.