You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can execute parallel sampling for multiple chains with brm() without issues. However, when I try to use future with kfold() or brm_multiple() I get errors.
library(brms)
library(future)
plan(multiprocess(workers = 4))
bprior1 <- prior(student_t(5,0,10), class = b) +
prior(cauchy(0,2), class = sd)
# this works
fit1 <- brm(count ~ zAge + zBase * Trt + (1|patient),
data = epilepsy, family = poisson(), prior = bprior1, future = T)
# this doesn't
kf <- kfold(fit1, chains = 1, K = 5, future = T)
library(mice)
imp <- mice(nhanes2)
# neither does this
fit_imp1 <- brm_multiple(bmi~age+hyp+chl, data = imp, chains = 1, future = T)
The error that I receive from kfold() is:
Fitting model 1 out of 5
Start sampling
failed to create the sampler; sampling not done
Error in rstan::sflist2stanfit(fits) :
The following elements of 'sflist' do not contain samples: 1.
The error I receive from brm_multiple() is:
Compiling the C++ model
Start sampling
Error in rstan::sflist2stanfit(fits) :
'sflist' should have at least 1 element
I'm using the development version of brms, but I'm attaching the session info to help:
I've also noticed that I have to set future = T in each function, unlike the examples in the help files for each function, in case that helps identify the cause of the errors.
The text was updated successfully, but these errors were encountered:
Both kfold and brm_multiple have future automatically activated to run models in parallel, while brm can run chains in parallel if future = TRUE. That is you have two layers of futures on top of each other for the former two functions if you also activate future in brm. I am not sure how future handles this situation exactly, but it is definitely built to deal with it (and it's surely documended somewhere). kfold has future implemented only on the loo-compare branch of brms, which will be merged in a few days. That's why it is not working on the master branch currently.
That said, there was also a bug in how brm runs models if future = TRUE and chains = 0, which is necessary in kfold and brm_multiple. This should be fixed now.
Fantastic, thanks for clearing that up. This is my first time using future for parallelization, so I didn't realize that doubling up could cause issues like that. Thanks!
I can execute parallel sampling for multiple chains with
brm()
without issues. However, when I try to usefuture
withkfold()
orbrm_multiple()
I get errors.The error that I receive from
kfold()
is:The error I receive from
brm_multiple()
is:I'm using the development version of
brms
, but I'm attaching the session info to help:I've also noticed that I have to set
future = T
in each function, unlike the examples in the help files for each function, in case that helps identify the cause of the errors.The text was updated successfully, but these errors were encountered: