2025-06-08

What is a P-Value?

  • Short for probability value — the probability of getting data as extreme as observed with the null hypothesis holding true.
  • A null hypothesis assumes patterns in data are due to chance, not a real effect.
  • In short: “What are the odds I’d see this extreme data by chance?”
  • Don’t worry about the jargon, it is merely a telltale number derived in Statistics and Probability

\[ p = P(\text{data} \mid H_0 \text{ is true}) \]

Why P Values Matter

  • P-values help determine if an observed effect is statistically significant.
  • They are widely used in science, medicine, business, and more.
  • If the p-value is less than the significance level (commonly 0.05), the result is considered statistically significant.

Comparing Two Groups, getting Resulting P-Value

# Compare MPG between 4- and 6-cylinder cars
df <- filter(mtcars, cyl == 4 | cyl == 6)
t_result <- t.test(mpg ~ cyl, data = df)
t_result$p.value
## [1] 0.0004048495

Boxplot of MPGs: 4 cyl vs 6 cyl

ggplot(df, aes(x = factor(cyl), y = mpg)) +
  geom_boxplot(fill = "skyblue") +
  labs(
    title = "Boxplot: MPG for 4 vs 6 Cylinder Cars",
    x = "Number of Cylinders",
    y = "Miles Per Gallon"
  )

Boxplot with highlighted mean values

Red dots show group means — reinforcing the visual trend behind the low p-value.

3D Plot: MPG as a function of weight and horsepower

MPG varies in response to both horsepower and weight — showing real-world variable interaction.

P-Value Decision Rule

When testing hypotheses the following is done:

  • Set a significance level (0.05 here): \(\alpha = 0.05\)
  • Define:
    • \(H_0\): null hypothesis (no effect)
    • \(H_A\): alternative hypothesis (effect exists)

Then apply:

\[ \text{If } p < \alpha, \text{ reject } H_0 \]

\[ \text{If } p \geq \alpha, \text{ fail to reject } H_0 \]

This is the formal rule used to make decisions in hypothesis testing using the p-value.