Description Usage Arguments Details Value See Also Examples
View source: R/norm2KV.2sided.R
Generates the suite of functions related to the two sample normal experiment with a two-sided alternative hypothesis of interest when the variance is known.
1 | norm2KV.2sided(sigma, prob, mu0, tau0, mu1, tau1, mu2, tau2)
|
sigma |
Scalar. The known standard deviation of the population. |
prob |
Scalar. The prior probability of the null hypothesis. Must be a value between 0 and 1. |
mu0 |
Scalar. The mean of the normal prior density on theta under the null
hypothesis. See documentation for |
tau0 |
Scalar. The standard deviation of the normal prior density on theta under
the null hypothesis. See documentation for |
mu1 |
Scalar. The mean of the normal prior density on mean for sample 1 under the
alternative hypothesis. See documentation for |
tau1 |
Scalar. The standard deviation of the normal prior density on mean for
sample 1 under the alternative hypothesis. See documentation for
|
mu2 |
Scalar. The mean of the normal prior density on mean for sample 2 under the
alternative hypothesis. See documentation for |
tau2 |
Scalar. The standard deviation of the normal prior density on mean for
sample 2 under the alternative hypothesis. See documentation for
|
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
X[j] ~ Normal(theta[j],sigma2)
H0: theta[1] == theta[2] vs. H1: theta[1] != theta[2]
using the following prior on theta[1] and theta[2]
pi(theta) = u*I(theta[1]==theta[2])Normal(mu0,tau0^2) + (1-u)*I(theta[1]!=theta[2])Normal(mu1,tau1^2)Normal(mu2,tau2^2),
where Normal(mu,tau^2) is Normal density with mean 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.
norm2KV.2sided
returns a list of 5 functions:
logm |
Returns a list of three vectors: the log marginal density under
the null hypothesis ( logm(xbar, n, sigma, prob, mu0, tau0, mu1, tau1, mu2, tau2)
|
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(xbar, n, sigma, prob, mu0, tau0, mu1, tau1, mu2, tau2) For details on the arguments, see |
prior |
Returns a vector. The value of the prior density. The function takes the following usage: prior(theta, prob, mu0, tau0, mu1, tau1, mu2, tau2)
|
post |
Returns a vector. The value of the posterior density. The function takes the following usage: post(theta, xbar, n, sigma, prob, mu0, tau0, mu1, tau1, mu2, tau2)
|
ssd.norm2KV.2sided |
Sample size calculations for this particular set-up. The function has the following usage: ssd.norm2KV.2sided(alpha, w, sigma, prob, mu0, tau0, mu1, tau1, mu2, tau2, m = 2500, minn = 2, maxn = 1000, all = FALSE) See |
binom1.1sided
,binom1.2sided
,
binom2.1sided
,binom2.2sided
,
norm1KV.1sided
,norm1KV.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 25 26 | ############################################################
# 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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.