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

# Summary

This R Markdown document provides examples for designing trials with binary endpoints using rpact.

# 1 Sample size calculation for a superiority trial with two groups without interim analyses

The sample size for a trial with binary endpoints can be calculated using the function `getSampleSizeRates()`. This function is fully documented in the help page (`?getSampleSizeRates`). Hence, we only provide some examples below.

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

To get the direction of the effects correctly, note that in rpact the index “2” in an argument name always refers to the control group, “1” to the intervention group, and treatment effects compare treatment versus control. Specifically, for binary endpoints, the probabilities of an event in the control group and intervention group, respectively, are given by arguments `pi2` and `pi1`. The default treatment effect is the absolute risk difference `pi1 - pi2` but the relative risk scale `pi1/pi2` is also supported if the argument `riskRatio` is set to `TRUE`.

``````# Example of a standard trial:
# - probability 25% in control (pi2 = 0.25) vs. 40% (pi1 = 0.4) in intervention
# - one-sided test (sided = 1)
# - Type I error 0.025 (alpha = 0.025) and power 80% (beta = 0.2)
sampleSizeResult <- getSampleSizeRates(
pi2 = 0.25, pi1 = 0.4,
sided = 1, alpha = 0.025, beta = 0.2
)
kable(sampleSizeResult)``````

Design plan parameters and output for rates

Design parameters

• Critical values: 1.96
• Significance level: 0.0250
• Type II error rate: 0.2000
• Test: one-sided

User defined parameters

• Assumed treatment rate: 0.400
• Assumed control rate: 0.250

Default parameters

• Risk ratio: FALSE
• Theta H0: 0
• Normal approximation: TRUE
• Treatment groups: 2
• Planned allocation ratio: 1

Sample size and output

• Direction upper: TRUE
• Number of subjects fixed: 303.7
• Number of subjects fixed (1): 151.9
• Number of subjects fixed (2): 151.9
• Critical values (treatment effect scale): 0.103

Legend

• (i): values of treatment arm i

As per the output above, the required total sample size is 304 and the critical value corresponds to a minimal detectable difference (on the absolute risk difference scale, the default) of approximately 0.103. This calculation assumes that pi2 = 0.25 is the observed rate in treatment group 2.

A useful summary is provided with the generic `summary()` function:

``kable(summary(sampleSizeResult))``

Sample size calculation for a binary endpoint

Fixed sample analysis, significance level 2.5% (one-sided). The sample size was calculated for a two-sample test for rates (normal approximation), H0: pi(1) - pi(2) = 0, H1: treatment rate pi(1) = 0.4, control rate pi(2) = 0.25, power 80%.

Stage Fixed
Efficacy boundary (z-value scale) 1.960
Number of subjects 303.7
One-sided local significance level 0.0250
Efficacy boundary (t) 0.103

Legend:

• (t): treatment effect scale

You can change the randomization allocation between the treatment groups using `allocationRatioPlanned`:

``````# Example: Extension of standard trial
# - 2(intervention):1(control) randomization (allocationRatioPlanned = 2)
kable(summary(getSampleSizeRates(
pi2 = 0.25, pi1 = 0.4,
sided = 1, alpha = 0.025, beta = 0.2,
allocationRatioPlanned = 2
)))``````

Sample size calculation for a binary endpoint

Fixed sample analysis, significance level 2.5% (one-sided). The sample size was calculated for a two-sample test for rates (normal approximation), H0: pi(1) - pi(2) = 0, H1: treatment rate pi(1) = 0.4, control rate pi(2) = 0.25, planned allocation ratio = 2, power 80%.

Stage Fixed
Efficacy boundary (z-value scale) 1.960
Number of subjects 346.3
One-sided local significance level 0.0250
Efficacy boundary (t) 0.104

Legend:

• (t): treatment effect scale

`allocationRatioPlanned = 0` can be defined in order to obtain the optimum allocation ratio minimizing the overall sample size (the optimum ample size is only slightly smaller than sample size with equal allocation; practically, this has no effect):

