# norm1KV.1sided: Normal Suite: One Sample, One Sided, Known Variance In BAEssd: Bayesian Average Error approach to Sample Size Determination

## Description

Generates the suite of functions related to the one sample normal experiment with a one-sided alternative hypothesis of interest when the variance is known.

## Usage

 `1` ``` norm1KV.1sided(sigma, theta0, mu, tau) ```

## Arguments

 `sigma` Scalar. The known standard deviation of the population of interest. `theta0` Scalar. The critical value of the mean under the null hypothesis: theta<=theta0. `mu` Scalar. The mean of the normal prior density on theta. See documentation for `dnorm`. `tau` Scalar. The standard deviation for the normal prior density on theta. See documentation for `dnorm`.

## Details

`norm1KV.1sided` is used to generate a suite of functions for a one-sample normal experiment with a one-sided alternative hypothesis when the variance is known. That is, when

X ~ Normal(theta,sigma2)

H0: theta <= theta0 vs. H1: theta > theta0

using the following prior on theta

pi(theta) = Normal(mu,tau2),

where Normal(mu,tau2) is Normal density with mean `mu` and variance `tau2`.

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 `norm1KV.1sided` are passed to each of the additional functions upon their creation as default values. That is, if `mu` is set to 1 in the call to `norm1KV.1sided`, each of the functions returned will have the defaualt value of 1 for `mu`. If an argument is not specified in the call to `norm1KV.1sided`, then it remains a required parameter in all functions created.

## Value

`norm1KV.1sided` returns a list of 4 functions:

 `logm` Returns a list of three vectors: the log marginal density under the null hypothesis (`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, theta0, mu, tau)` `xbar`: Vector. Observed sample mean from the experiment. `n`: Scalar. Sample Size. Remaining parameters described above for `norm1KV.1sided`. `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, theta0, mu, tau)` See `logm` above for details on the parameters of the function. `prior` Returns a vector. The value of the prior density. The function has the following usage: `prior(theta, mu, tau)` `theta`: Vector. The quantiles at which to evaluate the prior. Remaining parameters described above for `norm1KV.1sided`. `post` Returns a vector. The value of the posterior density. The function has the following usage: `post(theta, xbar, n, sigma, mu, tau)` `theta`: Vector. The quantiles at which to evaluate the prior. `xbar`: Vector. Observed sample mean from the experiment. `n`: Scalar. Sample Size. Remaining parameters described above for `norm1KV.1sided`.

## See Also

`binom1.1sided`,`binom1.2sided`, `binom2.1sided`,`binom2.2sided`, `norm1KV.2sided`,`norm2KV.2sided` `norm1UV.2sided`,`ssd`,`BAEssd`

## 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 29 30``` ```############################################################ # Generate the suite of functions for a one-sample normal # with a one-sided test. Consider the hypothesis # H0: theta<=0 vs. H1: theta>0 # # with a normal prior for theta with prior mean 2 and # prior standard deviation 1. The known standard # deviation for the population is 5. # generate suite f5 <- norm1KV.1sided(sigma=5,theta0=0,mu=2,tau=1) # attach suite attach(f5) # plot the prior and posterior density when the observed data is # n = 30, xbar = 1. mus <- seq(-5,5,0.01) mu1 <- prior(mus) mu2 <- post(mus,xbar=1,n=30) plot(c(mu1,mu2)~rep(mus,2),type="n",ylab="Density",xlab="mu",main="") lines(mu1~mus,lty=1,lwd=2) lines(mu2~mus,lty=2,lwd=2) # perform sample size calculation with TE bound of 0.25 and weight 0.5 ssd.norm1KV(alpha=0.25,w=0.5,logm=logm) # detain suite detach(f5) ```

BAEssd documentation built on May 29, 2017, 4:12 p.m.