Run time issue with brms: Fitting a mixed-effects location-scale model

Hello,

I am new to using the brms package and am having difficulty running a mixed-effects location-scale model as outlined by Lester, Cullen-Lester, and Walters (2019). The code for my (final) model is as follows:

modelfinal <- bf(avoidc ~ 1 + dfs + rlength + (1 + dfs|ID1|user_id),
sigma ~ 1 + dfs + rlength + (1 + dfs|ID1|user_id))

modelfinal_out <- brm(modelfinal, data = explore1, 
chains = 4, cores = 4, iter = 5000,
control = list(adapt_delta = .85, max_treedepth = 15),
seed = 8712, save_all_pars = T)

I am following the build-up procedure outlined by Lester et al. (2019) starting with an empty model. The empty model (below) ran pretty quickly.

empty_mod <- bf(avoidc ~ 1 ,
sigma ~ 1 )

The random intercept model runs after about 30 minutes.

random_int <- bf(avoidc ~ 1 + (1 | user_id),
sigma ~ 1 )
random_int_out <- brm(random_int, data = explore1, chains = 4,
cores = 4, iter = 5000, control = list(adapt_delta = .85,
max_treedepth = 15),
seed = 186, save_all_pars = T)

As soon as I get to a more complex step (below), I cannot successfully get it to run (I allowed it to run for about 3 days).

random_ints_loc_scale <- bf(avoidc ~ 1 + (1 |ID1|user_id),
                              sigma ~ 1 + (1 |ID1|user_id))
  
random_ints_loc_scale_out <- brm(random_ints_loc_scale, data = explore1, 
                                   chains = 4, cores = 4, iter = 5000,
                                   control = list(adapt_delta = .85, 
                                                  max_treedepth = 15), seed = 4789, save_all_pars = T)

Finally, I tried my final model (the MELS) with only 100 iterations just to see if it would work and the below code did successfully run after about 10 hours.

modelfinal <- bf(avoidc ~ 1 + dfs + rlength + (1 + dfs|ID1|user_id),
sigma ~ 1 + dfs + rlength + (1 + dfs|ID1|user_id))

modelfinal_out <- brm(modelfinal, data = explore1,
chains = 4, cores = 4, iter = 100,
control = list(adapt_delta = .85, max_treedepth = 15),
seed = 8712, save_all_pars = T)

Since I hope to use iter = 5000, it seems like it is not feasible to use the brms package with the way things are going/how long it took for 100 iterations. I have tried specifying prior1 ā† c(prior(normal(0, 1), class = b)) and changing adapt_delta to .90 based on posts Iā€™ve read. Neither seemed to help.

I am really excited about the possibility of doing these analyses but feel lost at what to do at this point. Iā€™m not sure whether the model will never run, or if it is worth trying to wait many days. Iā€™m also not sure whether it would be worth trying to run the code on a different computer (like borrowing someoneā€™s desktop versus my laptop) or to specify additional informative priors to try to cut down the run time (if so, any suggestions for how to select priors for MELS models would be great). The dataset I am using does have 11,423 observations nested within 1402 people, and I am willing to wait many hours for it to run. However, as a graduate student, I unfortunately have to run the analyses before a deadline and need to decide whether to pursue a different project.

Any help or advice would truly be greatly appreciated! Also, if you spot something wrong with my code or have an idea about something that might be causing this issue (with the data, etc.), please let me know.

Thank you so much!

1 Like

Hi and welcome to the community! Sorry for the long waitā€¦ :)

Itā€™s a bit strange that you have increased max_treedepth so much. Could you provide some data so we can reproduce this? It sounds like the model is misspecified but itā€™s hard to tell. What does Rhat, effective sample size, traceplots, etc. tell you?

3 Likes

See here for code implementing a location-scale model in Stan with some tricks to speed things up. Youā€™ll need to remove the bits associated with the secondary binomial outcome, but hopefully thatā€™s pretty straightforward.

Thank you so much for your reply! :) I really appreciate your help. I cannot unfortunately provide data at the moment due to some technical difficulties, but I will take a closer look at the Rhat, effective sample size, and traceplots as soon as things are working again. I had selected max_treedepth based on the values chosen in the example provided by Lester, Cullen-Lester, and Walters (2019), but now after reading more about the argument, it seems like this high of a value should not be necessary. Thank you for bringing that to my attention.

Thank you so much for providing me with this code! I really appreciate it. I will definitely give it a shot.

1 Like