Description Usage Arguments Details Value See Also Examples
bayes.prop.test
estimates the relative frequency of success for two or
more groups using Bayesian estimation and is intended as a replacement for
prop.test
.
1 2 3  bayes.prop.test(x, n, comp.theta = NULL, alternative = NULL,
cred.mass = 0.95, correct = NULL, n.iter = 15000,
progress.bar = "none", p, conf.level)

x 
a vector of counts of successes, a onedimensional table with two entries, or a twodimensional table (or matrix) with 2 columns, giving the counts of successes and failures, respectively. 
n 
a vector of counts of trials; ignored if x is a matrix or a table. 
comp.theta 
a vector of fixed relative frequencies of success to compare
with the estimated relative frequency of success. The length of

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

correct 
ignored and is only retained in order to mantain compatibility
with 
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.prop.test
estimates θ[1...m], the relative
frequencies of success for each of the m groups. The following model is
assumed for each group:
x ~ Binomial(θ, n)
θ ~ Beta(1, 1)
Here the prior on the θs is a noninformative Beta(1, 1) distribution which is identical to a Uniform(0, 1) distribution. By plot
ing and looking at a
summary
of the object returned by bayes.prop.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.prop.test
which can be copynpasted into an R script
and modified, for example, changing the prior on θ.
The print
and plot
function will only work well with a small
number of groups (2 to 6). If you have more groups you might want to run the
model with a small number of groups and then print the model code using
model.code
and fit the model using that code. The current model does
not assume any dependency between the groups, if this is an unreasonable assumption
you might want to modify the model code (from model.code
) to
include a dependency between the groups (see
here
for an example).
A list of class bayes_prop_test
that contains information about
the analysis. It can be further inspected using the functions
summary
, plot
, diagnostics
and
model.code
.
bayes.binom.test
for when you want to estimate the
relative frequency for only one group.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22  # Data from Muller, F. H., Tobakmissbrauch und Lungencarcinom,
# Zeit. f. Krebsforsch. 49, 5785, 1939. One of the early papers
# investigating the relation between smoking and lung cancer.
# Number of heavy smokers in one group of 86 lung cancer patients
# and one group of 86 healthy individuals.
no_heavy_smokers < c(56, 31)
no_cases < c(86, 86)
bayes.prop.test(no_heavy_smokers, no_cases)
# Save the return value in order to inspect the model result further.
fit < bayes.prop.test(no_heavy_smokers, no_cases)
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 Rscript and further modified.
model.code(fit)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.