1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- library(brms)
- dat_rt <- readRDS("dat_rt.rds")
- n_cores <- 7
- seed <- 42
- n_iter <- 25000
- n_warmup <- 17500
- adapt_delta <- 0.99
- max_treedepth <- 11
- n_chains <- 5
- priors <- c(
- # FIXED EFFECTS
- set_prior("normal(0,7.5)", class = "b", coef = "Intercept"),
- set_prior("normal(0,2.5)", class = "b", coef = "cong_dev"),
- set_prior("normal(0,2.5)", class = "b", coef = "pred_norm"),
- set_prior("normal(0,2.5)", class = "b", coef = "cong_dev:pred_norm"),
- set_prior("normal(0,7.5)", class = "b", coef = "Intercept", dpar="sigma"),
- set_prior("normal(0,2.5)", class = "b", coef = "cong_dev", dpar="sigma"),
- set_prior("normal(0,2.5)", class = "b", coef = "pred_norm", dpar="sigma"),
- set_prior("normal(0,2.5)", class = "b", coef = "cong_dev:pred_norm", dpar="sigma"),
- set_prior("normal(0,7.5)", class = "b", coef = "Intercept", dpar="ndt"),
- set_prior("normal(0,2.5)", class = "b", coef = "cong_dev", dpar="ndt"),
- set_prior("normal(0,2.5)", class = "b", coef = "pred_norm", dpar="ndt"),
- set_prior("normal(0,2.5)", class = "b", coef = "cong_dev:pred_norm", dpar="ndt"),
- # STANDARD DEVIATIONS OF RANDOM EFFECT DISTRIBUTIONS
- set_prior("student_t(3, 0, 2)", class = "sd"),
- set_prior("student_t(3, 0, 2)", class = "sd", dpar="sigma"),
- set_prior("student_t(3, 0, 2)", class = "sd", dpar="ndt")
- )
- # Fit model
- m_bme <- brm(
- brmsformula(
- rt ~ 0 + Intercept + cong_dev * pred_norm +
- (cong_dev * pred_norm | subj_id) +
- (cong_dev | image) +
- (1 | string),
- sigma ~ 0 + Intercept + cong_dev * pred_norm +
- (cong_dev * pred_norm | subj_id) +
- (cong_dev | image) +
- (1 | string),
- ndt ~ 0 + Intercept + cong_dev * pred_norm +
- (cong_dev * pred_norm | subj_id) +
- (cong_dev | image) +
- (1 | string)
- ),
- data = dat_rt,
- family = shifted_lognormal(),
- prior = priors,
- inits = "0",
- iter = n_iter,
- warmup = n_warmup,
- chains = n_chains,
- control = list(
- adapt_delta = adapt_delta,
- max_treedepth = max_treedepth
- ),
- sample_prior = "no",
- silent = TRUE,
- cores = n_cores,
- seed = seed,
- thin = 1,
- file = file.path("mods", "m_bme.rds")
- )
|