Learn R Programming

biostats101 (version 0.1.1)

mean_CI: Construct the Confidence Interval for the Mean

Description

Constructs a confidence interval (CI) for the mean of a numeric vector using the Student's t-distribution. The CI is calculated based on the specified degrees of freedom, confidence level, and alternative hypothesis.

Usage

mean_CI(data, conf.level = 0.95, alternative = "two.sided")

Value

A named numeric vector with the mean and the lower and upper bounds of the confidence interval.

Arguments

data

A numeric vector from which the mean and confidence interval will be calculated.

conf.level

A numeric value representing the confidence level for the confidence interval estimation. Default is 0.95.

alternative

The alternative hypothesis to be considered on the confidence interval estimation. Options are 'two.sided' (default), 'greater', or 'less'.

Examples

Run this code
# Example data
values = c(5.2, 4.8, 6.3, 6.1, 7.2, 3.5, 4.9, 2.2, 3.7, 3.5, 8.9)

# Construct a 95% confidence interval for the mean
mean_CI(values)

Run the code above in your browser using DataLab