03/06/2019

Slide 2

Power is the ability of a statistical test to reject a false null hypothesis.

We plot out an example of a two sample test where we would like to see if the mean of the second group is greater than the first group. The mean of the first group is 20, and the second gorup 30. The standard deviation and sample size for both groups are 15 and 25 respectively.

https://andrewlau.shinyapps.io/Power/

Andrew Lau

Use the left and right arrow keys to navigate.

Slide 3

library(ggplot2)
x = seq(0, 50, 0.1)
y_1 = dnorm(x, mean=20, sd=15 / sqrt(25))
y_2 = dnorm(x, mean=30, sd=15 / sqrt(25))
crit_value = qnorm(p=1 - 0.05, mean=20, sd=15 / sqrt(25))

x_shade = seq(crit_value, 50, 0.1)
y_shade = dnorm(x_shade, mean=30, sd=15 / sqrt(25))

data = data.frame("x" = c(x, x, x_shade), "y" = c(y_1, y_2, y_shade),
                  "group" = c(rep("A", length(x)), rep("B", length(x)),
                              rep("B_shade", length(x_shade))))

Slide 4

The below code visually demonstrates power.

Slide 5

This widget shows the distributions of the means of two independent samples. We are testing whether the mean of group B is greater than group A (a one-sided, two-sample test). The shaded in blue region above represents the power of this test. Play around and see how the standard deviation, alternate mean, sample size and the critical value, alpha, affect the power!

https://andrewlau.shinyapps.io/Power/