Hi!
I want to compare multiple models with loo, but because many of the observations have a pareto_k > 0.7 I would like to use the moment match option. However, I have this error
loo1 <- brms::loo(fit)
loo1_mm <- brms::loo_moment_match(fit, loo1)
Error in .update_pars(x, upars = upars, ...) :
length(new_samples) == nrow(pars) is not TRUE
Error: Moment matching failed. Perhaps you did not set 'save_all_pars' to TRUE when fitting your model?
The code to fit the model is the following:
bformula <- bf(n_foraging | trials(n_total) ~ Habitat * Period
+ (Habitat|Id)
+ (Habitat|Trip_id))
bprior <- c(
set_prior("normal(0,0.5)", class = "Intercept"),
set_prior("normal(0,0.5)", class = "b"),
set_prior("cauchy(0,2)", class = "sd"),
set_prior("lkj(1)", class = "cor")
)
fit <- brm(bformula,
data = DT,
family = binomial,
prior = bprior,
sample_prior = TRUE,
save_all_pars = TRUE,
iter = 2000,
chains = 4,
cores = 4,
seed = 69,
control = list(adapt_delta = 0.85))
And here the dataset: data.csv (21.7 KB)
I know this error was previously reported and presumably fixed, but even after updating all packages I still have the error.
When fitting the model with brm I have this warning message. Just in case it is related to this error:
Argument 'save_all_pars' is deprecated. Please use argument 'all' in function 'save_pars()' instead
Thanks!
- Operating System: windows 10
- brms Version: 2.14.2
- loo Version: 2.3.1.9000
- R-4.0.3