nbinbf01 | R Documentation |
This function computes the required sample size to obtain a
binomial Bayes factor (binbf01) more extreme than a threshold
k
with a specified target power.
nbinbf01(
k,
power,
p0 = 0.5,
type = c("point", "direction"),
a = 1,
b = 1,
dp = NA,
da = a,
db = b,
dl = 0,
du = 1,
lower.tail = TRUE,
nrange = c(1, 10^4),
...
)
k |
Bayes factor threshold |
power |
Target power |
p0 |
Tested binomial proportion. Defaults to |
type |
Type of test. Can be |
a |
Number of successes parameter of the beta analysis prior
distribution. Defaults to |
b |
Number of failures parameter of the beta analysis prior
distribution. Defaults to |
dp |
Fixed binomial proportion assumed for the power calculation. Set to
|
da |
Number of successes parameter of the truncated beta design prior
distribution. Is only taken into account if |
db |
Number of failures parameter of the truncated beta design prior
distribution. Is only taken into account if |
dl |
Lower truncation limit of of the truncated beta design prior
distribution. Is only taken into account if |
du |
Upper truncation limit of of the truncated beta design prior
distribution. Is only taken into account if |
lower.tail |
Logical indicating whether Pr( |
nrange |
Sample size search range over which numerical search is
performed. Defaults to |
... |
Other arguments passed to |
The required sample size to achieve the specified power
Samuel Pawel
pbinbf01, binbf01
## sample size parameters
pow <- 0.9
p0 <- 3/4
a <- 1
b <- 1
k <- 1/10
## Not run:
## sample sizes for directional testing
(nH1 <- nbinbf01(k = k, power = pow, p0 = p0, type = "direction", a = a,
b = b, da = a, db = b, dl = p0, du = 1))
(nH0 <- nbinbf01(k = 1/k, power = pow, p0 = p0, type = "direction", a = a,
b = b, da = a, db = b, dl = 0, du = p0, lower.tail = FALSE))
nseq <- seq(1, 1.1*max(c(nH1, nH0)), length.out = 100)
powH1 <- pbinbf01(k = k, n = nseq, p0 = p0, type = "direction", a = a,
b = b, da = a, db = b, dl = p0, du = 1)
powH0 <- pbinbf01(k = 1/k, n = nseq, p0 = p0, type = "direction", a = a,
b = b, da = a, db = b, dl = 0, du = p0, lower.tail = FALSE)
matplot(nseq, cbind(powH1, powH0), type = "s", xlab = "n", ylab = "Power", lty = 1,
ylim = c(0, 1), col = c(2, 4), las = 1)
abline(h = pow, lty = 2)
abline(v = c(nH1, nH0), col = c(2, 4), lty = 2)
legend("topleft", legend = c("H1", "H0"), lty = 1, col = c(2, 4))
## sample sizes for point null testing
(nH1 <- nbinbf01(k = k, power = pow, p0 = p0, type = "point", a = a,
b = b, da = a, db = b))
(nH0 <- nbinbf01(k = 1/k, power = pow, p0 = p0, type = "point", a = a,
b = b, dp = p0, lower.tail = FALSE, nrange = c(1, 10^5)))
nseq <- seq(1, max(c(nH1, nH0)), length.out = 100)
powH1 <- pbinbf01(k = k, n = nseq, p0 = p0, type = "point", a = a,
b = b, da = a, db = b, dl = 0, du = 1)
powH0 <- pbinbf01(k = 1/k, n = nseq, p0 = p0, type = "point", a = a,
b = b, dp = p0, lower.tail = FALSE)
matplot(nseq, cbind(powH1, powH0), type = "s", xlab = "n", ylab = "Power", lty = 1,
ylim = c(0, 1), col = c(2, 4), las = 1)
abline(h = pow, lty = 2)
abline(v = c(nH1, nH0), col = c(2, 4), lty = 2)
legend("topleft", legend = c("H1", "H0"), lty = 1, col = c(2, 4))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.