BayesPropTest

Created: 2014-05-18 23:34
Updated: 2014-05-19 00:12
r

README.md

BayesPropTest

simple Bayesian version of R's prop.test

Bayesian Test of the Difference Between Proportions

description

Provides a simple way to perform a Bayesian version of prop.test using the beta distribution.

The default prior distributional parameters are a = 1 and b = 1. The prior can be adjusted if you have reasonable information to work with. If you set a < b, the density will be weighted toward the lower half of the distribution, and setting a > b would weight it toward the upper half. If a = 0.5, much more weight is given to values near 0, while if b = 0.5, weight is stacked up near 1. Examples of different shapes of the beta distribution based on different parameter values can be seen at Rocscience.

A histogram is produced of the posterior distribution, with a red reference line marking "no difference."

usage

bayes.prop.test(n1, d1, n2, d2, a=1, b=1, rep=10000)

arguments

n1 The numerator of the first group. Required.

d1 The denominator of the first group. Required. The proportion n1/d1 should be greater than or equal to n2/d2.

d2 The denominator of the second group. Required. The proportion n2/d2 should be less than or equal to n1/d1.

a Alpha prior parameter. Defaults to 1.

b Beta prior parameter. Defaults to 1.

rep Number of replications for the rbeta function. Defaults to 10,000.

examples

bayes.prop.test(n1=50, d1=100, n2=20, d2=50)

# difference p-hat 2.5% 97.5% prob.diff>0
# 0.10000000 0.09695006 -0.07072376 0.25873452 0.87380000

author

@Rmadillo

Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more