I am having an issue running brms::kfold() after running a brms fit object with cmdrstan backend (and threads), saving and then reloading from file. A reproducible example:
library(brms) data("epilepsy") m <- brm(formula = count ~ 1 + (1|patient), data = epilepsy, backend = "cmdstanr", threads = threading(2), file = "m.Rds") #restart R or exit and reopen R #reload brms library(brms) m <- readRDS("m.Rds") kfold(m) Fitting model 1 out of 10 Fitting model 2 out of 10 Fitting model 3 out of 10 Fitting model 4 out of 10 Fitting model 5 out of 10 Fitting model 6 out of 10 Fitting model 7 out of 10 Fitting model 8 out of 10 Fitting model 9 out of 10 Fitting model 10 out of 10 Start sampling Error: Model not compiled. Try running the compile() method first.
The issue here is that my brmsfit objects must be loaded from file as they are not run on my machine.
Any tips/tricks/workarounds would be greatly appreciated!
Thanks in advance!
- Operating System: macOS catalina
- R version 4.0.3
- brms Version: 2.16.2