2025-11-16

Slide 1: Introduction to Hypothesis Testing

Hypothesis testing is a statistical framework used to make decisions about a population based on sample data.
We evaluate evidence by comparing observed results to what would happen under a certain assumption (the null hypothesis).

Slide 2: Key Concepts

  • Null hypothesis (H₀): default assumption
  • Alternative hypothesis (H₁): what we seek evidence for
  • Test statistic: summary of data used to evaluate hypotheses
  • p-value: probability of observing a result at least as extreme as the sample, assuming H₀ is true
  • Significance level (α): threshold for rejecting H₀

Slide 3: Hypothesis Test Example (One-Sample Mean)

We want to test whether the true mean weight of a product is 50 grams.

\[ H_0: \mu = 50 \] \[ H_1: \mu \neq 50 \]

Suppose we collect a sample of weights and compute the test statistic:

\[ t = \frac{\bar{x} - \mu_0}{s/\sqrt{n}} \]

If \(|t|\) is large, the sample mean is far from the hypothesized value \(\mu_0\).

Slide 4: ggplot Example — Sample Data Distribution

Slide 5: ggplot Example — Density Curve

Slide 6: 3D Plotly Example

Slide 7: Mathematical Details (Values)

xbar <- mean(sample_data)
s <- sd(sample_data)
n <- length(sample_data)
mu0 <- 50

t_statistic <- (xbar - mu0) / (s / sqrt(n))
t_statistic
## [1] 4.923414

Slide 8: Decision Rule (p-value Calculation)

p_value <- 2 * pt(abs(t_statistic), df = n - 1, lower.tail = FALSE)
p_value
## [1] 3.402336e-06

Slide 9: R Code for One-Sample t-Test

mu0 <- 50      # hypothesized population mean
t.test(sample_data, mu = mu0)
## 
##  One Sample t-test
## 
## data:  sample_data
## t = 4.9234, df = 99, p-value = 3.402e-06
## alternative hypothesis: true mean is not equal to 50
## 95 percent confidence interval:
##  50.79200 51.86133
## sample estimates:
## mean of x 
##  51.32666

Slide 10: Interpretation Helper Values

xbar
## [1] 51.32666
s
## [1] 2.694598
n
## [1] 100
p_value
## [1] 3.402336e-06