Calculates sample size or power for odds ratio test.
Usage
or_size(
  pA,
  pB,
  delta = NULL,
  kappa = 1,
  alpha,
  beta = NULL,
  nB = NULL,
  test_type = "equality"
)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.
"equality","non-inferiority", or"equivalence". Default is"2-side".
Note
Only one of beta (for sample size calculation) or nB (for power calculation) should be specified.
Required arguments by test_type:
"equality":For sample size:
pA,pB,alpha,betaFor power:
pA,pB,alpha,nB
"non-inferiority"/"equivalence":For sample size:
pA,pB,delta,alpha,betaFor power:
pA,pB,delta,alpha,nB
Examples
# Sample size for `"equality"` test
or_size(pA = 0.4, pB = 0.25, kappa = 1,
        alpha = 0.05, beta = 0.2, test_type = "equality")
#> [1] 156
# Power of `"equality"` test
or_size(pA = 0.4, pB = 0.25, kappa = 1,
        alpha = 0.05, nB = 156, test_type = "equality")
#> [1] 0.8020239
# Sample size for `"non-inferiority"` test
or_size(pA = 0.4, pB = 0.25, delta = 0.2, kappa = 1,
        alpha = 0.05, beta = 0.2, test_type = "non-inferiority")
#> [1] 242
# Power of `"non-inferiority"` test
or_size(pA = 0.4, pB = 0.25, delta = 0.2, kappa = 1,
        alpha = 0.05, nB = 242, test_type = "non-inferiority")
#> [1] 0.8007201
# Sample size for `"equivalence"` test
or_size(pA = 0.25, pB = 0.25, delta = 0.5, kappa = 1,
        alpha = 0.05, beta = 0.2, test_type = "equivalence")
#> [1] 366
# Power of `"equivalence"` test
or_size(pA = 0.25, pB = 0.25, delta = 0.5, kappa = 1,
        alpha = 0.05, nB = 366, test_type = "equivalence")
#> [1] 0.8008593