Created
May 12, 2021 18:20
-
-
Save mcfrank/3a77d494d2b304fd793e758e10f39583 to your computer and use it in GitHub Desktop.
This file contains 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) | |
probs <- c(.6, .8) | |
df <- expand_grid(subid = 1:10, | |
condition = 1:2, | |
trial_num = 1:12) %>% | |
group_by(condition) %>% | |
mutate(correct = rbinom(n = n(), size = 1, prob = probs[condition][1])) | |
ms <- df %>% | |
group_by(subid, condition) %>% | |
summarise(mean_correct = mean(correct)) | |
ggplot(ms, | |
aes(x = condition, y = mean_correct, col = condition)) + | |
geom_jitter(width = .1, height = 0) + | |
geom_hline(yintercept = .5, lty = 2) | |
iu_mean <- mean(ms$mean_correct[ms$condition == 1]) | |
ip_mean <- mean(ms$mean_correct[ms$condition == 2]) | |
pooled_sd <- sd(ms$mean_correct) | |
d <- (ip_mean - iu_mean) / pooled_sd | |
pwr::pwr.t.test(d = d, sig.level = .05, power = .8, | |
type = "two.sample", alternative = "two.sided") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment