Free examples and use-cases:   rpact vignettes
rpact: Confirmatory Adaptive Clinical Trial Design and Analysis

Summary

This R Markdown document provides many different examples for creating plots with rpact and ggplot2, e.g. the plot arguments type and showSource will be illustrated.

1 Design plots

First, load the rpact package

library(rpact)
packageVersion("rpact") # version should be version 2.0.5 or later
## [1] '3.2.1'

1.1 One-sided design with futility bounds

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

plot(design, type = 1, showSource = TRUE)
## Source data of the plot (type 1):
##   x-axis: design$informationRates
##   y-axes:
##     y1: c(design$futilityBounds, design$criticalValues[length(design$criticalValues)])
##     y2: design$criticalValues
## Simple plot command examples:
##   plot(design$informationRates, c(design$futilityBounds, design$criticalValues[length(design$criticalValues)]), type = "l")
##   plot(design$informationRates, design$criticalValues, type = "l")

plot(design, type = 3, showSource = TRUE)
## Source data of the plot (type 3):
##   x-axis: design$informationRates
##   y-axis: design$stageLevels
## Simple plot command example:
##   plot(design$informationRates, design$stageLevels, type = "l")

plot(design, type = 4, showSource = TRUE)
## Source data of the plot (type 4):
##   x-axis: design$informationRates
##   y-axis: design$alphaSpent
## Simple plot command example:
##   plot(design$informationRates, design$alphaSpent, type = "l")

plot(design, type = 5, nMax = 10, showSource = TRUE) 
## Source data of the plot (type 5):
##   x-axis: seq(-1, 1, 0.01)
##   y-axes:
##     y1: getPowerAndAverageSampleNumber(design, theta = seq(-1, 1, 0.01), nMax = 10)$overallEarlyStop
##     y2: getPowerAndAverageSampleNumber(design, theta = seq(-1, 1, 0.01), nMax = 10)$calculatedPower
## Simple plot command examples:
##   plot(seq(-1, 1, 0.01), getPowerAndAverageSampleNumber(design, theta = seq(-1, 1, 0.01), nMax = 10)$overallEarlyStop, type = "l")
##   plot(seq(-1, 1, 0.01), getPowerAndAverageSampleNumber(design, theta = seq(-1, 1, 0.01), nMax = 10)$calculatedPower, type = "l")