Compute sample size for a Phase 2 study of a binary test using either normal approximation or via simulation.
In simulations, the function goes through a grid of sample sizes and computes empirically the power for the given alternatives `FPF1`

and `TPF1`

.
The test decision is based on a rectangular confidence region using one-sided confidence limits for these two binomial parameters where the confidence intervals
are either computed according
to Wilson's method or exact as Clopper-Pearson intervals. The chosen sample sizes are the smallest numbers of cases and controls where the power is above `power`

for all subsequent
combinations. It may happen that the desired power is reached for even smaller numbers of cases and controls but that for larger numbers we find power below
the desired limit. This phenomena can be attributed to the discrete nature of the problem and is well-known from the similar setup for one binomial proportion.

1 2 3 4 5 | ```
sampleSizePhase2BinaryTest(FPF0 = 0.2, TPF0 = 0.75, FPF1 = 0.05, TPF1 = 0.9,
alpha = 0.05, power = 0.9)
sampleSizePhase2BinaryTestSimulated(FPF0, TPF0, FPF1, TPF1,
alpha = 0.05, power = 0.9, M = 5000, range = 15,
print = TRUE, type = c("wilson", "exact")[2])
``` |

`FPF0` |
Minimally acceptable value for the false positive fraction. |

`TPF0` |
Minimally acceptable value for the true positive fraction. |

`FPF1` |
Desirable value for the false positive fraction. |

`TPF1` |
Desirable value for the true positive fraction. |

`alpha` |
Significance level. |

`power` |
Desired power, i.e. 1 - probability of type II error. |

`M` |
Number of diagnostic tests to be simulated for the alternative. |

`range` |
Starting from the normally approximated sample size |

`print` |
If |

`type` |
Confidence interval to be used: either Wilson or the exact by Clopper and Pearson. |

A list with the entries

`n.cases` |
Number of cases necessary to achieve prescribed power based on wald test. |

`n.controls` |
Number of cases necessary to achieve prescribed power based on wald test. |

for `sampleSizePhase2BinaryTest`

and entries

`wald.n.cases` |
Number of cases necessary to achieve prescribed power based on wald test. |

`wald.n.controls` |
Number of cases necessary to achieve prescribed power based on wald test. |

`simul.n.cases` |
Number of cases necessary to achieve prescribed power based on simulations. |

`simul.n.controls` |
Number of controls necessary to achieve prescribed power based on simulations. |

`simul.power` |
Actual power that is achieved in simulations. |

`alphastar` |
Confidence level for the two univariate confidence intervals for FPF and TPF, equals |

`simul.powers` |
Computed powers for all the number of cases/controls combinations in simulations. |

Kaspar Rufibach

kaspar.rufibach@gmail.com

Pepe, M.S. (2003) *The statistical evaluation of medical tests for classification and prediction*.
Oxford: Oxford University Press.

The function `sampleSizePhase2BinaryTestSimulated`

depends on `sampleSizePhase2BinaryTest`

, `wilson`

, and clopperPearson.

1 2 3 4 5 6 | ```
## Example 8.1 in Pepe (2001):
## "The Statistical Evaluation Medical Tests for Classification and Prediction"
sampleSizePhase2BinaryTest(FPF0 = 0.2, TPF0 = 0.75, FPF1 = 0.05, TPF1 = 0.9,
alpha = 0.1, power = 0.9)
sampleSizePhase2BinaryTestSimulated(FPF0 = 0.2, TPF0 = 0.75, FPF1 = 0.05,
TPF1 = 0.9, alpha = 0.1, power = 0.9, M = 1000, range = 15, print = TRUE)
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.