2025-10-19

What is a P-value? Let us begin!

The p-value can be defined as the probability of estimating test resultd atleast as extreme as the ttue observed results, assuming that the null hypothesis is true.

Properties of p-value are:

  • Range: 0 - 1

  • Smaller p-values mean stronger evidence against the null hypothesis

  • it is also compared to the significance level when we measure it, \(\alpha\) (usually 0.05)

Mathematical Definition

The p-value for a test statistic is \(T\) can be defined mathematically as:

\[p\text{-value} = P(|T| \geq |t_{obs}| \mid H_0 \text{ is true})\]

Index for the above formula:

  • \(t_{obs}\) - Observed test statistic

  • \(H_0\) - Null hypothesis

  • When calculating the probability, we do it under the null distribution

When we do a two-tailed test with test statistic, \(Z \sim N(0,1)\):

\[p\text{-value} = 2 \cdot P(Z > |z_{obs}|)\]

Reference table with the values

Refer this table for when we need to reject or fail to reject.

Note: It is never “ACCEPT”, it is always “Fail to Reject”

p-Value Range Interpretation (agaisnt \(H_0\)) Decision (at a = 0.05)
p > 0.10 No evidence Fail to reject
0.05 < p <= 0.10. Weak evidence Fail to reject
0.01 < p <= 0.05. Moderate evidence Reject
p <= 0.01. Strong evidence Reject

Visualizing p-values, using Normal distribution:

EXAMPLE: Population Mean

Scenario: We all love coffee. A coffee shop by my house claims that their espresso shots have 75mg of caffeine. But I think that this is false and in fact, the caffeine content is actually higher.

Hypothesis:

  • \(H_0: \mu = 75\) mg (This is the null hypothesis)

  • \(H_a: \mu > 75\) mg (This is the alternative hypothesis)

Sample Data: Number of shots measured: 25

  • Sample mean: \(\bar{x} = 78.5\) mg
  • Sample standard deviation: \(s = 6.2\) mg
  • Significance level: \(\alpha = 0.05\)

Espresso Calculation

Let us calculate the t-statistic:

\[t = \frac{\bar{x} - \mu_0}{s/\sqrt{n}} = \frac{78.5 - 75}{6.2/\sqrt{25}} = \frac{3.5}{1.24} = 2.82\]

When the degrees of freedom \(df = n - 1 = 24\):

# let us calculate the p-value
t_stat <- 2.82
df <- 24
p_value <- pt(t_stat, df, lower.tail = FALSE)
cat("p-Value = ", round(p_value, 4))
## p-Value =  0.0047

Since p-value = 0.0047 < 0.05, we reject \(H_0\). This means that there is significance evidence that the mean caffeine content is higher than the said 75mg.

Complete T-test

# now let us use the sample data
set.seed(123)
caffeine <- rnorm(25, mean = 78.5, sd = 6.2)

# now let us perform one sample t-test
observ <- t.test(caffeine, mu = 75, alternative = "greater")

# print out the results
print(observ)
cat("\np-Value: ", observ$p.value)

# now we make our decision down below based on the calculated value
if (observ$p.value < 0.05) 
  {cat("Reject null hypothesis at alpha = 0.05")}
else 
  {cat("Fail to reject null hypothesis at alpha = 0.05")}

3D Visualization of data

p-Value distribution under the null hypothesis condition

Conclusion

So, what is p-Value? It can be defined as the probability og observing a set of data as an extreme IF the null hypothesis is true.

Summary

  • P-Values are used to quantify any sort of evidence against the null hypothesis

  • When there are smaller p-values, it means that there is a strong evidence against \(H_0\)

  • When calculating, consider effect sizes and confidence intervals against the p-values

  • Always know your \(\alpha\) before collecting the data

  • After calculating, ensure the practicality of the system as well.

Thank you. This is the end of the presentation!