BayesFactor (version 0.9.12-4.2)

proportionBF: Function for Bayesian analysis of proportions

Description

Bayes factors or posterior samples for binomial, geometric, or neg. binomial data.

Usage

proportionBF(y, N, p, rscale = "medium", nullInterval = NULL,
  posterior = FALSE, callback = function(...) as.integer(0), ...)

Arguments

y

a vector of successes

N

a vector of total number of observations

p

the null value for the probability of a success to be tested against

rscale

prior scale. A number of preset values can be given as strings; see Details.

nullInterval

optional vector of length 2 containing lower and upper bounds of an interval hypothesis to test, in probability units

posterior

if TRUE, return samples from the posterior instead of Bayes factor

callback

callback function for third-party interfaces

...

further arguments to be passed to or from methods.

Value

If posterior is FALSE, an object of class BFBayesFactor containing the computed model comparisons is returned. If nullInterval is defined, then two Bayes factors will be computed: The Bayes factor for the interval against the null hypothesis that the probability is \(p_0\), and the corresponding Bayes factor for the compliment of the interval.

If posterior is TRUE, an object of class BFmcmc, containing MCMC samples from the posterior is returned.

Details

Given count data modeled as a binomial, geometric, or negative binomial random variable, the Bayes factor provided by proportionBF tests the null hypothesis that the probability of a success is \(p_0\) (argument p). Specifically, the Bayes factor compares two hypotheses: that the probability is \(p_0\), or probability is not \(p_0\). Currently, the default alternative is that $$\lambda~logistic(\lambda_0,r)$$ where \(\lambda_0=logit(p_0)\) and \(\lambda=logit(p)\). \(r\) serves as a prior scale parameter.

For the rscale argument, several named values are recognized: "medium", "wide", and "ultrawide". These correspond to \(r\) scale values of \(1/2\), \(\sqrt{2}/2\), and 1, respectively.

The Bayes factor is computed via Gaussian quadrature, and posterior samples are drawn via independence Metropolis-Hastings.

See Also

prop.test

Examples

Run this code
# NOT RUN {
bf = proportionBF(y = 15, N = 25, p = .5)
bf
## Sample from the corresponding posterior distribution
samples =proportionBF(y = 15, N = 25, p = .5, posterior = TRUE, iterations = 10000)
plot(samples[,"p"])
# }

Run the code above in your browser using DataCamp Workspace