2025-09-23

Hypothesis Testing

Why is Hypothesis Testing important?

- Hypothesis Testing allows us to determine if a sample contains enough data to suggest an alternative hypothesis.

- Allows us to test multiple different potential hypothesis to determine if any are worth exploring.

- Testing can lead to incorrect conclusions called Type I and Type II Errors.

Important Terms

\(H_{0}\) = Null Hypothesis, referring to there being no relationship in the data

\(H_{1}\) = Alternative Hypothesis, referring to the proposed hypothesis being tested

p-value, is the smallest level of significance causing the \(H_{0}\) to be rejected

\(\alpha\), is the significance level or likely hood of error. If you are 99% cofindent, \(\alpha\) = 0.01

One Sided Confidence Intervals


For one sided lower intervals we reject \(H_{0}\), if \(z_{0}< -z_{\alpha}\)
For one sided upper intervals we reject \(H_{0}\), if \(z_{0}> z_{\alpha}\)

Two Sided Confidence Intervals


For two sided intervals we reject \(H_{0}\),
if \(z_{0}> z_{\alpha/2}\) or \(z_{0}< -z_{\alpha/2}\)

Testing \(\mu\) when we know \(\sigma^{2}\) for one sided

\(H_{0}\) is \(\mu = \mu_{0}\)

For one sided lower intervals \(H_{1}\) is \(\mu < \mu_{0}\) and for upper \(H_{1}\) if \(\mu > \mu_{0}\)
We Reject \(H_{0}\) if \(z_{0} > z_{\alpha}\) for upper intervals and we reject \(H_{0}\) if \(z_{0} < -z{\alpha}\) for lower intervals

If we still have no rejected our Hypothesis, we compute our p-value, for upper intervals our p-value = \(1-\phi(z_{0})\) and for lower intervals our p-value = \(\phi(z_{0})\)

Finally if the p-value < \(\alpha\) we reject \(H_{0}\)

Testing \(\mu\) when we know \(\sigma^{2}\) for two sided

\(H_{0}\) is \(\mu = \mu_{0}\)
For two sided intervals \(H_{1}\) is \(\mu \neq \mu_{0}\)

We reject \(H_{0}\) if \(z_{0} > z_{\alpha/2}\) or if \(z_{0} < -z_{\alpha/2}\)

The p-value for two-sided intervals can be found by \(2[1-\phi(|z_{0}|)]\)

Finally just as with our one-sided intervals, if p-value < \(\alpha\) we reject \(H_{0}\)

Additional Two-sided confidence interval graph example

Example of creating a normal distributions

  normdist <- ggplot(data = data.frame(x = c(-5, 5)), aes(x)) +
  stat_function(fun = dnorm, n = 1000, args = list(mean = 0, sd = 1)) + 
  scale_y_continuous(breaks = NULL) +       
  scale_x_continuous(labels = c("-infinity", "-Z of alpha", 
                                "mean", "Z of alpha", "Infinity"))