# mudiff.modwoc: Bayesian sample size determination for differences in normal... In SampleSizeMeans: Sample size calculations for normal means

## Description

The function `mudiff.modwoc` calculates conservative sample sizes, in the sense that the desired posterior credible interval coverage and length for the difference between two normal means are guaranteed over a given proportion of data sets that can arise according to the prior information.

## Usage

 `1` ```mudiff.modwoc(len, alpha1, beta1, alpha2, beta2, n01, n02, level = 0.95, worst.level = 0.95, equal = TRUE, m = 50000, mcs = 3) ```

## Arguments

`len`

The desired total length of the posterior credible interval for the difference between the two unknown means

`alpha1`

First prior parameter of the Gamma density for the precision (reciprocal of the variance) for the first population

`beta1`

Second prior parameter of the Gamma density for the precision (reciprocal of the variance) for the first population

`alpha2`

First prior parameter of the Gamma density for the precision (reciprocal of the variance) for the second population

`beta2`

Second prior parameter of the Gamma density for the precision (reciprocal of the variance) for the second population

`n01`

Prior sample size equivalent for the mean for the first population

`n02`

Prior sample size equivalent for the mean for the second population

`level`

The desired fixed coverage probability of the posterior credible interval (e.g., 0.95)

`worst.level`

The probability that the length of the posterior credible interval of fixed coverage probability level will be at most len

`equal`

logical. Whether or not the final group sizes (n1, n2) are forced to be equal:

 when equal = TRUE, final sample sizes n1 = n2; when equal = FALSE, final sample sizes (n1, n2) minimize the expected posterior variance given a total of n1+n2 observations
`m`

The number of points simulated from the preposterior distribution of the data. For each point, the length of the highest posterior density interval of fixed coverage probability level is estimated, in order to approximate the (100*worst.level)%-percentile of the posterior credible interval length. Usually 50000 is sufficient, but one can increase this number at the expense of program running time.

`mcs`

The Maximum number of Consecutive Steps allowed in the same direction in the march towards the optimal sample size, before the result for the next upper/lower bound is cross-checked. In our experience, mcs = 3 is a good choice.

## Details

Assume that a sample from each of two populations will be collected in order to estimate the difference between two independent normal means. Assume that the precision within each of the two the populations are unknown, but have prior information in the form of Gamma(alpha1, beta1) and Gamma(alpha2, beta2) densities, respectively. Assume that the means are unknown, but have prior information equivalent to (n01, n02) previous observations, respectively. The function `mudiff.modwoc` returns the required sample sizes to attain the desired length len for the posterior credible interval of fixed coverage probability level for the difference between the two unknown unknown means. The Modified Worst Outcome Criterion used is conservative, in the sense that the posterior credible interval length len is guaranteed over the worst.level proportion of all possible data sets that can arise according to the prior information, for a fixed coverage probability level.

This function uses a fully Bayesian approach to sample size determination. Therefore, the desired coverages and lengths are only realized if the prior distributions input to the function are used for final inferences. Researchers preferring to use the data only for final inferences are encouraged to use the Mixed Bayesian/Likelihood version of the function.

## Value

The required sample sizes (n1, n2) for each group given the inputs to the function.

## Note

The sample sizes are calculated via Monte Carlo simulations, and therefore may vary from one call to the next.

It is also correct to state that the coverage probability of the posterior credible interval of fixed length len will be at least level with probability worst.level with the sample sizes returned.

## Author(s)

Lawrence Joseph [email protected] and Patrick Belisle

## References

Joseph L, Belisle P.
Bayesian sample size determination for Normal means and differences between Normal means
The Statistician 1997;46(2):209-226.

`mudiff.acc`, `mudiff.alc`, `mudiff.acc.equalvar`, `mudiff.alc.equalvar`, `mudiff.modwoc.equalvar`, `mudiff.varknown`, `mudiff.mblacc`, `mudiff.mblalc`, `mudiff.mblmodwoc`, `mudiff.mblacc.equalvar`, `mudiff.mblalc.equalvar`, `mudiff.mblmodwoc.equalvar`, `mudiff.mbl.varknown`, `mudiff.freq`, `mu.acc`, `mu.alc`, `mu.modwoc`, `mu.varknown`, `mu.mblacc`, `mu.mblalc`, `mu.mblmodwoc`, `mu.mbl.varknown`, `mu.freq`
 `1` ```mudiff.modwoc(len=0.2, alpha1=2, beta1=2, alpha2=3, beta2=3, n01=10, n02=50) ```