Description Usage Arguments Details Value See Also Examples
View source: R/binom2.2sided.R
Generates the suite of functions related to the two sample binomial experiment with a twosided alternative hypothesis of interest.
1  binom2.2sided(prob, a0, b0, a1, b1, a2, b2)

prob 
Scalar. The prior probability that the null hypothesis is true. Must be a value between 0 and 1. 
a0 
Scalar. Shape1 parameter for prior Beta distribution under the null
hypothesis that the two parameters are equal. See documentation for

b0 
Scalar. Shape2 parameter for prior Beta distribution under the null
hypothesis that the two parameters are equal. See documentation for

a1 
Scalar. Shape1 parameter for prior Beta distribution for the parameter
governing sample 1 under the alternative hypothesis. See documentation for

b1 
Scalar. Shape2 parameter for prior Beta distribution for the parameter
governing sample 1 under the alternative hypothesis. See documentation for

a2 
Scalar. Shape1 parameter for prior Beta distribution for the parameter
governing sample 2 under the alternative hypothesis. See documentation for

b2 
Scalar. Shape2 parameter for prior Beta distribution for the parameter
governing sample 2 under the alternative hypothesis. See documentation for

binom2.2sided
is used to generate a suite of functions for a twosample
binomial experiment with a twosided alternative hypothesis. That is, when
X[j]p[j] ~ Binomial(n,p[j]), independent
H0: p[1] == p[2] vs. H1: p[1] != p[2]
using the following prior on p[1] and p[2]
pi(p) = u*(p[1]==p[2])Beta(a0,b0) + (1u)*(p[1]!=p[2])Beta(a1,b1)Beta(a2,b2),
where Beta(a,b) is Beta density with parameters a
and b
and
u
is the prior probability of the null hypothesis (prob
).
The functions that are generated are useful in examining the prior and
posterior densities of the parameter p
, as well as constructing the
Bayes Factor and determining the sample size via an average error based
approach.
The arguments of binom2.2sided
are passed to each of the additional
functions upon their creation as default values. That is, if a0
is
set to 1 in the call to binom2.2sided
, each of the functions returned
will have the defaualt value of 1 for a0
. If an argument is not
specified in the call to binom2.2sided
, then it remains a required
parameter in all functions created.
binom2.2sided
returns a list of 4 functions:
logm 
Returns a list of three vectors: the log marginal density under
the null hypothesis ( logm(x, n, prob, a0, b0, a1, b1, a2, b2)

logbf 
Returns a vector. The value of the log Bayes Factor given the observed data provided and the prior parameters specified. The function has the following usage: logbf(x, n, prob, a0, b0, a1, b1, a2, b2) For details on the parameters, see 
prior 
Returns a vector. The value of the prior density. The function takes the following usage: prior(p, prob, a0, b0, a1, b1, a2, b2)

post 
Returns a vector. The value of the posterior density. The function takes the following usage: post(p, x, n, prob, a0, b0, a1, b1, a2, b2)

binom1.1sided
,binom1.2sided
,
binom2.1sided
,norm1KV.1sided
,
norm1KV.2sided
,norm2KV.2sided
norm1UV.2sided
,ssd
,BAEssd
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24  ############################################################
# Generate the suite of functions for a onesample binomial
# with a twosided test. Consider the hypothesis
# H0: p[1]==p[2] vs. H1: p[1]!=p[2]
#
# with a uniform prior on p under the null and a uniform
# prior on p[1] and p[2] under the alternative with a 0.5
# probability of the null hypothesis being true.
# generate suite
f4 < binom2.2sided(prob=0.5,a0=1,b0=1,a1=1,b1=1,a2=1,b2=1)
# attach suite
attach(f4)
# calculate the Bayes factor when the observed data are
# n = 30, x[1] = 10, x[2] = 20
logbf(x=matrix(c(10,20),ncol=2,nrow=1),n=30)
# perform sample size calculation with TE bound of 0.25 and weight 0.5
ssd.binom(alpha=0.25,w=0.5,logm=logm,two.sample=TRUE)
# detain suite
detach(f4)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.