ci.mean: Compute the confidence interval of a mean

Description Usage Arguments Value Author(s) Examples

View source: R/ci.mean.R

Description

This function will compute the mean/confidence interval of a single variable, or compute the mean/CIs of levels within a factor based on an outcome variable

Usage

1
ci.mean(y, x = NULL, levels = NULL, interval = 0.95)

Arguments

y

The variable we wish to compute the mean of

x

The grouping variable (optional). If no grouping variable is specified, the function will estimate the mean of y only.

levels

The user can specify which levels of the factor they want to compute the means of. See examples.

interval

What interval is requested (expressed as a proportion). Defaults to .95.

Value

either a list containing the mean and CI, or a table containing the means/CIs for each level of x

Author(s)

Dustin Fife

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
iq = rnorm(100, 100, 15)
group = sample(c("iq.booster.pill", "control", "iq.training"), size=100, replace=T)
	### compute the mean of just iq
ci.mean(iq)
	### compute mean for all levels of x
ci.mean(iq, group)
	### compute mean for only the iq.booster.pill group
ci.mean(iq, group, levels="iq.booster.pill")
	### change to a 99% CI
ci.mean(iq, group, levels=c("control","iq.booster.pill"), interval=.99)

dustinfife/fifer documentation built on Oct. 31, 2020, 3:36 p.m.