- The p-value is the probability of obtaining a result equal to or more extreme than what was observed, assuming the null hypothesis is true.
- A small p-value indicates strong evidence against the null hypothesis.
- Common thresholds: 0.05, 0.01, 0.001.
2025-06-08
\[ p = P(\text{observing data as extreme as the sample data} \mid H_0 \text{ is true}) \]
\[ p = \int_{x_{obs}}^\infty f(x \mid H_0) \, dx \]
set.seed(123)
placebo <- rbinom(1000, 1, 0.10) # 10% infection rate
vaccine <- rbinom(1000, 1, 0.08) # 8% infection rate
data <- data.frame(
group = rep(c("Placebo", "Vaccine"), each = 1000),
infected = c(placebo, vaccine)
)
test_result <- prop.test(x = c(sum(placebo), sum(vaccine)),
n = c(length(placebo), length(vaccine)),
alternative = "greater")
test_result$p.value
## [1] 0.1301831