Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

analyse_10_localiser_rt_acc.R 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. library(dplyr)
  2. library(readr)
  3. library(purrr)
  4. library(tidyr)
  5. library(brms)
  6. library(ggdist)
  7. library(ggplot2)
  8. theme_set(theme_classic() + theme(strip.background = element_rect(fill = "white"), plot.background = element_blank()))
  9. library(patchwork)
  10. cond_cols <- c(
  11. "Words" = "#000000",
  12. "False Font" = "#D81B60",
  13. "Phase-Shuffled" = "#1E88E5"
  14. )
  15. # summarise picture-word RT posteriors ------------------------------------
  16. # pw_rt_post_summ <- file.path("mods", "m_rt.rds") %>%
  17. # readRDS() %>%
  18. # as_draws_df(variable="^sd\\_", regex=TRUE) %>%
  19. # select(-.chain, -.iteration, -.draw) %>%
  20. # pivot_longer(cols = everything(), names_to="par", values_to="est") %>%
  21. # group_by(par) %>%
  22. # summarise(
  23. # m = mean(est),
  24. # s = sd(est)
  25. # )
  26. # import data -------------------------------------------------------------
  27. d <- file.path("raw_data", "stim-pc", "data", "localiser") %>%
  28. list.files(pattern = "^.*\\.csv$", full.names = TRUE) %>%
  29. map_df(read_csv, col_types = cols(sex="c"))
  30. d_cleaned_for_rt_m <- filter(d, acc == 1) %>%
  31. mutate(
  32. ff_dev = scale(ifelse(condition=="bacs", 1, 0), center=TRUE, scale=FALSE),
  33. noise_dev = scale(ifelse(condition=="noise", 1, 0), center=TRUE, scale=FALSE)
  34. )
  35. d_cleaned_for_acc_m <- filter(d, rt <= 1500) %>%
  36. mutate(
  37. ff_dev = scale(ifelse(condition=="bacs", 1, 0), center=TRUE, scale=FALSE),
  38. noise_dev = scale(ifelse(condition=="noise", 1, 0), center=TRUE, scale=FALSE)
  39. )
  40. # fit rt model ------------------------------------------------------------
  41. rt_priors <- c(
  42. # FIXED EFFECTS
  43. # mu
  44. set_prior("normal(5.3, 1)", class = "b", coef = "Intercept"),
  45. set_prior("normal(0, 1)", class = "b", coef = "ff_dev"),
  46. set_prior("normal(0, 1)", class = "b", coef = "noise_dev"),
  47. # sigma
  48. set_prior("normal(-0.561, 1)", class = "b", coef = "Intercept", dpar="sigma"),
  49. set_prior("normal(0, 1)", class = "b", coef = "ff_dev", dpar="sigma"),
  50. set_prior("normal(0, 1)", class = "b", coef = "noise_dev", dpar="sigma"),
  51. # delta
  52. set_prior("normal(-9, 5)", class = "b", coef = "Intercept", dpar="ndt"),
  53. # SDs of RANDOM EFFECTS
  54. set_prior("student_t(5, 0, 1)", class = "sd")
  55. )
  56. n_cores <- 7
  57. seed <- 3101
  58. refresh <- 25
  59. n_chains_rt <- 5
  60. n_iter_rt <- 10000
  61. n_warmup_rt <- 7500
  62. adapt_delta_rt <- 0.9
  63. max_treedepth_rt <- 10
  64. inits_rt <- replicate(
  65. n_chains_rt,
  66. list(b_ndt = as.array(c(-5))),
  67. simplify=FALSE
  68. )
  69. m_rt <- brm(
  70. formula = brmsformula(
  71. rt ~ 0 + Intercept + ff_dev + noise_dev +
  72. (ff_dev + noise_dev | subj_id) +
  73. (ff_dev + noise_dev | item_nr) +
  74. (1 | image),
  75. sigma ~ 0 + Intercept + ff_dev + noise_dev +
  76. (ff_dev + noise_dev | subj_id) +
  77. (ff_dev + noise_dev | item_nr) +
  78. (1 | image),
  79. ndt ~ 0 + Intercept
  80. ),
  81. data = d_cleaned_for_rt_m,
  82. family = shifted_lognormal(),
  83. prior = rt_priors,
  84. iter = n_iter_rt,
  85. warmup = n_warmup_rt,
  86. chains = n_chains_rt,
  87. control = list(
  88. adapt_delta = adapt_delta_rt,
  89. max_treedepth = max_treedepth_rt
  90. ),
  91. inits = inits_rt,
  92. sample_prior = "no",
  93. silent = TRUE,
  94. cores = n_cores,
  95. seed = seed,
  96. thin = 1,
  97. file = file.path("mods", "m_loc_rt.rds"),
  98. refresh = refresh
  99. )
  100. # fit accuracy model ------------------------------------------------------
  101. acc_priors <- c(
  102. set_prior("normal(5, 1)", class="b", coef="Intercept"),
  103. set_prior("normal(0, 5)", class="b", coef="ff_dev"),
  104. set_prior("normal(0, 5)", class="b", coef="noise_dev"),
  105. set_prior("student_t(5, 0, 1)", class = "sd")
  106. )
  107. n_iter_acc <- 10000
  108. n_warmup_acc <- 7500
  109. adapt_delta_acc <- 0.99
  110. max_treedepth_acc <- 10
  111. n_chains_acc <- 5
  112. m_acc <- brm(
  113. formula = acc ~ 0 + Intercept + ff_dev + noise_dev +
  114. (ff_dev + noise_dev | subj_id) +
  115. (ff_dev + noise_dev | item_nr) +
  116. (1 | image),
  117. data = d_cleaned_for_acc_m,
  118. family = bernoulli("logit"),
  119. prior = acc_priors,
  120. iter = n_iter_acc,
  121. warmup = n_warmup_acc,
  122. chains = n_chains_acc,
  123. control = list(
  124. adapt_delta = adapt_delta_acc,
  125. max_treedepth = max_treedepth_acc
  126. ),
  127. sample_prior = "no",
  128. silent = TRUE,
  129. cores = n_cores,
  130. seed = seed,
  131. thin = 1,
  132. file = file.path("mods", "m_loc_acc.rds"),
  133. refresh = refresh
  134. )
  135. draws_preds <- as_draws_df(m_acc, variable="^b\\_", regex=TRUE) %>%
  136. expand_grid(condition = unique(d_cleaned_for_acc_m$condition)) %>%
  137. left_join(
  138. d_cleaned_for_acc_m %>%
  139. select(condition, ff_dev, noise_dev) %>%
  140. distinct(),
  141. by = "condition"
  142. ) %>%
  143. mutate(
  144. pred_logit = b_Intercept + b_ff_dev * ff_dev + b_noise_dev * noise_dev,
  145. pred_odds = exp(pred_logit),
  146. prob = pred_odds / (1 + pred_odds),
  147. cond_lab = factor(recode(
  148. condition,
  149. word = "Words",
  150. bacs = "False Font",
  151. noise = "Phase-Shuffled"
  152. ), levels = c("Words", "False Font", "Phase-Shuffled"))
  153. )
  154. acc_pl <- draws_preds %>%
  155. mutate(pointinterval_pos = recode(condition, word=-30, bacs=-60, noise=-90)) %>%
  156. ggplot(aes(prob, fill=cond_lab, colour=cond_lab)) +
  157. geom_density(alpha=0.4, trim=TRUE) +
  158. stat_pointinterval(aes(y=pointinterval_pos), point_interval = median_hdi, .width=.89, interval_size=2, point_size=1.75) +
  159. scale_colour_manual(values = cond_cols) +
  160. scale_fill_manual(values = cond_cols) +
  161. scale_x_continuous(expand = expansion(), limits=c(NA, 1)) +
  162. scale_y_continuous(expand = expansion(mult=0.04)) +
  163. labs(
  164. x = "Probability of Correct Response",
  165. y = "Posterior Density",
  166. colour = "Stimulus Type",
  167. fill = "Stimulus Type"
  168. ) +
  169. theme(
  170. legend.position = "top",
  171. axis.ticks.y = element_blank(),
  172. axis.text.y = element_blank()
  173. )
  174. # get predictions of densities for RT -------------------------------------
  175. times <- 1:1000
  176. rt_dens_pred <- as_draws_df(m_rt, "^b\\_.*", regex=TRUE) %>%
  177. select(-starts_with(".")) %>%
  178. expand_grid(condition = c("bacs", "noise", "word")) %>%
  179. left_join(
  180. d_cleaned_for_rt_m %>%
  181. select(condition, ff_dev, noise_dev) %>%
  182. distinct(),
  183. by = "condition"
  184. ) %>%
  185. mutate(
  186. pred_mu = b_Intercept + ff_dev * b_ff_dev + noise_dev * b_noise_dev,
  187. pred_sigma = b_sigma_Intercept + ff_dev * b_sigma_ff_dev + noise_dev * b_sigma_noise_dev,
  188. # pred_ndt = b_ndt_Intercept + ff_dev * b_ndt_ff_dev + noise_dev * b_ndt_noise_dev,
  189. pred_ndt = b_ndt_Intercept
  190. ) %>%
  191. select(condition, starts_with("pred")) %>%
  192. expand_grid(rt = times) %>%
  193. mutate(
  194. pred_dens = dshifted_lnorm(
  195. x = rt,
  196. meanlog = pred_mu,
  197. sdlog = exp(pred_sigma),
  198. shift = exp(pred_ndt)
  199. )
  200. ) %>%
  201. group_by(rt, condition) %>%
  202. median_hdi(pred_dens, .width=0.89) %>%
  203. ungroup() %>%
  204. mutate(
  205. cond_lab = factor(recode(
  206. condition,
  207. word = "Words",
  208. bacs = "False Font",
  209. noise = "Phase-Shuffled"
  210. ), levels = c("Words", "False Font", "Phase-Shuffled"))
  211. )
  212. rt_pl <- rt_dens_pred %>%
  213. filter(pred_dens>0) %>%
  214. ggplot(aes(rt, pred_dens, ymin=.lower, ymax=.upper, fill=cond_lab, colour=cond_lab)) +
  215. geom_ribbon(alpha=0.4, show.legend = FALSE) +
  216. geom_text(aes(y=pred_dens * 1.15, label=""), show.legend=FALSE) +
  217. scale_colour_manual(values = cond_cols) +
  218. scale_fill_manual(values = cond_cols) +
  219. scale_x_continuous(expand = expansion(), limits=c(0, NA)) +
  220. scale_y_continuous(expand = expansion()) +
  221. labs(
  222. x = "Response Time (ms)",
  223. y = "Predicted Density",
  224. colour = "Stimulus Type",
  225. fill = "Stimulus Type"
  226. ) +
  227. theme(
  228. axis.text.y = element_blank(),
  229. axis.ticks.y = element_blank()
  230. )
  231. preds_pl <- (acc_pl | rt_pl) +
  232. plot_layout(guides = "collect") +
  233. plot_annotation(tag_levels = "a") &
  234. theme(legend.position = "bottom")
  235. ggsave(file.path("figs", "10_loc_rt_acc_preds.pdf"), preds_pl, width=5.5, height=2.5)
  236. # compare priors and posteriors -------------------------------------------
  237. priors_m_rt <- brm(
  238. formula = brmsformula(
  239. rt ~ 0 + Intercept + ff_dev + noise_dev +
  240. (ff_dev + noise_dev | subj_id) +
  241. (ff_dev + noise_dev | item_nr) +
  242. (1 | image),
  243. sigma ~ 0 + Intercept + ff_dev + noise_dev +
  244. (ff_dev + noise_dev | subj_id) +
  245. (ff_dev + noise_dev | item_nr) +
  246. (1 | image),
  247. ndt ~ 0 + Intercept
  248. ),
  249. data = d_cleaned_for_rt_m,
  250. family = shifted_lognormal(),
  251. prior = rt_priors,
  252. iter = n_iter_rt,
  253. warmup = n_warmup_rt,
  254. chains = n_chains_rt,
  255. control = list(
  256. adapt_delta = adapt_delta_rt,
  257. max_treedepth = max_treedepth_rt
  258. ),
  259. inits = inits_rt,
  260. sample_prior = "only",
  261. silent = TRUE,
  262. cores = n_cores,
  263. seed = seed,
  264. thin = 1,
  265. refresh = 1000
  266. )
  267. priors_m_acc <- brm(
  268. formula = acc ~ 0 + Intercept + ff_dev + noise_dev +
  269. (ff_dev + noise_dev | subj_id) +
  270. (ff_dev + noise_dev | item_nr) +
  271. (1 | image),
  272. data = d_cleaned_for_acc_m,
  273. family = bernoulli("logit"),
  274. prior = acc_priors,
  275. iter = n_iter_acc,
  276. warmup = n_warmup_acc,
  277. chains = n_chains_acc,
  278. control = list(
  279. adapt_delta = adapt_delta_acc,
  280. max_treedepth = max_treedepth_acc
  281. ),
  282. sample_prior = "only",
  283. silent = TRUE,
  284. cores = n_cores,
  285. seed = seed,
  286. thin = 1,
  287. refresh = 1000
  288. )
  289. prior_post_rt <- bind_rows(
  290. as_draws_df(m_rt, "^b\\_.*|^sd\\_.*", regex=TRUE) %>%
  291. select(-.chain, -.iteration, -.draw) %>%
  292. pivot_longer(cols=everything(), names_to="par", values_to="est") %>%
  293. mutate(source="posterior"),
  294. as_draws_df(priors_m_rt, "^b\\_.*|^sd\\_.*", regex=TRUE) %>%
  295. select(-.chain, -.iteration, -.draw) %>%
  296. pivot_longer(cols=everything(), names_to="par", values_to="est") %>%
  297. mutate(source="prior")
  298. ) %>%
  299. mutate(source = factor(source, levels = c("prior", "posterior")))
  300. prior_post_acc <- bind_rows(
  301. as_draws_df(m_acc, "^b\\_.*|^sd\\_.*", regex=TRUE) %>%
  302. select(-.chain, -.iteration, -.draw) %>%
  303. pivot_longer(cols=everything(), names_to="par", values_to="est") %>%
  304. mutate(source="posterior"),
  305. as_draws_df(priors_m_acc, "^b\\_.*|^sd\\_.*", regex=TRUE) %>%
  306. select(-.chain, -.iteration, -.draw) %>%
  307. pivot_longer(cols=everything(), names_to="par", values_to="est") %>%
  308. mutate(source="prior")
  309. ) %>%
  310. mutate(source = factor(source, levels = c("prior", "posterior")))
  311. # plots comparing priors and posteriors -----------------------------------
  312. # fixed effects
  313. pl_prior_post_fe_ints_rt <- prior_post_rt %>%
  314. filter(grepl("^b\\_", par), grepl("Intercept", par, fixed=TRUE)) %>%
  315. mutate(
  316. par_lab = factor(recode(
  317. par,
  318. b_Intercept = "mu",
  319. b_sigma_Intercept = "sigma",
  320. b_ndt_Intercept = "delta"
  321. ), levels = c("mu", "sigma", "delta"))
  322. ) %>%
  323. ggplot(aes(est, "Intercept", colour=source)) +
  324. stat_pointinterval(point_interval = "median_hdi", .width=.89, position=position_dodge(width=-0.4), show.legend = FALSE) +
  325. facet_wrap(vars(par_lab), scales = "free_x", labeller = label_parsed) +
  326. scale_y_discrete(expand = expansion(0.1, 0)) +
  327. scale_colour_manual(values = c("black", "red"), labels = c("Prior", "Posterior")) +
  328. labs(
  329. x = NULL,
  330. y = NULL,
  331. colour = NULL,
  332. tag = "b"
  333. ) +
  334. theme(
  335. legend.position = "none",
  336. axis.ticks.y = element_blank(),
  337. axis.text.y = element_blank()
  338. )
  339. pl_prior_post_fe_slopes_rt <- prior_post_rt %>%
  340. filter(grepl("^b\\_", par), !grepl("Intercept", par, fixed=TRUE)) %>%
  341. add_row(
  342. source = factor(c("prior", "prior", "posterior", "posterior"), levels=c("prior", "posterior")),
  343. par = rep(c("b_ndt_ff_dev", "b_ndt_noise_dev"), 2)
  344. ) %>%
  345. mutate(
  346. par_lab = factor(case_when(
  347. grepl("sigma", par, fixed=TRUE) ~ "sigma",
  348. grepl("ndt", par, fixed=TRUE) ~ "delta",
  349. TRUE ~ "mu"
  350. ), levels = c("mu", "sigma", "delta")),
  351. eff = factor(case_when(
  352. grepl("ff_dev", par, fixed=TRUE) ~ "Words Vs.\nFalse Font",
  353. grepl("noise_dev", par, fixed=TRUE) ~ "Words Vs.\nPhase-Shuffled",
  354. ))
  355. ) %>%
  356. ggplot(aes(est, reorder(eff, desc(eff)), colour=source)) +
  357. stat_pointinterval(point_interval = "median_hdi", .width=.89, position=position_dodge(width=-0.4), show.legend = FALSE) +
  358. facet_wrap(vars(par_lab), scales = "free_x", labeller = label_parsed) +
  359. scale_y_discrete(expand = expansion(0.1, 0)) +
  360. scale_colour_manual(values = c("black", "red"), labels = c("Prior", "Posterior")) +
  361. labs(
  362. x = "RT Model Estimate",
  363. y = NULL,
  364. colour = NULL
  365. ) +
  366. theme(
  367. legend.position = "bottom",
  368. legend.margin = margin(),
  369. strip.background = element_blank(),
  370. strip.text.x = element_blank(),
  371. axis.ticks.y = element_blank(),
  372. axis.text.y = element_blank()
  373. )
  374. pl_prior_post_fe_ints_acc <- prior_post_acc %>%
  375. filter(grepl("^b\\_", par), grepl("Intercept", par, fixed=TRUE)) %>%
  376. ggplot(aes(est, "Intercept", colour=source)) +
  377. stat_pointinterval(point_interval = "median_hdi", .width=.89, position=position_dodge(width=-0.4), show.legend = FALSE) +
  378. scale_y_discrete(expand = expansion(0.1, 0)) +
  379. scale_colour_manual(values = c("black", "red"), labels = c("Prior", "Posterior")) +
  380. labs(
  381. x = NULL,
  382. y = NULL,
  383. colour = NULL,
  384. tag = "a"
  385. ) +
  386. theme(
  387. legend.position = "none"
  388. )
  389. pl_prior_post_fe_slopes_acc <- prior_post_acc %>%
  390. filter(grepl("^b\\_", par), !grepl("Intercept", par, fixed=TRUE)) %>%
  391. mutate(
  392. eff = factor(case_when(
  393. grepl("ff_dev", par, fixed=TRUE) ~ "Words Vs.\nFalse Font",
  394. grepl("noise_dev", par, fixed=TRUE) ~ "Words Vs.\nPhase-Shuffled",
  395. ))
  396. ) %>%
  397. ggplot(aes(est, reorder(eff, desc(eff)), colour=source)) +
  398. stat_pointinterval(point_interval = "median_hdi", .width=.89, position=position_dodge(width=-0.4)) +
  399. scale_y_discrete(expand = expansion(0.1, 0)) +
  400. scale_colour_manual(values = c("black", "red"), labels = c("Prior", "Posterior")) +
  401. labs(
  402. x = "Accuracy Model\nEstimate",
  403. y = NULL,
  404. colour = NULL
  405. ) +
  406. theme(
  407. legend.position = "bottom",
  408. legend.margin = margin(),
  409. strip.background = element_blank()
  410. )
  411. pl_prior_post_fe <- pl_prior_post_fe_ints_acc + pl_prior_post_fe_ints_rt+
  412. pl_prior_post_fe_slopes_acc + pl_prior_post_fe_slopes_rt +
  413. plot_layout(guides = "collect", widths = c(1, 3), heights = c(1, 1.75)) &
  414. theme(legend.position = "bottom")
  415. ggsave(file.path("figs", "10_localiser_beh_prior_post_fes.pdf"), pl_prior_post_fe, width=6.5, height=3.25, device="pdf")
  416. # random effects
  417. # # subject random effects SDs
  418. # pl_prior_post_re_subj_ints_rt <- prior_post_rt %>%
  419. # filter(grepl("^sd\\_subj\\_id", par), grepl("Intercept", par, fixed=TRUE)) %>%
  420. # add_row(
  421. # source = factor(c("prior", "posterior"), levels=c("prior", "posterior")),
  422. # par = rep("sd_subj_id__ndt_Intercept", 2)
  423. # ) %>%
  424. # mutate(
  425. # par_lab = factor(case_when(
  426. # grepl("sigma", par, fixed=TRUE) ~ "sigma",
  427. # grepl("ndt", par, fixed=TRUE) ~ "delta",
  428. # TRUE ~ "mu"
  429. # ), levels = c("mu", "sigma", "delta"))
  430. # ) %>%
  431. # ggplot(aes(est, "Intercept", colour=source)) +
  432. # stat_pointinterval(point_interval = "median_hdi", .width=.89, position=position_dodge(width=-0.4)) +
  433. # facet_wrap(vars(par_lab), scales = "free_x", labeller = label_parsed) +
  434. # scale_y_discrete(expand = expansion(0.1, 0)) +
  435. # scale_colour_manual(values = c("black", "red"), labels = c("Prior", "Posterior")) +
  436. # labs(
  437. # x = NULL,
  438. # y = NULL,
  439. # title = "Participant Random Effects SDs",
  440. # tag = "A"
  441. # ) +
  442. # theme(legend.position = "none")
  443. #
  444. # pl_prior_post_re_subj_slopes_rt <- prior_post_rt %>%
  445. # filter(grepl("^sd\\_subj\\_id", par), !grepl("Intercept", par, fixed=TRUE)) %>%
  446. # add_row(
  447. # source = factor(c("prior", "prior", "posterior", "posterior"), levels=c("prior", "posterior")),
  448. # par = rep(c("sd_subj_id__ndt_ff_dev", "sd_subj_id__ndt_noise_dev"), 2)
  449. # ) %>%
  450. # mutate(
  451. # par_lab = factor(case_when(
  452. # grepl("sigma", par, fixed=TRUE) ~ "sigma",
  453. # grepl("ndt", par, fixed=TRUE) ~ "delta",
  454. # TRUE ~ "mu"
  455. # ), levels = c("mu", "sigma", "delta")),
  456. # eff = factor(case_when(
  457. # grepl("ff_dev", par, fixed=TRUE) ~ "Words Vs.\nFalse Font",
  458. # grepl("noise_dev", par, fixed=TRUE) ~ "Words Vs.\nPhase-Shuffled",
  459. # ))
  460. # ) %>%
  461. # ggplot(aes(est, reorder(eff, desc(eff)), colour=source)) +
  462. # stat_pointinterval(point_interval = "median_hdi", .width=.89, position=position_dodge(width=-0.4)) +
  463. # facet_wrap(vars(par_lab), scales = "free_x", labeller = label_parsed) +
  464. # scale_y_discrete(expand = expansion(0.1, 0)) +
  465. # scale_colour_manual(values = c("black", "red"), labels = c("Prior", "Posterior")) +
  466. # labs(
  467. # x = NULL,
  468. # y = NULL,
  469. # colour = NULL
  470. # ) +
  471. # theme(
  472. # legend.position = "none",
  473. # strip.background = element_blank(),
  474. # strip.text.x = element_blank()
  475. # )
  476. #
  477. # # item (match set) random effects SDs
  478. # pl_prior_post_re_item_ints_rt <- prior_post_rt %>%
  479. # filter(grepl("^sd\\_item", par), grepl("Intercept", par, fixed=TRUE)) %>%
  480. # add_row(
  481. # source = factor(c("prior", "posterior"), levels=c("prior", "posterior")),
  482. # par = rep("sd_item_nr__ndt_Intercept", 2)
  483. # ) %>%
  484. # mutate(
  485. # par_lab = factor(case_when(
  486. # grepl("sigma", par, fixed=TRUE) ~ "sigma",
  487. # grepl("ndt", par, fixed=TRUE) ~ "delta",
  488. # TRUE ~ "mu"
  489. # ), levels = c("mu", "sigma", "delta"))
  490. # ) %>%
  491. # ggplot(aes(est, "Intercept", colour=source)) +
  492. # stat_pointinterval(point_interval = "median_hdi", .width=.89, position=position_dodge(width=-0.4)) +
  493. # facet_wrap(vars(par_lab), scales = "free_x", labeller = label_parsed) +
  494. # scale_y_discrete(expand = expansion(0.1, 0)) +
  495. # scale_colour_manual(values = c("black", "red")) +
  496. # labs(
  497. # x = NULL,
  498. # y = NULL,
  499. # title = "Image Random Effects SDs",
  500. # tag = "B"
  501. # ) +
  502. # theme(legend.position = "none")
  503. #
  504. # pl_prior_post_re_item_slopes_rt <- prior_post_rt %>%
  505. # filter(grepl("^sd\\_item", par), !grepl("Intercept", par, fixed=TRUE)) %>%
  506. # add_row(
  507. # source = factor(c("prior", "prior", "posterior", "posterior"), levels=c("prior", "posterior")),
  508. # par = rep(c("sd_item_nr__ndt_ff_dev", "sd_item_nr__ndt_noise_dev"), 2)
  509. # ) %>%
  510. # mutate(
  511. # par_lab = factor(case_when(
  512. # grepl("sigma", par, fixed=TRUE) ~ "sigma",
  513. # grepl("ndt", par, fixed=TRUE) ~ "delta",
  514. # TRUE ~ "mu"
  515. # ), levels = c("mu", "sigma", "delta")),
  516. # eff = factor(case_when(
  517. # grepl("ff_dev", par, fixed=TRUE) ~ "Words Vs.\nFalse Font",
  518. # grepl("noise_dev", par, fixed=TRUE) ~ "Words Vs.\nPhase-Shuffled",
  519. # ))
  520. # ) %>%
  521. # ggplot(aes(est, eff, colour=source)) +
  522. # stat_pointinterval(point_interval = "median_hdi", .width=.89, position=position_dodge(width=-0.4)) +
  523. # facet_wrap(vars(par_lab), scales = "free_x", labeller = label_parsed) +
  524. # scale_y_discrete(expand = expansion(0.1, 0)) +
  525. # scale_colour_manual(values = c("black", "red"), labels = c("Prior", "Posterior")) +
  526. # labs(
  527. # x = NULL,
  528. # y = NULL,
  529. # colour = NULL
  530. # ) +
  531. # theme(
  532. # legend.position = "none",
  533. # strip.background = element_blank(),
  534. # strip.text.x = element_blank()
  535. # )
  536. #
  537. # # image random effects SDs
  538. # pl_prior_post_re_string_ints_rt <- prior_post_rt %>%
  539. # filter(grepl("^sd\\_image", par), grepl("Intercept", par, fixed=TRUE)) %>%
  540. # add_row(
  541. # source = factor(c("prior", "posterior"), levels=c("prior", "posterior")),
  542. # par = rep("sd_image__ndt_Intercept", 2)
  543. # ) %>%
  544. # mutate(
  545. # par_lab = factor(case_when(
  546. # grepl("sigma", par, fixed=TRUE) ~ "sigma",
  547. # grepl("ndt", par, fixed=TRUE) ~ "delta",
  548. # TRUE ~ "mu"
  549. # ), levels = c("mu", "sigma", "delta"))
  550. # ) %>%
  551. # ggplot(aes(est, "Intercept", colour=source)) +
  552. # stat_pointinterval(point_interval = "median_hdi", .width=.89, position=position_dodge(width=-0.4)) +
  553. # facet_wrap(vars(par_lab), scales = "free_x", labeller = label_parsed) +
  554. # scale_y_discrete(expand = expansion(0.1, 0)) +
  555. # scale_colour_manual(values = c("black", "red"), labels=c("Prior", "Posterior")) +
  556. # labs(
  557. # x = "Estimate",
  558. # y = NULL,
  559. # title = "Word Random Effects SDs",
  560. # tag = "C",
  561. # colour = NULL
  562. # ) +
  563. # theme(legend.position = "bottom", legend.margin = margin())