``````# Example: Extension of standard trial
# optimum randomization ratio
kable(summary(getSampleSizeRates(
pi2 = 0.25, pi1 = 0.4,
sided = 1, alpha = 0.025, beta = 0.2,
allocationRatioPlanned = 0
)))``````

Sample size calculation for a binary endpoint

Fixed sample analysis, significance level 2.5% (one-sided). The sample size was calculated for a two-sample test for rates (normal approximation), H0: pi(1) - pi(2) = 0, H1: treatment rate pi(1) = 0.4, control rate pi(2) = 0.25, optimum planned allocation ratio = 0.953, power 80%.

Stage Fixed
Efficacy boundary (z-value scale) 1.960
Number of subjects 303.6
One-sided local significance level 0.0250
Efficacy boundary (t) 0.103

Legend:

• (t): treatment effect scale

Power at given sample size can be calculated using the function `getPowerRates()`. This function has the same arguments as `getSampleSizeRates()` except that the maximum total sample size needs to be defined (`maxNumberOfSubjects`) and the Type II error `beta` is no longer needed. For one-sided tests, the direction of the test is also required. The default `directionUpper = TRUE` indicates that for the alternative the probability in the intervention group `pi1` is larger than the probability in the control group `pi2` (`directionUpper = FALSE` is the other direction):

``````# Example: Calculate power for a simple trial with total sample size 304
# as in the example above in case of pi2 = 0.25 (control) and
# pi1 = 0.37 (intervention)
powerResult <- getPowerRates(
pi2 = 0.25, pi1 = 0.37,
maxNumberOfSubjects = 304, sided = 1, alpha = 0.025
)
kable(powerResult)``````

Design plan parameters and output for rates

Design parameters

• Critical values: 1.96
• Significance level: 0.0250
• Test: one-sided

User defined parameters

• Assumed treatment rate: 0.370
• Assumed control rate: 0.250
• Direction upper: NA
• Maximum number of subjects: 304

Default parameters

• Risk ratio: FALSE
• Theta H0: 0
• Normal approximation: TRUE
• Treatment groups: 2
• Planned allocation ratio: 1

Sample size and output

• Effect: 0.12
• Number of subjects fixed: 304
• Number of subjects fixed (1): 152
• Number of subjects fixed (2): 152
• Overall reject: 0.6196
• Critical values (treatment effect scale): 0.103

Legend

• (i): values of treatment arm i

The calculated power is provided in the output as “Overall reject” and is 0.620 for the example.

The `summary()` command produces the output

``kable(summary(powerResult))``

Power calculation for a binary endpoint

Fixed sample analysis, significance level 2.5% (one-sided). The results were calculated for a two-sample test for rates (normal approximation), H0: pi(1) - pi(2) = 0, power directed towards larger values, H1: treatment rate pi(1) = 0.37, control rate pi(2) = 0.25, number of subjects = 304.

Stage Fixed
Efficacy boundary (z-value scale) 1.960
Power 0.6196
Number of subjects 304.0
One-sided local significance level 0.0250
Efficacy boundary (t) 0.103

Legend:

• (t): treatment effect scale

The `getPowerRates()` (as well as `getSampleSizeRates()`) functions can also be called with a vector argument for the probability `pi1` in the intervention group. This is illustrated below via a plot of power depending on this probability. For examples of all available plots, see the R Markdown document How to create admirable plots with rpact.

``````# Example: Calculate power for simple design (with sample size 304 as above)
# for probabilities in intervention ranging from 0.3 to 0.5
powerResult <- getPowerRates(
pi2 = 0.25, pi1 = seq(0.3, 0.5, by = 0.01),
maxNumberOfSubjects = 304, sided = 1, alpha = 0.025
)

# one of several possible plots, this one plotting true effect size vs power
plot(powerResult, type = 7)``````