11.3 Case Study: Students heights

Suppose we want to test if the average height of a sample of students is different from the population average height (which is 165 cm).

11.3.1 Hypotheses

  • H0: The average height of students is 165 cm.
  • Ha: The average height of students is not equal to 165 cm.

\[\left\{\begin{matrix} H_0 & \mu=165cm \\ H_a & \mu \neq 165cm \end{matrix}\right.\]

11.3.2 Sample data (heights of students)

heights <- c(160, 168, 162, 170, 155, 175, 158, 172, 166, 180)

11.3.3 Choose a Significance Level (α)

The significance level (α) is the threshold you set to determine what constitutes strong enough evidence to reject the null hypothesis. Common values for α are 0.05 or 0.01.

Significance level

alpha <- 0.05

11.3.4 Perform the Hypothesis Test

You can use statistical tests appropriate for your data type and research question. In this example, you can use a t-test to compare the sample mean to the population mean.

Perform t-test

t_test <- t.test(heights, mu = 165)

11.3.5 Make a Decision

  • If the p-value (probability value) obtained from the test is less than α (p < α), you reject the null hypothesis. This means you have evidence to support the alternative hypothesis.

  • If p-value ≥ α, you fail to reject the null hypothesis. This means you don’t have enough evidence to support the alternative hypothesis.

Get the p-value from the test

p_value <- t_test$p.value

# Make a decision
if (p_value < alpha) {
  cat("Reject H0: There is enough evidence to suggest that the average height is different from 165 cm.\n")
} else {
  cat("Fail to reject H0: There is not enough evidence to suggest that the average height is different from 165 cm.\n")
}
## Fail to reject H0: There is not enough evidence to suggest that the average height is different from 165 cm.