Learn R Programming

rashnu (version 0.1.2)

two_prop_size: Sample Size or Power for Two-Sample Proportion Test

Description

Calculates sample size or power for a two-sample proportion test.

Usage

two_prop_size(
  pA,
  pB,
  delta = NULL,
  kappa = 1,
  alpha,
  beta = NULL,
  nB = NULL,
  test_type = "2-side"
)

Value

Numeric. Returns sample size (if beta is given), or power (if nB is given).

Arguments

pA

Numeric. True proportion of group A.

pB

Numeric. True proportion of group B.

delta

Numeric (optional). Margin for "non-inferiority" or "equivalence" test. Required for "non-inferiority" or "equivalence" test.

kappa

Numeric. Ratio of sample sizes (nA/nB). Default is 1.

alpha

Numeric. Type I error rate.

beta

Numeric (optional). Type II error rate. Required for sample size calculation.

nB

Integer (optional). Sample size for group B. Required for power calculation.

test_type

Character. "2-side", "1-side", "non-inferiority", or "equivalence". Default is "2-side".

Examples

Run this code
# Sample size for `"2-side"` test
two_prop_size(pA = 0.65, pB = 0.85, kappa = 1,
              alpha = 0.05, beta = 0.2, test_type = "2-side")

# Power of `"2-side"` test
two_prop_size(pA = 0.65, pB = 0.85, kappa = 1,
              alpha = 0.05, nB = 70, test_type = "2-side")

# Sample size for `"1-side"` test
two_prop_size(pA = 0.65, pB = 0.85, kappa = 1,
              alpha = 0.05, beta = 0.2, test_type = "1-side")

# Power of `"1-sided"` test
two_prop_size(pA = 0.65, pB = 0.85, kappa = 1,
              alpha = 0.05, nB = 55, test_type = "1-side")

# Sample size for `"non-inferiority"` test
two_prop_size(pA = 0.85, pB = 0.65, delta = -0.1, kappa = 1,
              alpha = 0.05, beta = 0.2, test_type = "non-inferiority")

# Power of `"non-inferiority"` test
two_prop_size(pA = 0.85, pB = 0.65, delta = -0.1, kappa = 1,
              alpha = 0.05, nB = 25, test_type = "non-inferiority")

# Sample size for `"equivalence"` test
two_prop_size(pA = 0.65, pB = 0.85, delta = 0.05, kappa = 1,
              alpha = 0.05, beta = 0.2, test_type = "equivalence")

# Power of `"equivalence"` test
two_prop_size(pA = 0.65, pB = 0.85, delta = 0.05, kappa = 1,
              alpha = 0.05, nB = 136, test_type = "equivalence")

Run the code above in your browser using DataLab