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

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

`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 |

`callback` |
callback function for third-party interfaces |

`...` |
further arguments to be passed to or from methods. |

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

*λ~logistic(λ_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.

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 *p0*, 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.

Richard D. Morey (richarddmorey@gmail.com)

1 2 3 4 5 | ```
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"])
``` |

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.