Description Usage Arguments Details Value See Also Examples
View source: R/binom2.1sided.R
Generates the suite of functions related to the two sample binomial experiment with a one-sided alternative hypothesis of interest.
1 | binom2.1sided(a1, b1, a2, b2)
|
a1 |
Scalar. Shape1 parameter for prior Beta distribution for the parameter
governing sample 1. See documentation for |
b1 |
Scalar. Shape2 parameter for prior Beta distribution for the parameter
governing sample 1. See documentation for |
a2 |
Scalar. Shape1 parameter for prior Beta distribution for the parameter
governing sample 2. See documentation for |
b2 |
Scalar. Shape2 parameter for prior Beta distribution for the parameter
governing sample 2. See documentation for |
binom2.1sided
is used to generate a suite of functions for a two-sample
binomial experiment with a one-sided 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) = Beta(a1,b1)Beta(a2,b2),
where Beta(a,b) is Beta density with parameters a
and b
.
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.1sided
are passed to each of the additional
functions upon their creation as default values. That is, if a1
is
set to 1 in the call to binom2.1sided
, each of the functions returned
will have the defaualt value of 1 for a1
. If an argument is not
specified in the call to binom2.1sided
, then it remains a required
parameter in all functions created.
binom2.1sided
returns a list of 4 functions:
logm |
Returns a list of three vectors: the log marginal density under
the null hypothesis ( logm(x, n, 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, 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, a1, b1, a2, b2)
|
post |
Returns a vector. The value of the posterior density. The function takes the following usage: post(p, x, n, a1, b1, a2, b2)
|
binom1.1sided
,binom1.2sided
,
binom2.2sided
,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 | ############################################################
# Generate the suite of functions for a one-sample binomial
# with a two-sided test. Consider the hypothesis
# H0: p[1]<=p[2] vs. H1: p[1]>p[2]
#
# with a uniform prior on p[1] and a uniform prior on p[2].
# generate suite
f3 <- binom2.1sided(a1=1,b1=1,a2=1,b2=1)
# attach suite
attach(f3)
# 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(f3)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.