Skip to content

Instantly share code, notes, and snippets.

@JonasMoss
Created March 25, 2018 20:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JonasMoss/238643b4b1d7563f9e7bfc89f11f2b96 to your computer and use it in GitHub Desktop.
Save JonasMoss/238643b4b1d7563f9e7bfc89f11f2b96 to your computer and use it in GitHub Desktop.
Small demonstration of power.
## A small demonstration of statistical power for a one-sided z-test. The point
## is to show that powers close to zero or one are not reasonable to assume a
## priori.
n = 80
theta = seq(-0.3, 1, by = 0.01)
plot(theta, 1 - pnorm(1.96 - sqrt(n)*theta), type = "l", bty = "l",
xlab = expression(theta), ylab = "Power",
main = paste0("Power when n = ", n))
grid()
lines(theta, 1 - pnorm(1.96 - sqrt(n)*theta))
abline(h = 0.05, col = "red", lty = 2)
abline(h = 0.95, col = "blue", lty = 2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment