2025-10-18

What is a Confidence Interval?

A confidence interval is a range of possible values for an unknown population parameter.

  • Instead of a single point estimate, we get an interval
  • We are “X% confident” that the interval contains the true population value
  • Confidence levels EX: 90%, 95%, 99%

Example: “We are 95% confident that the true mean weight is between 7 grams and 9 grams”

Mathematical Definition

For a population mean \(\mu\) with known standard deviation \(\sigma\):

\[\bar{X} \pm z_{\alpha/2} \cdot \frac{\sigma}{\sqrt{n}}\]

Where:

  • \(\bar{X}\) = sample mean
  • \(z_{\alpha/2}\) = critical value from standard normal distribution
  • \(\sigma\) = population standard deviation
  • \(n\) = sample size

What Does It All Mean?

What does 95% confidence mean?

If we repeated our sampling process many times and constructed a 95% CI each time:

\[P(\bar{X} - 1.96\frac{\sigma}{\sqrt{n}} \leq \mu \leq \bar{X} + 1.96\frac{\sigma}{\sqrt{n}}) = 0.95\]

  • 95% of the intervals would contain the true parameter!
  • Any single interval either contains the parameter or doesn’t.

Example: Student Studying Hours

Let’s estimate average number of hours of studying for college students.

Calculating a 95% Confidence Interval

R Code: How to Calculate Confidence Intervals

studyHours <- rnorm(50, mean = 7.2, sd = 1.3)

n <- length(studyHours)
sampleMean <- mean(studyHours)
sampleSd <- sd(studyHours)
standard_error <- sampleSd / sqrt(n)

ciLower <- sampleMean - 1.96 * standard_error
ciUpper <- sampleMean + 1.96 * standard_error

 #or use t tests
t.test(studyHours, conf.level = 0.95)$conf.int

Simulation: How Confidence Intervals Capture the True Mean

3D Plot: Confidence Intervals & How Sample Sizes Affects the Outcome

Key Takeaways

Three factors affect Confidence Interval width:

  1. Sample size: (\(n\)): Larger \(n\) → Smaller Interval
  2. Confidence level: Higher confidence → Wider Interval
    • 90% Confidence is slimmer than 95% Confidence
    • 99% Confidence is wider than 95% Confidence
  3. Population variability: (\(\sigma\)): More variability → Wider Confidence Interval

So you need to decide between Precision or Confidence.

Summary from Study Example

Statistic Value
Sample Size 50.000
Sample Mean 6.831
Sample SD 1.204
Standard Error 0.253
95% CI Lower 6.911
95% CI Upper 7.578
CI Width 0.667

We are 95% confident that the true average studying hours for college students is between 6.91 and 7.58 hours.