2025-02-07

What is Hypothesis Testing

  1. Hypothesis Testing is a form of statistical analysis where you have an assumption you wish to test
  2. The goal of Hypothesis Testing is to determine if there is enough evidence to support or reject the claim you made in you Hypothesis
  3. It is used to determine the relationship between two variables

The Steps in Statistical Hypothesis Testing

  1. State the Null Hypothesis (H0)
  2. State the Alternative Hypothesis (H1 or Ha)
  3. Set 𝜶 (Significane Level)
  4. Collect Data
  5. Select and Calcuate a Test Statistic
  6. Construct Acceptance and Rejection Regions
  7. Draw Conclusion about H0

Null Hypotheis & Alternative Hypothesis Formulas

μ is the population mean and μ0 is the hypothetical population mean \[ \\H_0: \mu = \mu_0 \\ H_a: \mu \neq \mu_0 \]

Types of Statistical Hypothesis Testign

  1. Z Test
  • Used to determine if a relationship is staistically significant
  1. T Test
  • Used to compare the means of two groups
  1. Chi-Square
  • Used to determine if your data is as predicted (oberserved values compared to predicted values)
  1. ANOVA
  • Used to compare the means of three or more groups

Formulas for Z Test, T Test, and Chi Square

\[ Z = \frac{\bar{X} - \mu_0}{\sigma / \sqrt{n}} \\ \]

\[ t = \frac{\bar{X} - \mu}{S / \sqrt{n}} \\ \]

\[ \chi^2 = \sum \frac{(O_i - E_i)^2}{E_i} \]

F-Distribution Region for Acceptance or Rejection Regions in ggplot

R code for creating F Distribution Graph in R Studio

df1 = 5  
df2 = 20 
x_vals= seq(0, 5, length.out = 100) 
y_vals = df(x_vals, df1, df2) 
f_data= data.frame(F_stat = x_vals, Density = y_vals)
alpha=  0.05
F_critical = qf(1 - alpha, df1, df2)
ggplot(f_data, aes(x = F_stat, y = Density)) +
  geom_line(color = "black", linewidth = 1) +  
  geom_ribbon(aes(ymax = ifelse(F_stat >= F_critical, Density, NA),
  ymin = 0), fill = "red", alpha = 0.5) + annotate("text", 
  x = F_critical - 0.5, y = 0.1, label = "Accept H0", 
  color = "green", size = 5) + annotate("text", 
  x = F_critical + 0.3, y = 0.05, 
  label = "Reject H0", color = "red", size = 5) +
  labs(title = "F-Distribution Hypothesis Test",
       x = "F Statistic", y = "P(F)") 

Two Tailed Hypothesis Test

Visualizing Hypothesis with Plotly