2025-10-19

Understanding Significance Testing

Using the mtcars Dataset

Conducting a significance test can allow us to understand if changes between results or data are actually worth noting or significant or if they are present due to chance.

Why Significance Testing?

  • Data can vary so not every change is meant to be significant
  • Significance testing is meant to be used to see actual statistical differences
  • In this presentation, we will test if manual or automatic have better fuel efficiency using the mtcars dataset

Setting Up the Hypotheses

Our hypothesis tests whether manual cars have higher mean miles per gallon (mpg) than automatic car

\[ H_0: \mu_{manual} = \mu_{automatic} \\ H_a: \mu_{manual} \neq \mu_{automatic} \]

We will use a two-sample t-test at a significance level of \(= 0.05\), meaning if it is less than the level, the decision will be rejected.

Previewing the Data

Preview mtcars dataset
mpg cyl disp hp drat wt qsec vs am gear carb
Mazda RX4 21.0 6 160 110 3.90 2.620 16.46 0 Manual 4 4
Mazda RX4 Wag 21.0 6 160 110 3.90 2.875 17.02 0 Manual 4 4
Datsun 710 22.8 4 108 93 3.85 2.320 18.61 1 Manual 4 1
Hornet 4 Drive 21.4 6 258 110 3.08 3.215 19.44 1 Automatic 3 1
Hornet Sportabout 18.7 8 360 175 3.15 3.440 17.02 0 Automatic 3 2
Valiant 18.1 6 225 105 2.76 3.460 20.22 1 Automatic 3 1

Performing the Two-Sample t-test

# Perform the 2 sample t-test and display the results
t_test_result <- t.test(mpg ~ am, data = mtcars)
print(t_test_result)
## 
##  Welch Two Sample t-test
## 
## data:  mpg by am
## t = -3.7671, df = 18.332, p-value = 0.001374
## alternative hypothesis: true difference in means between group Automatic and group Manual is not equal to 0
## 95 percent confidence interval:
##  -11.280194  -3.209684
## sample estimates:
## mean in group Automatic    mean in group Manual 
##                17.14737                24.39231

Boxplot showing MPG per transmission type for automatic and manual cars

Density plot showing distribution of MPG by transmission type

T-distribution for visualization

Framing the Decision

As decided earlier, if the p-value < 0.05, we reject the null hypothesis.

Otherwise, we fail to reject it.

From our test:

  • p-value = 0.0014
  • Mean (Manual) = 24.39
  • Mean (Automatic) = 17.15

\[ \text{Decision: Reject } H_0 \text{ if } p < 0.05 \]

Summary of Findings

  • From the t-test we saw that manual transmission has a higher MPG average then automatic cars
  • We can say that the difference is statistically significant.
  • Significance Testing has helped us confirm that results are not due to random variations

Application where Significance Testing is Used:

  • Trauma Response Data
  • Marketing
  • Medical Data
  • National Security