two_prop_size {rashnu} | R Documentation |
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"
)
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 nA
/nB
(for power calculation) should be specified.
Required arguments by test_type
:
-
"2-side"
/"1-side"
: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 `"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")