# proportionBF: Function for Bayesian analysis of proportions In BayesFactor: Computation of Bayes Factors for Common Designs

## Description

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

## Usage

 ```1 2``` ```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.

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

λ~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.

## 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 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.

## Author(s)

Richard D. Morey ([email protected])

`prop.test`

## Examples

 ```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"]) ```

### Example output ```Loading required package: coda
************
Welcome to BayesFactor 0.9.12-2. If you have questions, please contact Richard Morey (richarddmorey@gmail.com).

Type BFManual() to open the manual.
************
Bayes factor analysis
--------------
 Alt., p0=0.5, r=0.5 : 0.6598725 <U+00B1>0%

Against denominator:
Null, p = 0.5
---
Bayes factor type: BFproportion, logistic

Independent-candidate M-H acceptance rate: 90%
```

BayesFactor documentation built on May 19, 2018, 5:04 p.m.