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

Summary

The aim of this R Markdown document is to give a brief description on how easy it is to supplement and enhance plots generated in rpact by use of the ggplot2 package and associated language.

1 Introduction

We will illustrate the generation of the plots by assessing the simulated Type I error rate of a group-sequential and adaptive inverse-normal design in a sample size recalculation setting. It is well known that the adaptive inverse-normal designs in contrast to group-sequential designs controls the overall Type I error rate even in a setting of sample size recalculation. The goal of this exercise is to present this fact in a single comprehensive output.

With rpact it is very convenient to calculate the necessary components: We will analyze both design choices by rpact, retrieve the results and arrange them by the means of ggplot2.

Throughout this document, we will use the default parameter settings from rpact which assume a one-sided significance level of 0.025.

Loading the packages

We start by loading the required two packages.

library(rpact)
packageVersion("rpact")
## [1] '3.2.1'
library(ggplot2)

2 Initialize the group-sequential and adaptive inverse-normal design

After the two packages were loaded, the group-sequential (dGS) and adaptive inverse-normal (dIN) design can be generated.

dGS <- getDesignGroupSequential()
dIN <- getDesignInverseNormal()

We can now take a look into both designs and inspect their default values.

dGS
## Design parameters and output of group sequential design:
## 
## User defined parameters: not available
## 
## Derived from user defined parameters: not available
## 
## Default parameters:
##   Type of design                               : O'Brien & Fleming 
##   Maximum number of stages                     : 3 
##   Stages                                       : 1, 2, 3 
##   Information rates                            : 0.333, 0.667, 1.000 
##   Significance level                           : 0.0250 
##   Type II error rate                           : 0.2000 
##   Two-sided power                              : FALSE 
##   Test                                         : one-sided 
##   Tolerance                                    : 0.00000001 
## 
## Output:
##   Cumulative alpha spending                    : 0.0002592, 0.0071601, 0.0250000 
##   Critical values                              : 3.471, 2.454, 2.004 
##   Stage levels (one-sided)                     : 0.0002592, 0.0070554, 0.0225331
dIN
## Design parameters and output of inverse normal combination test design:
## 
## User defined parameters: not available
## 
## Derived from user defined parameters: not available
## 
## Default parameters:
##   Type of design                               : O'Brien & Fleming 
##   Maximum number of stages                     : 3 
##   Stages                                       : 1, 2, 3 
##   Information rates                            : 0.333, 0.667, 1.000 
##   Significance level                           : 0.0250 
##   Type II error rate                           : 0.2000 
##   Two-sided power                              : FALSE 
##   Test                                         : one-sided 
##   Tolerance                                    : 0.00000001 
## 
## Output:
##   Cumulative alpha spending                    : 0.0002592, 0.0071601, 0.0250000 
##   Critical values                              : 3.471, 2.454, 2.004 
##   Stage levels (one-sided)                     : 0.0002592, 0.0070554, 0.0225331

In the output we see some important characteristics like the type of design (OF = O’Brien and Fleming), the maximum number of stages (3), the information rates (0.333, 0.667, 1.000), the significance level (0.025) and the stage level information (0.0002592, 0.0070554, 0.0225331).

We can also easily plot the stage level information by means of rpact.

plot(dGS, type = 3)

plot(dIN, type = 3)

With these commands, rpact creates two plots that show the three stage levels (0.0025, 0.0070554, 0.0225331) visually together with the corresponding information rates (0.333, 0.667, 1.000) and the significance level (0.025, dashed line).

3 Modification of the rpact base plots with ggplot2 (aesthetic) commands

We note that the two prior plots are identical. This is expected as the same boundary type (O’Brien and Fleming) was used for both designs. So, we might want to restrict ourselves to present only one stage level plot. Instead, we can include this information in a custom title. This is achieved by combining the rpact “base” plot with ggplot2 aesthetics commands as follows:

plot(dGS, type = 3) + 
  ggtitle("Stage level plot of the adaptive and group-sequential design")

All ggplot2 aesthetic commands which modify an existing plot are initiated by a plus sign “+”. Thereafter, we can add the particular command in the ggplot2 language to specify how we want to modify the plot. Luckily, almost all rpact graphics are compatible with ggplot2.

Modifications are not restriction to additions to existing plots, as demonstrated by adding a new title, but they can also re-model the initial plot. For example, we can change the limits of the x- and y-axis post-hoc.

plot(dGS, type = 3) + xlim(0, 1) + ylim(0, dGS$alpha + 0.005)
## Scale for 'x' is already present. Adding another scale for 'x', which will
## replace the existing scale.