2024-10-21

Introduction to P-Values

  • P-Value: a number describing how likely it is that your data would have occurred under the null hypothesis of your statistical test
  • Role in Hypothesis Testing: helps determine if the null hypothesis should be rejected
  • A small p-value (≤ 0.05) indicates strong evidence against the null hypothesis
  • A large p-value suggests weak evidence against the null hypothesis

Example of P-Value

  • Scenario: Tossing a Coin (is there an equal chance of landing heads or tails)
  • Null Hypothesis (\(H_0\)): The coin is fair (probability of heads = 0.5)
  • Alternative Hypothesis (\(H_a\)): The coin is not fair (probability of heads ≠ 0.5).

Experiment Design

  • Toss the coin a certain number of times (e.g., 100 tosses).
  • Count the number of heads and tails.
  • Calculate the p-value based on the observed number of heads.

Slide 4: R Code to Simulate Coin Tosses

set.seed(123)
n_tosses <- 100
n_heads <- rbinom(1, n_tosses, 0.5)
n_tails <- n_tosses - n_heads

results <- c(n_tails, n_heads)
results
## [1] 51 49
tosses <- rbinom(n_tosses, 1, 0.5)

P-Value Calculation

  • Observed Heads: Let’s say we observed \(60\) heads.

  • P-Value: If the p-value is less than \(0.05\), we reject \(H_0\), indicating that the coin may not be fair.

  • Formula: \[ P\text{-value} = P(X \geq k | H_0) \] where \(k\) is the observed number of heads.

Bar Plot of Coin Toss Results

Scatter Plot of P-Values