prec_mean: Sample size or precision for a mean

View source: R/descriptive_stats.R

prec_meanR Documentation

Sample size or precision for a mean

Description

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

Usage

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

Arguments

mean

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).

mu

deprecated argument

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.

This function is also suitable for a difference in paired means, as this reduces to a single value per individual - the difference.

uniroot is used to solve n.

Value

Object of class "presize", a list with mean 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

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

presize documentation built on March 7, 2023, 8:28 p.m.