bayesBinomTest: Bayesian two-sample test of proportions

Description Usage Arguments See Also Examples

Description

Bayesian two-sample test of proportions

Usage

1
2
3
bayesBinomTest(x, n, a1, b1, a2, b2, a = a1, b = b1, pi0 = 0.5,
  pi1 = 1 - pi0, c1 = 1, c2 = 1, c = c1/c2, rule = pi1/pi0 *
  c2/c1)

Arguments

x

two-vector containing successful trials

n

number of trials (the same for both samples)

a1

alpha, the hyperparameter of the beta distribution of the first proportion

b1

beta, the hyperparameter of the beta distribution of the first proportion

a2

alpha, the hyperparameter of the beta distribution of the second proportion

b2

beta, the hyperparameter of the beta distribution of the second proportion

a

alpha, the hyperparameter of the beta distribution under the null this is defaulted to a1 when not specified

b

beta, the hyperparameter of the beta distribution under the null this is defaulted to b1 when not specified

pi0

the prior probability of the null hypothesis

pi1

the prior probability of the alternative hypothesis

c1

loss associated with type I error

c2

loss associated with type II error

c

relative loss constant (loss due to type II error divided by loss due to type I error)

rule

the decision rule for the Bayes factor B. by default, test rejects when B < pi1/pi0 * c2/c1

See Also

samplePower, samplePowerEst, findSize, plotBinomRule

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
## Not run: 

a1 <- 3/5; b1 <- 7/5
a2 <- 7/5; b2 <- 3/5
plotBeta(c(a1, a2), c(b1, b2))
bayesBinomTest(c(12, 16), 20, a1, b1, a2, b2) # reject
bayesBinomTest(c(13, 16), 20, a1, b1, a2, b2) # fail to reject

# compare to :
prop.test(c(9, 16), c(20, 20)) # almost exact reject at 5% level
prop.test(c(10, 16), c(20, 20)) # fail to reject
prop.test(c(11, 16), c(20, 20)) # fail to reject


# but even slightly more informative priors can overpower results
# watch the proportions to see why
a1 <- 3; b1 <- 7
a2 <- 7; b2 <- 3
plotBeta(c(a1, a2), c(b1, b2))
bayesBinomTest(c(12, 16), 20, a1, b1, a2, b2) # reject
bayesBinomTest(c(13, 16), 20, a1, b1, a2, b2) # reject
bayesBinomTest(c(16, 16), 20, a1, b1, a2, b2) # reject (!)
bayesBinomTest(c(17, 16), 20, a1, b1, a2, b2) # reject (!)
bayesBinomTest(c(18, 16), 20, a1, b1, a2, b2) # fail to reject (!)



## End(Not run)

dkahle/bayesRates documentation built on May 15, 2019, 9:07 a.m.