prec_mean: Sample size or precision for a mean

Description Usage Arguments Details Value Examples

View source: R/descriptive_stats.R

Description

prec_mean returns the sample size or the precision for the provided mean and standard deviation.

Usage

1
prec_mean(mu, sd, n = NULL, conf.width = NULL, conf.level = 0.95, ...)

Arguments

mu

mean.

sd

standard deviation.

n

number of observations.

conf.width

precision (the full width of the confidence interval).

conf.level

confidence level.

...

other arguments to uniroot (e.g. tol).

Details

Exactly one of the parameters n or conf.width must be passed as NULL, and that parameter is determined from the other.

The precision is defined as the full width of the confidence interval. The confidence interval calculated as t(n - 1) * sd / sqrt(n), with t(n-1) from the t-distribution with n-1 degrees of freedom.

uniroot is used to solve n.

Value

Object of class "presize", a list with mu mean, sd standard deviation, n sample size, conf.width precision (the width of the confidence interval), lwr lower bound of confidence interval, upr upper bound of confidence interval, augmented with method and note elements.

Examples

1
2
3
4
# mean of 5, SD of 2.5, whats the confidence interval width with 20 participants?
prec_mean(mu = 5, sd = 2.5, n = 20)
# mean of 5, SD of 2.5, how many participants for CI width of 2.34?
prec_mean(mu = 5, sd = 2.5, conf.width = 2.34)  # approximately the inverse of above

presize documentation built on April 9, 2021, 1:05 a.m.