Posterior Predictions with a Wiener model - very slow?

Hello,

Does anybody have any advice on generating predictions from a BRMS model with a Wiener distribution? When I try, the process seems very slow. It could be that my own intuition is very wrong, and everything is fine, but I thought it would be good to double check I’m not doing something dumb!

At the moment I am using the tidybayes package.

The dataset I use to fit the model has 22k rows (data from a psychology experiment)
I am aggregating over repetitions before running the predictions, which reduces the amount of data to 2.3k rows.

If I run the below (with n = 1), the code takes around 6 seconds to run, and the predicted values look quite nice when compared to the empirical median reaction time.

start_time <- Sys.time()

d %>% group_by(id, bk, co, st) %>%
  summarise(median_rt = median(rt),
            mean_resp = mean(resp),
            .groups = "drop") %>%
  add_predicted_draws(m,
                      re_formula = NULL,
                      n = 1,
                      negative_rt = TRUE,
                      prediction = "prt") %>%
  select(-.chain, -.iteration, -.draw) -> p

print(Sys.time() - start_time)

Although, if I then rm(p) and rerun the code, it takes much longer. On the last try, I hit the stop button after waiting for 2 minutes! Restarting R and running again leads to 11 seconds to run the code.

Ideally, I think I want to run the above with higher n.

My PC has 16GB RAM and is running Windows.

If it helps, the model formula is:

formula <- bf(rt | dec(resp) ~ 0 + bk:co:st + (0 + bk:co:st|p|id), 
              bs ~ 0 + bk:co + (0 + bk:co|p|id),
              bias ~ 0 + bk:co + (0 + bk:co|p|id),
              ndt ~ 1 + (1|p|id))

Thank you for your help

1 Like

This implies that you would expect to wait about 6 hours to get predictions for all 4000 posterior samples (which is the default). So waiting for 2 minutes doesn’t seem unexpected. Unfortunately, the prediction code in brms can be quite slow.

Best of luck with your model!