b2p: Power for Comparing Two Binomials

View source: R/b2p.R

b2pR Documentation

Power for Comparing Two Binomials

Description

Calculates power (b2p) and sample size (b2n) for a two sample binomial test based on a normal approximation with and without continuity correction. b2p also computes the exact power of Fisher's exact test and the exact UMP unbiased test. Given combined sample size and response probability, b2diff calculates the difference corresponding to a specified power.

Usage

b2p(p1, p2, n1, n2, alpha = 0.025, exact = TRUE)

b2n(p1, p2, power = 0.8, r = 0.5, alpha = 0.025)

b2diff(p, r, n, alpha = 0.025, power = 0.8, exact = TRUE)

Arguments

p1

Success probability in group 1

p2

Success probability in group 2. Must be < p1.

n1

Number of subjects in group 1

n2

Number of subjects in group 2

alpha

One-sided significance level (type I error)

exact

If TRUE, power for the exact test is computed

power

The desired power of the test

r

Proportion in group 1

p

The overall (average) response probability in the two groups

n

The combined number of subjects in the two groups

Details

The power is computed for the one-sided test for the alternative that p1 > p2 against the null of equal rates. For a one-sided test in the opposite direction, reverse the definition of success and failure to map the problem to the alternative in this direction. The calculations are also valid for a two-sided test of size 2*alpha when the two-sided test is formed by combining the one-sided rejection regions of size alpha in each direction. This function does not give correct results for more general two-sided exact tests that divide the error asymmetrically between the two tails unless the correct one-sided error corresponding to the asymmetric test is used. The normal approximations are based on formulas from Fleiss (Statistical Methods for Rates and Proportions, 2nd ed, 1981).

b2diff is intended for facilitating power calculations when a new (binary) marker will be measured on an existing sample. Then the combined samples size n and overall response rate is known. r gives the expected proportion of the sample in group 1 (defined by the new marker). b2diff then calculates the response probabilities in the two groups that give a difference for which the two-sample comparison will have the specified power, subject to the overall response probability and sample size constraints. The probabilities are computed for the one-sided tests in each direction (higher response rates in group 1 and lower response rates in group 1)

The uniformly most powerful unbiased test uses a randomized rejection rule on the boundary of the critical region to give the exact type I error rate specified. This is generally not regarded as an appropriate procedure in practice.

Value

b2p returns a vector of length 4 giving the power based on the normal approximation with continuity correction (approx.cor), the normal approximation without correction (approx.unc), the exact power for Fisher's exact test (fisher), and the exact power for the uniformly most powerful unbiased test (UMPU), which uses a randomized rejection rule on the boundary of the critical region.

b2n returns a vector of length 2 giving the approximate sample size for the continuity corrected statistic (cont.cor) and the uncorrected (uncor) statistics.

b2diff returns a vector of length 6 giving the input values of p and r, the response probabilities in groups 1 and 2 corresponding to the difference with larger response in group 1, and the response probabilities in groups 1 and 2 corresponding to the difference with lower response in group 1.

References

Fleiss (1981). Statistical Methods for Rates and Proportions. 2nd ed.

See Also

pickwin

Examples

b2diff(0.3, 0.1, 400)
b2n(0.4, 0.2)
b2p(0.4, 0.2, 100, 100)


raredd/desmon documentation built on May 7, 2024, 3:46 p.m.