Skip to content

Instantly share code, notes, and snippets.

@benwhalley
Last active October 5, 2017 09:30
Show Gist options
  • Save benwhalley/49dc0d5a8212de6ad64618c6b444c637 to your computer and use it in GitHub Desktop.
Save benwhalley/49dc0d5a8212de6ad64618c6b444c637 to your computer and use it in GitHub Desktop.
f.10 <- log.auc.positive ~ log(CueOrder)*Congruent + (1|Participant) + (0+log(CueOrder)*Congruent|Participant)
fit.10.stan <- stan_lmer(f.10, data=dftouse, iter=5000, chains=3)
summary(fit.10.stan)
fit.10.stan.preds <- posterior_linpred(fit.10.stan,
transform=F,
re.form=NA) %>%
t %>%
as.data.frame() %>%
bind_cols(dftouse, .) %>%
reshape2::melt(id.vars=c("Participant",
"BlockNo", "Trial", "Congruent")) %>%
rename(fit=value, sim=variable)
fit.10.stan.preds.wide <- fit.10.stan.preds %>%
reshape2::dcast(BlockNo+Trial+sim~Congruent,
fun.aggregate = mean,
value.var='fit') %>%
ungroup() %>%
mutate(Effect = (`TRUE`-`FALSE`), D = Effect/sd(`FALSE`))
fit.10.stan.preds.wide %>%
group_by(BlockNo, Trial) %>%
tidybayes::median_qi(D) %>%
ggplot(aes(Trial, D, ymin=conf.low, ymax=conf.high)) +
geom_hline(yintercept = 0) +
geom_ribbon(alpha=.2) + geom_line() + facet_wrap(~BlockNo, ncol=4) +
scale_y_continuous(breaks=seq(-3, 5, by=.5)) +
ylab("Congruency Effect")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment