Description Usage Arguments Details Value Examples
bayes.binom.test estimates the relative frequency of success using 
Bayesian estimation and is intended as a replacement for 
binom.test.
| 1 2 | bayes.binom.test(x, n, comp.theta = 0.5, alternative = NULL,
  cred.mass = 0.95, n.iter = 15000, progress.bar = "none", p, conf.level)
 | 
| x | number of successes, or a vector of length 2 giving the numbers of successes and failures, respectively. | 
| n | number of trials; ignored if x has length 2. | 
| comp.theta | a fixed relative frequency of success to compare with the 
estimated relative frequency of success. This argument fills a similar role
as  | 
| alternative | ignored and is only retained in order to mantain 
compatibility with  | 
| cred.mass | the amount of probability mass that will be contained in 
reported credible intervals. This argument fills a similar role as 
 | 
| n.iter | The number of iterations to run the MCMC sampling. | 
| progress.bar | The type of progress bar. Possible values are "text", "gui", and "none". | 
| p | same as  | 
| conf.level | same as  | 
Given data on the number of successes and failures bayes.binom.test
estimates θ, the relative frequency of success, assuming the
following model:
x ~ Binomial(θ, n)
θ ~ Beta(1, 1)
Here the prior on θ is a non-informative Beta(1, 1) distribution which is identical to a Uniform(0, 1) distribution. By ploting and looking at a
summary of the object returned by bayes.binom.test you can get
more information about the shape of the posterior and the posterior
predictive distribution. model.code prints out the
corresponding R code underlying bayes.binom.test which can be
copy-n-pasted into an R script and modified, for example, changing the prior
on θ.
A list of class bayes_binom_test that contains information
about the analysis. It can be further inspected using the functions 
summary, plot, diagnostics and 
model.code.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | # A college dormitory recently sponsored a taste comparison between
# two major soft drinks. Of the 64 students who participated, 39 selected
# brand A, and only 25 selected brand B. Example from 
# http://www.elderlab.yorku.ca/~aaron/Stats2022/BinomialTest.htm
bayes.binom.test(x = 39, n = 64)
# Save the return value in order to inspect the model result further.
fit <- bayes.binom.test(x = 39, n = 64, cred.mass=0.8)
summary(fit)
plot(fit)
# MCMC diagnostics (should not be necessary for such a simple model)
diagnostics(fit)
# Print out the R code to run the model. This can be copy n' pasted into
# an R-script and further modified.
model.code(fit)
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.