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
2
prec_mean(mu, sd, n = NULL, conf.width = NULL, conf.level = 0.95,
  tol = .Machine$double.eps^0.25)

Arguments

mu

mean

sd

standard deviation

n

number of observations

conf.width

precision (the full width of the conficende interval)

conf.level

confidence level

tol

numerical tolerance used in root finding, the default providing (at least) four significant digits

Details

Exactly one of the parameters n, 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 conficence 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 conficence interval)

lwr

lower end of confidence interval

upr

higher end of confidence interval

augmented with method and note elements.

Examples

1
2
prec_mean(mu = 5, sd = 2.5, n = 20)
prec_mean(mu = 5, sd = 2.5, conf.width = 2.34)  # approximately the inverse of above

a-lenz/presize documentation built on May 17, 2019, 7:44 a.m.