2024-10-20

What is Hypothesis Testing?

  • A statistical method for making decisions based on data.
  • Involves formulating null and alternative hypotheses.
  • Determines if there is enough evidence to reject the null hypothesis.

Null and Alternative Hypotheses

  • Null Hypothesis (H0): Assumes no effect or no difference.
  • Alternative Hypothesis (H1): Assumes there is an effect or a difference.

\[ H_0: \mu = \mu_0 \] \[ H_1: \mu \neq \mu_0 \]

Types of Errors

  • Type I Error (α): Rejecting H0 when it is true (false positive).
  • Type II Error (β): Failing to reject H0 when it is false (false negative).

Understanding p-values

  • The p-value measures the strength of evidence against H0.
  • A small p-value indicates strong evidence against H0.
  • Common significance levels: 0.05, 0.01.

\[ p\text{-value} < \alpha \Rightarrow \text{reject } H_0 \]

Example: Testing a New Drug

  • H0: The new drug has no effect on blood pressure.
  • H1: The new drug lowers blood pressure.
  • Data collected from a clinical trial.

Creating the data

  • Here’s the code for creating the data frame
  • control = rnorm(100,mean=120,sd=10)
  • treatment =rnorm(100,mean=115,sd=10)
  • bloodpressuredata =data.frame(group = rep(c(“Control”,“Treatment”),each = 100), bloodpressure = c(control, treatment))
  • summary(bloodpressuredata)
  • Here’s what the code created:
##     group           bloodpressure   
##  Length:200         Min.   : 85.52  
##  Class :character   1st Qu.:109.31  
##  Mode  :character   Median :116.76  
##                     Mean   :116.26  
##                     3rd Qu.:123.11  
##                     Max.   :147.33

Boxplot

Histogram

2D scatter plot