Calculates sample size or power for a paired-sample proportion test.
Arguments
- p01
Numeric. Proportion of discordant pairs with (before = 1, after = 0).
- p10
Numeric. Proportion of discordant pairs with (before = 0, after = 1).
- alpha
Numeric. Type I error rate.
- beta
Numeric (optional). Type II error rate. Required for sample size calculation.
- n
Integer (optional). Sample size. Required for power calculation.
- test_type
Character.
"2-side"
or"1-side"
. Default is"2-side"
.
Note
Only one of beta
(for sample size calculation) or n
(for power calculation) should be specified.
Required arguments:
For sample size:
p01
,p10
,alpha
,beta
For power:
p01
,p10
,alpha
,n
Examples
# Sample size for `"2-side"` test
pair_prop_size(p01 = 0.45, p10 = 0.05,
alpha = 0.1, beta = 0.1, test_type = "2-side")
#> [1] 23
# Power of `"2-side"` test
pair_prop_size(p01 = 0.45, p10 = 0.05,
alpha = 0.1, n = 23, test_type = "2-side")
#> [1] 0.9023805
# Sample size for `"1-side"` test
pair_prop_size(p01 = 0.45, p10 = 0.05,
alpha = 0.05, beta = 0.1, test_type = "1-side")
#> [1] 23
# Power of `"1-side"` test
pair_prop_size(p01 = 0.45, p10 = 0.05,
alpha = 0.05, n = 23, test_type = "1-side")
#> [1] 0.9023805