Kopecky K and Green S (2012). Noninferiority trials. In: Handbook of Statistics in Clinical Oncology. Crowley J and Hoering A, eds. CRC Press, Boca Raton, FL USA.

This program calculates the required sample size for a two-arm non-inferiority design with a binomial outcome. N is calculated by the following formula for specified power = 100(1 - \(\beta\))% and the true success probabilities are \(P_{E}\) and \(P_{S}\): \[ N = [\frac{Z_{\alpha/2} + Z_{\beta}}{M + (P_{E} - P_{S})}]^2 * [\frac{P_{E}(1 - P_{E})}{K_{E}} + \frac{P_{S}(1 - P_{S})}{1 - K_{E}}] \] where

- N is the total number patients
- \(K_{E}\) is the proportion randomized to E.

**Alpha level**(*one-sided*) \(\alpha\): The desired type I error rate. This corresponds to a specification of a (1 - 2 * \(\alpha\))% confidence interval around the difference between the rates.**Power**: Enter the desired power, 0-1, to rule out the null hypothesis of inferiority.**Noninferiority Margin**: Enter the largest acceptable difference in success rates between the standard arm and the experimental arm that would be consistent with noninferiority.**Proportion of patients in the experimental arm**(*0.5*): Enter the proportion of patients (0-1) out of the total N that will be assigned to the experimental arm.**Success Probability in Standard Arm and Experimental Arm**: Enter the expected success probability for the standard arm, and the experimental arm. Typically these are specified as equal, but equality is not required.

**Alpha level**(*one-sided*) \(\alpha\): The desired type I error rate. This corresponds to a specification of a (1 - 2 * \(\alpha\))% confidence interval around the difference between the rates.**Power**: Enter the desired power, 0-1, to rule out the null hypothesis of inferiority.**Success Probability in Experimental Arm (Under H0)**: Enter the assumed success probability under the null hypothesis. Note that the difference between the success probability in the standard arm, and this input, is the largest acceptable difference that would be consistent with noninferiority.**Proportion of patients in the experimental arm**(*0.5*): Enter the proportion of patients (0-1) out of the total N that will be assigned to the experimental arm.**Success Probability in Standard Arm and Experimental Arm**: Enter the expected success probability for the standard arm, and the experimental arm. Typically these are specified as equal, but equality is not required.

- Total sample size.

The program is written in *R*.

```
function(alpha_level, power_level, margin, p_success_E, p_success_S, k_E)
{
za = qnorm(alpha_level, lower.tail = FALSE)
zb = qnorm(power_level)
n = ((za + zb) / (margin + p_success_E - p_success_S))^2 * (((p_success_E * (1 - p_success_E)) / k_E) + ((p_success_S * (1 - p_success_S)) / (1 - k_E)))
result = list(n = round(n, digits = 0))
return(jsonlite::toJSON(result, pretty = TRUE))
}
```