# Compute sample size for a Phase 2 study of a binary test

### Description

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.

### Usage

1 2 3 4 5 |

### Arguments

`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. |

### Value

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. |

### Author(s)

Kaspar Rufibach

kaspar.rufibach@gmail.com

### References

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

### See Also

The function `sampleSizePhase2BinaryTestSimulated`

depends on `sampleSizePhase2BinaryTest`

, `wilson`

, and clopperPearson.

### Examples

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)
``` |