- Why we test hypotheses
- The 5-step logic of a hypothesis test
- What a p-value really means
- PlantGrowth data example
- Visualizations with ggplot2 & Plotly
- R code example
- Interpreting our results and next steps
2025-06-10
Every dataset has noise. Hypothesis testing gives us a consistent rule to decide if an observed effect is real or just chance.
Null hypothesis (H₀): \[ H_0: \mu_{\text{ctrl}} = \mu_{\text{trt1}} \] Alternative hypothesis (Hₐ): \[ H_a: \mu_{\text{ctrl}} \neq \mu_{\text{trt1}} \]
For a two-sample t-test: \[ t = \frac{\bar{x}_1 - \bar{x}_2}{s_p \sqrt{\frac{1}{n_1} + \frac{1}{n_2}}}, \quad s_p = \sqrt{\frac{(n_1 - 1)s_1^2 + (n_2 - 1)s_2^2}{n_1 + n_2 - 2}}. \]
A p-value is the probability of obtaining a test statistic at least as extreme as the one observed, assuming the null hypothesis is true.
The data contains 10 plants in “ctrl” vs. 10 plants in “trt1”
Question: Does Treatment 1 change plant weight?
- H₀: μ(ctrl) = μ(trt1)
- Hₐ: μ(ctrl) ≠ μ(trt1)
The boxplot shows a small shift. But is it statistically significant?
The histograms show the spread of the data.
This interactive curve is our null distribution.
Here’s the R command to perform a Welch two-sample t-test (R’s default):
t.test(weight ~ group, data = pg2)