03-16-2024

Introduction

-A null hypothesis is a type of statistical hypothesis that proposes that no statistical significance exists in a set of given observations.

-Hypothesis testing is used to assess the credibility of a hypothesis by using sample data.

-A null hypothesis is a type of conjecture in statistics that proposes that there is no difference between certain characteristics of a population or data-generating process.

P-Value

  • The P value is defined as the probability under the assumption of no effect or no difference (null hypothesis), of obtaining a result equal to or more extreme than what was actually observed.
  • \[p = P(T \ge t | H_0)\]
  • The P stands for probability and measures how likely it is that any observed difference between groups is due to chance.

Example

  • Suppose we want to test if there is a significant difference in the average heights between two groups.
  • Null hypothesis (H0): \(\mu_1 = \mu_2\)
  • Alternative hypothesis (H1): \(\mu_1 \neq \mu_2\)

Frequency and MPG

Relationship between MPG and Weight

Plotly_3D: Weight X MPG X Displacement

Setting up null hypothesis and alternative hypothesis

Null Hypothesis (Ho)

The null hypothesis posits that there is no difference in the average MPG between cars with high displacement and cars with low displacement.

Alternative Hypothesis (Ha)

The alternative hypothesis suggests that there is a difference in the average MPG between cars with high displacement and cars with low displacement.

T-Test

high_disp <- mtcars$mpg[mtcars$disp > 200]
low_disp <- mtcars$mpg[mtcars$disp <= 200]

t_test_result <- t.test(high_disp, low_disp)

print(t_test_result)
## 
##  Welch Two Sample t-test
## 
## data:  high_disp and low_disp
## t = -6.0862, df = 24.191, p-value = 2.667e-06
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -11.80803  -5.82947
## sample estimates:
## mean of x mean of y 
##  15.68125  24.50000

Results

With a very significant p-value (2.667e-06) from the Welch t-test, the alternative hypothesis was accepted and the null hypothesis was rejected. This implies that the data indicates that cars with low displacement typically have greater MPG, and the evidence strongly supports that there is a statistically significant difference in MPG between cars with large displacement and those with low displacement.