2025-06-09

P-Value

What is p-value?

-A p-value is a statistical measure used in hypothesis testing

-Assess the strength of evidence against a null hypothesis.

-It represents the probability of obtaining results as extreme as, or more extreme than, the observed results under the assumption that the null hypothesis is true. -The smaller the p-value, the more likely you are to reject the null hypothesis.

Example of A p-value

Suppose two groups have test scores:

Group A: 88, 75, 90, 95, 80

Group B: 65, 70, 72, 78, 68

Are their means significantly different?

## 
##  Welch Two Sample t-test
## 
## data:  a and b
## t = 3.5735, df = 6.6043, p-value = 0.009982
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##   4.952376 25.047624
## sample estimates:
## mean of x mean of y 
##      85.6      70.6

Example Scenario

Suppose a company claims that their batteries last at least 100 hours on average.
You test 30 batteries and get:

  • Sample mean: \(\bar{x} = 98.5\) hours
  • Known standard deviation: \(\sigma = 4\) hours

Is there evidence at \(\alpha = 0.05\) to doubt the company’s claim?

Calculating the Test Statistic

We use the one-sample z-test for the mean.

\[ z = \frac{\bar{x} - \mu_0}{\sigma / \sqrt{n}} \]

  • \(\bar{x} = 98.5\) (sample mean)
  • \(\mu_0 = 100\) (claimed mean)
  • \(\sigma = 4\) (known std dev)
  • \(n = 30\) (sample size)

\[ z = \frac{98.5 - 100}{4/\sqrt{30}} \approx -2.06 \]

Visualizing the Test Statistic

## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## Warning: Removed 130 rows containing non-finite outside the scale range
## (`stat_align()`).

Visualizing the Test Statistic

## Warning: Removed 130 rows containing non-finite outside the scale range
## (`stat_align()`).

Calculating the P-value

Since we’re checking if the mean is less than claimed (one-sided test):

\[ p\text{-value} = P(\bar{X} \leq 98.5 \mid H_0) = P(Z \leq -2.06) \]

  • The area in red is the p-value.

Interactive Plot: Z Distribution

Interpreting the Results

  • Calculated p-value: \(p = 0.0197\) (from \(Z = -2.06\))
  • Since \(p = 0.0197 < \alpha = 0.05\), reject \(H_0\)
  • There is statistically significant evidence to doubt the company’s claim.