norm2KV.2sided(sigma, prob, mu0, tau0, mu1, tau1, mu2, tau2)
dnorm
.
dnorm
.
dnorm
.
dnorm
.
dnorm
.
dnorm
.
norm2KV.2sided
returns a list of 5 functions:
logm0
), the log marginal density under the
alternative hypothesis (logm1
), the log marginal density
(logm
). Each are evaluated at the observed data provided. The
function takes the following usage:
logm(xbar, n, sigma, prob, mu0, tau0, mu1, tau1, mu2, tau2)
xbar
: Matrix with 2 columns. Each column represents the
sample mean for each of the two samples.n
: Scalar. The sample size.norm2KV.2sided
.
logbf(xbar, n, sigma, prob, mu0, tau0, mu1, tau1, mu2, tau2)For details on the arguments, see
logm
above.
prior(theta, prob, mu0, tau0, mu1, tau1, mu2, tau2)
theta
: Vector. The quantiles at which to evaluate the prior.norm2KV.2sided
.
post(theta, xbar, n, sigma, prob, mu0, tau0, mu1, tau1, mu2, tau2)
theta
: Vector. The quantiles at which to evaluate the
posterior.xbar
: Vector of length 2. Each element represents the sample
mean for each of the two samples, respectively.n
: Scalar. The sample size.norm2KV.2sided
.
ssd.norm2KV.2sided(alpha, w, sigma, prob, mu0, tau0, mu1, tau1, mu2, tau2, m = 2500, minn = 2, maxn = 1000, all = FALSE)See
ssd
for more details. The suite-specific parameters are
described above for norm2KV.2sided
.
norm2KV.2sided
is used to generate a suite of functions for a
two-sample normal experiment with a two-sided alternative hypothesis when the
variance is known and the samples are independent. That is, when
mu
and variance
tau^2
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 theta
, as well as constructing
the Bayes Factor and determining the sample size via an average error based
approach.
The arguments of norm2KV.2sided
are passed to each of the additional
functions upon their creation as default values. That is, if mu0
is
set to 1 in the call to norm2KVV.2sided
, each of the functions returned
will have the defaualt value of 1 for mu0
. If an argument is not
specified in the call to norm2KV.2sided
, then it remains a required
parameter in all functions created.
binom1.1sided
,binom1.2sided
,
binom2.1sided
,binom2.2sided
,
norm1KV.1sided
,norm1KV.2sided
,
norm1UV.2sided
,ssd
,BAEssd
############################################################
# Generate the suite of functions for a two-sample normal
# with a two-sided test. Consider the hypothesis
# H0: theta[1]==theta[2] vs. H1: theta[1]!=theta[2]
#
# with a known variance of 3.
# generate suite
f7 <- norm2KV.2sided(sigma=3,prob=0.5,mu0=0,tau0=1,mu1=2,tau1=1,mu2=2,tau2=1)
# attach suite
attach(f7)
# calculate the Bayes Factor for the following observed data
# n = 30, xbar[1] = -1, xbar[2] = 1
logbf(xbar=matrix(c(-1,1),nrow=1,ncol=2),n=30)
# perform sample size calculation with TE bound of 0.5 and weight 0.9
# - due to a need for a Monte Carlo implementation of this procedure, this
# problem can take significantly longer to solve, compared to other examples.
# Thus, for this example, a large error bound and weight were chosen to
# decrease computation time while illustrating the function.
ssd.norm2KV.2sided(alpha=0.5,w=0.9)
# detain suite
detach(f7)
Run the code above in your browser using DataLab