Shiny Project Presentation

Marty Gaupp
27 Sep 2015

To explore the interaction between type I error (\( \alpha \)) and type II error (\( \beta \)), I built a shiny app that allows the user to manipulate \( \sigma \), \( \mu_a \), n, and \( \alpha \). The app then computes the resulting beta (and power) and shades in the appropriate area under each curve to represent alpha and beta.

Introduction to Type I and Type II Errors

  • Type I error is incorrectly rejecting a true null hypothesis
    • such a “false positive” is denoted by \( \alpha \)
      • detecting an effect that is not present
    • \( \alpha \) = P(type I error) = P(reject \( H_0 \)|\( H_0 \) is true)
  • Type II error is failing to reject a false null hypothsis
    • such a “false negative” is denoted by \( \beta \)
      • failing to detect an effect that is present
    • \( \beta \) = P(type II error) = P(FTR \( H_0 \)|\( H_0 \) is false)
  • How about confidence and power?
    • confidence = 1 - \( \alpha \) = rejecting an effect that is not present
    • power = 1 - \( \beta \) = detecting an effect that is present

Components of Type I and Type II Errors

  • \( \alpha \) is usually controlled by the experimenter
    • represents the amount of error that is tolerable
    • affected by:
      • sample size (n)
      • spread in the data (\( \sigma \))
  • \( \beta \) is much harder to control
    • affected by the true (but unkown) alt hypotheis (\( \mu_a \))
      • the greater \( \mu_a \) is from the null hypothesis (\( \mu_0 \)) the better
      • it's easier to detect a bigger effect (\( \Delta\mu \))
  • \( \alpha \) and \( \beta \) work against each other
    • to increase both, increase n, \( \sigma \), and/or \( \Delta\mu \)

Calculating Power

  • Type I error (\( \alpha \)) is controlled by the experimenter
    • \( \alpha \) = area under red curve to the right of the line
  • Type II error (\( \beta \)) depends on \( \sigma \), \( \mu_a \), n, and \( \alpha \)
    • \( \beta \) = area under blue curve to the left of the line
  • In the app, line location is set by the \( \alpha \) slider
    • \( \beta \) = lower tail of a pnorm function call
    • for example:
      • if \( \mu_0 \) = 30, \( \sigma \) = 4, \( \mu_a \) = 32, n = 16, and \( \alpha \) = 0.05
      • then \( \beta \) = 0.361
      • and power = 63.9 %

The Shiny App

To use the shiny app to investigate the relationship between type I and type II error, just adjust \( \sigma \), \( \mu_a \), n, and/or \( \alpha \) in the app

alt text

The app automatically calculates beta and power using the pnorm function described on the previous slide