2024-11-17

Introduction to Hypothesis Testing in Statistics

  • A statistical method to test assumptions about a population parameter.
  • The aim is to determine whether there is sufficient statistical evidence to support the hypothesis.
  • Two main hypotheses:
    • Null hypothesis (\(H_0\)): No effect or no difference.
    • Alternative hypothesis (\(H_1\)): Effect or difference exists.
  • Significance level (\(\alpha\)): Typically set to 0.05.

Steps in Hypothesis Testing

  • Formulating hypotheses
  • Choosing a test statistic based on data
  • Collecting data
  • Calculating P-value
  • Compare the P-value
  • Summarize the results and conclude

Visualizing Data with ggplot2

  • A ggplot histogram to show distribution

R code for visualization

## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout

Mathematics of Hypothesis Testing

  • Use of LaTex for formulas
  • Test statistic for a one-sample z-test: \[ z = \frac{\bar{x} - \mu}{\frac{\sigma}{\sqrt{n}}} \]
  • P-value interpretation: \[ p = P(Z > |z| \,|\, H_0) \]

Example Analysis

  • A ggplot boxplot comparing two graphs

3D plot with Plotly

  • A 3D visualisation of a test

Conclusion

  • Recap key points.

  • Importance of hypothesis testing in decision-making.

  • Hypothesis testing provides a structured way to test assumptions.

  • Visualization aids understanding and communication of results.

  • Statistical tools like R make hypothesis testing accessible and reproducible.