or_size {rashnu} | R Documentation |
Sample Size or Power for Odds Ratio Test
Description
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 |
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. |
Value
Numeric. Returns sample size (if beta
is given), or power (if nB
is given).
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
,beta
For power:
pA
,pB
,alpha
,nB
-
"non-inferiority"
/"equivalence"
:For sample size:
pA
,pB
,delta
,alpha
,beta
For 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")
# Power of `"equality"` test
or_size(pA = 0.4, pB = 0.25, kappa = 1,
alpha = 0.05, nB = 156, test_type = "equality")
# 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")
# 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")
# 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")
# 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")