Returns the required sample size to obtain a given width of a confidence
interval for the sample mean. The function uses uniroot() to
find a numeric solution. The t distribution is used.
Usage
meanCIn(
ci,
sd,
interval = c(2, 100000),
conf.level = 0.95,
norm = FALSE,
tol = .Machine$double.eps^0.5
)Arguments
- ci
the left and right bound of the interval, which is presumed to be symmetric.
- sd
the standard deviation of the sample.
- interval
the interval for the sample size to be searched into, (default is c(2, 100000)).
- conf.level
confidence level, defaults to
0.95.- norm
logical, determining if the t- or normaldistribution should be used.
- tol
the desired accuracy (convergence tolerance).
Details
The required sample sizes for a specific width of confidence interval for the mean depends recursively on the sample size, as the sample size defines the degrees of freedom in the t-distribution. Although in most practical cases it will be sufficient to use the normal distribution, we might be interested in exact results.
See also
Other ci.location:
meanCI(),
meanDiffCI(),
medianCI(),
quantileCI(),
sumCI()
Examples
meanCIn(ci=c(25, 27), sd=5)
#> [1] 98.46626
