-
-
Save chipoglesby/3413a4527de323a7d1e686a4e9440970 to your computer and use it in GitHub Desktop.
Code from this tweet: https://twitter.com/drob/status/840636042470400000
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(broom) | |
library(scales) | |
theme_set(theme_minimal()) | |
crossing(n = round(10 ^ seq(1, 7, .1)), | |
delta = 10 ^ seq(-1, -3, -1), | |
sig.level = .05, | |
sd = .3) %>% | |
invoke(power.t.test, ., type = "one.sample") %>% | |
tidy() %>% | |
ggplot(aes(n, power, color = percent(delta))) + | |
geom_line() + | |
geom_hline(lty = 2, yintercept = .9) + | |
scale_x_log10(labels = comma_format()) + | |
scale_y_continuous(labels = percent_format()) + | |
labs(x = "Number of observations (log scale)", | |
y = "Power of one-sample t-test", | |
color = "Effect size", | |
title = "Power of one-sample t-test depending on sample size", | |
subtitle = "Standard deviation = .3; dashed line shows power = 90%") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment