Skip to content

Instantly share code, notes, and snippets.

@benwhalley
Created November 28, 2018 12:01
Show Gist options
  • Save benwhalley/4f268c68ddd4224d6ce4f5b28c9f1cb0 to your computer and use it in GitHub Desktop.
Save benwhalley/4f268c68ddd4224d6ce4f5b28c9f1cb0 to your computer and use it in GitHub Desktop.
library(rstanarm)
library(tidybayes)
m1 <- stan_lmer(t2_accuracy ~ lag*condition + (1|p), data = rsvp_accuracy)
nd <- expand.grid(condition=unique(rsvp_accuracy$condition), lag=factor(c(1,3))) %>% as.tibble() %>% mutate(p=Inf)
m1.preds <- add_fitted_samples(nd, m1)
m1.preds.wide <- m1.preds %>%
data.table::dcast(.iteration+condition~lag)
m1.preds.wide %>%
mutate(d=`1`-`3`) %>%
data.table::dcast(.iteration~condition, value.var="d") %>%
transmute(fam-omm, fam-control, control-omm) %>%
data.table::melt() %>%
group_by(variable) %>%
mean_qi()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment