Skip to content

Instantly share code, notes, and snippets.

@mcfrank
Created October 22, 2020 17:01
Show Gist options
  • Select an option

  • Save mcfrank/e586ad6b4e2812fa1125b15fa0e2971f to your computer and use it in GitHub Desktop.

Select an option

Save mcfrank/e586ad6b4e2812fa1125b15fa0e2971f to your computer and use it in GitHub Desktop.
library(tidyverse)
library(BayesFactor)
trials_per_kid <- 12
sim_data <- function (n) {
d <- expand.grid(subid = 1:n,
condition = c("pred","unpred","consistent")) %>%
rowwise %>%
mutate(correct = mean(rbinom(n = trials_per_kid,
p = case_when(condition == "pred" ~ .8,
condition == "unpred" ~ .7,
condition == "consistent" ~ .5), size = 1)))
}
bfs <- expand.grid(n = 1:60) %>%
rowwise %>%
mutate(bf = extractBF(anovaBF(correct ~ condition, data = sim_data(2)))[1]$bf)
qplot(x= n, y = bf, data = bfs) +
geom_smooth()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment