Description Usage Arguments Details Author(s) References Examples
View source: R/test_binomial.R
Determines the sample size, power, null proportion, alternative proportion, or significance level for a binomial test. The results also return the actual power and significance.
1 2 3 |
n |
The sample size, or number of trials |
p0 |
The value of the probability of a success under the null hypothesis |
p1 |
The value of the probability of a success under the alternative hypothesis |
power |
The power of the test |
alpha |
Significance level for the test |
alternative |
A character vector giving the alternative to the test.
Multiple values may be given, but the values must be |
conservative |
A logical vector. This determines if the sample
size selected is conservative (larger). This decision is required
because the power as a function of sample size is non-montonic in
the binomial distribution. In practice, it is usually better to look
at both and select the sample size where |
n_limits |
The limits of the search for when |
Exactly one of the parameters n
, p0
,
p1
, alpha
, and power
must be passed as NULL
. The only
exception is that delta
may be passed as a second NULL
when
mu0
and mu1
are specified.
The parameters are combined via expand.grid
, so all combinations
of the inputs are evaluated.
Benjamin Nutter
O'Brien R, Castelloe J, "Sample-Size Analysis in Study Planning," American Statistical Association Continuing Education Program: Section on Teaching Statistics in the Health Sciences, Joint Statistical Meetings, San Francisco, CA; 5 August 2003 (Short Course Manual)
Some design choices were obtained from the r-help question at: http://r.789695.n4.nabble.com/Sample-size-calculations-for-one-sided-binomial-exact-test-td3964313.html
1 2 3 4 5 6 7 8 9 10 | #* Julia Chill's Frozen Sensations Example from O'Brien and Castelloe
test_binomial(n=c(20, 40), p0=.5, p1=.8, alpha=c(.01, .05),
alternative='right.tailed')
#* Plot the sample size for a range of n
library(ggplot2)
Chill <- test_binomial(n=20:40, p0=.5, p1=.8, alpha=c(.01, .05),
alternative='right.tailed')
ggplot(Chill, aes(x=n, y=power, colour=factor(alpha))) + geom_line()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.