2025-04-14

Introduction to Hypothesis Testing

Hypothesis testing is a statistical method for making decisions about a population based on sample data.

\[ H_0: \mu_D = \mu_A \\ H_A: \mu_D \neq \mu_A \]

Steps in Hypothesis Testing

  1. Set up null and alternative hypotheses
  2. Choose significance level \(\alpha\)
  3. Calculate test statistic
  4. Determine p-value or critical region
  5. Make a decision: reject or fail to reject \(H_0\)

Real-World Problem

We compare average ratings between Drama and Action movies using data from the ggplot2movies package.

  • Sample 1: Drama movies
  • Sample 2: Action movies
  • Test: Two-sample t-test (Welch’s t-test) ## R Code to Perform t-test
## 
##  Welch Two Sample t-test
## 
## data:  drama_ratings and action_ratings
## t = 34.902, df = 6346.6, p-value < 2.2e-16
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  0.8132646 0.9100589
## sample estimates:
## mean of x mean of y 
##  6.153684  5.292022

ggplot: Distribution Comparison

ggplot: Boxplot Comparison

Plotly 3D Surface (Dummy Example)

Conclusion & Interpretation

  • t-test result: 34.9
  • p-value: 0
  • If \(p < 0.05\), we reject \(H_0\) and conclude that the mean ratings differ.

Hypothesis testing helps us make data-driven comparisons between groups.