I am fairly new to bayesian model, so apologies if my question is naive. I am trying to fit a Bayesian linear model on my data as follows
# formulas
formulas <- brmsformula(RT ~ condition*primetype*experiment + (1|target) + (1|subj),
beta ~ condition*primetype*experiment + (1|target) + (1|subj),
family=exgaussian(), decomp="QR")
# modelling
bay_fit <- brm(
formula = formulas,
data = data_full_corr,
family = exgaussian(),
prior = c(
prior(normal(0, 100), class = "b"),
prior(normal(0, 100), class = "b", dpar = "beta")
),
cores = getOption("mc.cores", 4),
thin = 2,
chains = 4, # Number of MCMC chains to run at the same time
iter = 5000, # Total iterations per chain (including warmup)
warmup = 1000, # Number of warmup iterations (discarded for posterior inference)
seed = 42, # Random seed for reproducibility of MCMC sampling
init = 0.01, # set the initial values for the sampler
control = list(adapt_delta = 0.99, max_treedepth = 15), # Increased adapt_delta and max_treedepth to prevent divergences
file = 'brm_frequency-att'
)
The issue is that the program gets stuck at the first iterations for hours. This attempt in particular is being stuck at the first iterations for roughly 10 hours. The data is huge (~200,000 observations), so it might be the cause, but I just wanted to make sure everything is all set up properly. (When drastically reducing the iterations (e.g., to 500 for each chain), the model did go through, but did not reach convergence. I also tried to set the iterations at 2000, but it would still take this long.)
One more thing I noticed is that the time expectations when the program starts sampling increase at every run of ‘brm()’. The only way for me to decrease those expectations is to restart the laptop. Is this normal?
Many thanks in advance!
Operating System: macOS 15.5 ~ R 4.4.2 ~ RStudio 2025.05
In addition to setting more informative priors, as @spinkney suggests, I would also suggest trying a simpler model specification.
The first line of your formula corresponds to effects on the mean of the ex-Gaussian distribution, \mu, which is given by the mean of the Gaussian component \xi and the mean (inverse rate) of the exponential component \beta.
Then, you additionally model effects on the mean of the exponential component \beta. I suspect that those effects on \mu and \beta would be quite strongly correlated with each other. Also, there’s some work suggesting that the ex-Gaussian parameters (i.e., Gaussian mean \xi and SD \sigma, and exponential mean \beta) do not have clear psychological interpretations.
So taken together, you might want to consider dropping the line in your model formula with effects on \beta.
In terms of speeding up, you could also look into within-chain parallelization, assuming you have more CPU cores available than what you’re currently specifying in the cores input argument.
Side note: You’re specifying thin = 2, but thinning is generally discouraged in Stan, unless you’re running into memory problems.
Thank you for the very appropriate reference! All I am trying to do is to run a model on my data to separate components of the diffusion model, so if it’s unclear whether the ex-Gaussian parameters can have a psychological interpretation, it would certainly defeat the purpose of such a model!
I tried to do that too, but it’s not helping.
I have just found in another post the link to @Solomon’s interesting post on setting up inits, so I will try to see if that helps a bit.