mean_CI: Construct the Confidence Interval for the Mean

View source: R/mean_CI.R

mean_CIR Documentation

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

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

Value

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

Examples

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

biostats101 documentation built on Sept. 13, 2024, 1:11 a.m.