Learn R Programming

lsr (version 0.1.1)

ciMean: Confidence interval around the mean

Description

Calculates confidence intervals for the mean of a normally-distributed variable.

Usage

ciMean(x, conf = 0.95, na.rm = FALSE)

Arguments

x
A numeric vector containing the observations.
conf
The level of confidence desired. Defaults to a 95% confidence interval
na.rm
Logical value indicating whether missing values are to be removed. Defaults to FALSE.

Value

  • The output is a numeric vector containing the lower and upper ends of the confidence interval.

Details

This function calculates the confidence interval for the mean of a variable, under the standard assumption that the data are normally distributed. By default it returns a 95% confidence interval (conf = 0.95) and does not remove missing values (na.rm = FALSE).

See Also

confint

Examples

Run this code
X <- c(1, 3, 6)          # data 
ciMean(X)                # 95 percent confidence interval
ciMean(X, conf = .8)     # 80 percent confidence interval

confint( lm(X ~ 1) )     # for comparison purposes

X <- c(1, 3, NA, 6)      # data with missing values
ciMean(X, na.rm = TRUE)  # remove missing values

Run the code above in your browser using DataLab