2025-03-16

Introduction

  • Hypothesis testing is a statistical method used to make decisions based on data.
  • It involves testing an assumption about a population parameter.
  • Example: Does a new drug improve patient outcomes?

Steps in Hypothesis Testing

  1. State the null ( \(H_0\) ) and alternative hypothesis ( \(H_A\) ).
  2. Choose the significance level ( \(\alpha\) ).
  3. Collect and summarize data.
  4. Calculate the test statistic.
  5. Compare with the critical value or compute p-value.
  6. Make a decision: Reject or fail to reject \(H_0\) .

Null and Alternative Hypothesis

  • Null Hypothesis ( \(H_0\) ): Assumes no effect or no difference.
  • Alternative Hypothesis ( \(H_A\) ): Contradicts \(H_0\) , suggesting an effect or difference.

Example:

\(H_0: \mu = 50\) (Mean is 50) - \(H_A: \mu \neq 50\) (Mean is different from 50)

Example: One-Sample t-test

library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.4.3
set.seed(123)
data <- data.frame(values = rnorm(30, mean=50, sd=10))
test_result <- t.test(data$values, mu=50)
test_result
## 
##  One Sample t-test
## 
## data:  data$values
## t = -0.26299, df = 29, p-value = 0.7944
## alternative hypothesis: true mean is not equal to 50
## 95 percent confidence interval:
##  45.86573 53.19219
## sample estimates:
## mean of x 
##  49.52896

Plot: Data Distribution

ggplot(data, aes(x=values)) +
  geom_histogram(binwidth=5, fill="blue", alpha=0.5, color="black") +
  geom_vline(xintercept=50, linetype="dashed", color="red") +
  ggtitle("Histogram of Sample Data")

P-Value and Decision

  • The p-value tells us the probability of observing our result if \(H_0\) is true.
  • If p-value < \(\alpha\) , reject \(H_0\) (significant result).
  • If p-value ≥ \(\alpha\) , fail to reject \(H_0\) (not enough evidence).

3D Visualization: t-Distribution

Conclusion

  • Hypothesis testing is fundamental in statistics for decision-making.
  • It helps determine if observed effects are statistically significant.
  • Applications include medicine, engineering, finance, and more.