precision: Sample size for given precision or precision for given sample...

Description Usage Arguments Details Value Author(s) Examples

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

1
precision(d, n, pars, method="sample size", alpha=0.05, minint=1, maxint=500) 

Arguments

d

The Confidence Interval width required (for use with method="sample size"). This can be a vector.

n

Sample size (for use with method="width"). This can be a vector.

pars

Standard deviation of the variable

method

Whether sample size is required ("sample size") or precision ("width").

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

1
2
3
4
5
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)

emon documentation built on May 2, 2019, 6:02 p.m.