For some reason I'm able to specify alternative = 'greater' but not alternative = 'less' in pwr.2p.test(), although it seems to me like both options should be valid and return the same result. Perhaps this is a bug, or perhaps this is just a design decision that could be documented in the function documentation?
library(pwr)
# Works
pwr.2p.test(
h = 0.1,
n = NULL,
sig.level = 0.04,
power = 0.55,
alternative = 'greater'
)
#>
#> Difference of proportion power calculation for binomial distribution (arcsine transformation)
#>
#> h = 0.1
#> n = 704.1359
#> sig.level = 0.04
#> power = 0.55
#> alternative = greater
#>
#> NOTE: same sample sizes
# Fails
pwr.2p.test(
h = 0.1,
n = NULL,
sig.level = 0.04,
power = 0.55,
alternative = 'less'
)
#> Error in uniroot(function(n) eval(p.body) - power, c(2 + 1e-10, 1e+09)): f() values at end points not of opposite sign
Created on 2020-08-03 by the reprex package (v0.3.0)