Interval Estimation

–> Understanding Confidence Intervals

Introduction

Interval estimation is a statistical method used to estimate a range within which a population parameter is likely to fall. This range, known as a confidence interval, provides an indication of the reliability of the estimate. For example, a 95% confidence interval for a population mean suggests that there is a 95% probability that the true mean lies within this range. The interval is derived from sample data and reflects the data’s variability, offering a measure of the uncertainty surrounding the estimate.

Confidence Interval

A confidence interval is integral to interval estimation. It provides a range that likely includes a population parameter, with a specified confidence level (e.g., 95%) indicating the probability that the interval contains the true value. Thus, it expresses the uncertainty of statistical estimates.

Confidence Interval Formula

For a population mean, the CI is calculated as: \[ \bar{X} \pm Z \frac{\sigma}{\sqrt{n}} \] where: - \(\bar{X}\) is the sample mean - \(Z\) is the Z-value from the standard normal distribution - \(\sigma\) is the population standard deviation - \(n\) is the sample size

Example Calculation

Suppose we have a sample mean \(\bar{X} = 50\), a population standard deviation \(\sigma = 10\), and a sample size \(n = 25\). For a 95% confidence level, the Z-value is 1.96. The confidence interval is: \[ 50 \pm 1.96 \frac{10}{\sqrt{25}} \] \[ 50 \pm 3.92 \] \[ [46.08, 53.92] \]

Plotly Plot

## Loading required package: ggplot2
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
library(ggplot2)
ggplot(data, aes(x = factor(x), y = y)) +
  geom_point() +
  geom_errorbar(aes(ymin = ymin, ymax = ymax), width = 0.2) +
  ggtitle("Confidence Interval with ggplot2") +
  xlab("Sample") + ylab("Mean")

data <- data.frame(mean = 50, lower = 46.08, upper = 53.92)
ggplot(data, aes(y = mean)) +
  geom_point(aes(x = 1), size = 4) +
  geom_errorbar(aes(x = 1, ymin = lower, ymax = upper), width = 0.2) +
  ggtitle("Confidence Interval") +
  xlab("") + ylab("Mean") +
  theme_minimal()

mean <- 50
sd <- 10
n <- 25
z <- 1.96
lower <- mean - z * (sd / sqrt(n))
upper <- mean + z * (sd / sqrt(n))
c(lower, upper)
## [1] 46.08 53.92