Please share your Stan program and accompanying data if possible.
I am trying to use add_criterion() to add “loo” to a model created with brm(), so that I can use loo_compare() to compared models. add_criterion() appears to run (it takes awhile as the model is complex, and the time that the .rds file was modified shows that it was modified), but when I apply loo_compare(), it throws an error stating that the model doesn’t contain a precomputed “loo” criterion. I have used save_pars = save_pars(all = TRUE) when I first constructed the model. The code for producing the model and adding the criterion are both pasted below.
Here’s the code for producing the model:
b5TestStepxVwlxSpkrGndrVwlxLsnrGndrCO_27mar26 ← brm(data = b5Test,
family = bernoulli,
prior = priors,
formula = shRsp \~ recodeStep +
vowel \* recodeSpeaker \* recodeGender \* zConscitientiousness +
vowel \* recodeListenerGender \* zConscitientiousness +
(1 + recodeStep +
vowel:recodeSpeaker +
vowel:recodeGender +
recodeSpeaker:recodeGender +
vowel:recodeSpeaker:recodeGender| uniqueParticipant),
warmup = 1000, iter = 5000, chains = 4, cores = 4, threads = threading(4),
save_pars = save_pars(all = TRUE),
control = list(adapt_delta = 0.99,
max_treedepth = 15),
seed = 101457,
file = "b5TestStepxVwlxSpkrGndrVwlxLsnrGndrCO_27mar26 ",
file_refit = “on_change”)
And here’s the code for adding the criterion.
options(mc.cores = 1)
brms::add_criterion(b5TestStepxVwlxSpkrGndrVwlxLsnrGndrCO_27mar26, criterion = c(“loo”), pointwise = TRUE, overwrite = TRUE)