| precision {emon} | R Documentation | 
Sample size for given precision or precision for given sample size
Description
Precision is measured by the width of a 100(1-alpha) The function generates the sample size needed to achieve this or the precision achieved for a specified sample size.
Usage
precision(d, n, pars, method="sample size", alpha=0.05, minint=1, maxint=500) 
Arguments
| d | The Confidence Interval width required (for use with  | 
| n | Sample size (for use with  | 
| pars | Standard deviation of the variable | 
| method | Whether sample size is required ( | 
| alpha | Defines the (1-alpha/2) percentage point of the t-dristribution used in the confidence interval. | 
| minint | Lower bound to be used in the search interval for the sample size. | 
| maxint | Upper bound to be used in the search interval for the sample size. | 
Details
The width of a Confidence Interval for the mean is given by the standard formula
d = 2 * sigma * t(1-alpha/2, n-1) / sqrt(n), where sigma is the standard deviation and
n is the sample
size. t(.) is the relevant quantile of the t distribution function.If sample size is required then
we can turn this equation round to get n = [2 * sigma * t(1-alpha/2, n-1)/d]^2. To solve this
equation for the sample size n, precision uses the function optimize.
Value
| n | Sample sizes. | 
| d | Confidence interval widths. | 
Author(s)
Jon Barry: Jon.Barry@cefas.co.uk
Examples
precision(d=c(1,1.2,1.5), pars=1, method="sample size", alpha=0.05)
precision(d=c(4), pars=1, method="sample size", alpha=0.05)
precision(n=c(20,25), pars=1, method="width", alpha=0.05)