2026-04-12

What is Hypothesis Testing?

Hypothesis Testing is a method within statistics, which uses data to determine whether or not it supports a particular theory over default assumption. The key factor in hypothesis testing is to make informed, data based decisions without biases or false conclusions. This is commonly used in science and medicine, as it answers the question of whether something is based on chance or based on fact.

The Steps of Hypothesis Testing.

Often, the hypotheses are split into to: the null hypothesis (H_0) or the or the alternative hypothesis (H1 or Ha). The null hypothesis tells us that there is nothing new to be discovered or no difference, while the alternative hypothesis shows us that there is an effect or difference.

There are three main steps to hypothesis testing such as formulating an analysis plan, collecting and analyzing data to calculate test statistics and p-value, and finally come to conclusion or make a decision.

To demonstrate, we can think of a scenario, such as doctors testing a blood pressure drug to see if the effects actually lower blood pressure. Here, we are comparing patients who take the drug and what we would expect with no effects.

Hypotheses (Math)

Null hypothesis: \[ H_0: \mu = 0 \]

Alternative hypothesis: \[ H_a: \mu < 0 \]

  • \(\mu\) = average change in blood pressure
  • 0 = no change

Test Idea

If the drug works: Blood pressure should decrease

If it doesn’t: Changes are just random variation

We use a statistical test to check this.

What is a p-value?

The p-value tells us the probability/how surprising the results are with the assumption of a null hypothesis. Here, our basis would be assuming the drug has no effect.

Rule:

p < 0.05 → evidence the drug works
p ≥ 0.05 → not enough evidence

Example Data

In a study:

50 patients take the drug
Average change = −5 mmHg
Some patients improve more than others

This suggests blood pressure might be decreasing.

ggplot: Distribution of Changes

Plotly Interactive Plot

p-value Calculation

## [1] 0.02275013

Hypothetical Conclusion:

  • The data was analyzed through a null hypothesis
  • We can see how result falls in the extreme left tail of the distribution
  • The p-value (~0.0228) is below the 0.05 significance level
  • We reject the null hypothesis in favor of the alternative so our conclusion here is statistically significant evidence that the drug lowers blood pressure

R Code Used Example

library(ggplot2)

# Create data for distribution
x <- seq(-10, 10, length.out = 100)
y <- dnorm(x, mean = 0, sd = 3)
df <- data.frame(x, y)