2024-10-20

Introduction

Hypothesis testing is a method used to determine whether there is enough statistical evidence in a sample of data to infer that a certain condition is true for the entire population.

Null and Alternative Hypotheses

In hypothesis testing, we define two hypotheses:

\[ H_0: \mu = 70 \quad \text{(Null Hypothesis)} \] \[ H_A: \mu \neq 70 \quad \text{(Alternative Hypothesis)} \]

Where \(\mu\) is the population mean.

Simulated Data

We will simulate a sample of 30 data points from a normal distribution with a mean of 71 and standard deviation of 5, and then perform a t-test.

set.seed(123)
sample_data <- rnorm(30, mean = 71, sd = 5)

ggplot Histogram of Sample Data

ggplot Density Plot

Hypothesis Test (t-test)

We perform a one-sample t-test to check if the mean of our sample is significantly different from 70.

t_test_result <- t.test(sample_data, mu = 70)
t_test_result
## 
##  One Sample t-test
## 
## data:  sample_data
## t = 0.85364, df = 29, p-value = 0.4003
## alternative hypothesis: true mean is not equal to 70
## 95 percent confidence interval:
##  68.93287 72.59610
## sample estimates:
## mean of x 
##  70.76448

3D Plotly Plot

Now, let’s visualize some random data in 3D using Plotly.

Conclusion

Based on the p-value from the t-test, we decide to reject or fail to reject the null hypothesis.

\[ \text{If } p\text{-value} < \alpha, \text{ reject } H_0. \]

In this case, we have:

## [1] 0.4003008

R Code Slide

Finally, here’s a slide that shows the R code used to create one of the plots (the histogram, for example):