I have run two complex multivariate models following this tutorial: Estimating Multivariate Models with brms. The models follow this format:
f1 = as.formula('y1~1+var1+var2+var3+(1+var1+var2+var3|GroupID)')
f2 = as.formula('y2~1+var1+var2+var3+(1+var1+var2+var3|GroupID)')
f3 = as.formula('y1~1+var1+var2+(1+var1+var2+|GroupID)')
f4 = as.formula('y2~1+var1+var2+(1+var1+var2+|GroupID)')
model_of_interest = brm(f1+f2,data=df,iter=6000,chains=4,cores=4,family="gaussian",control=list(adapt_delta=0.9),save_all_pars=TRUE)
null_model = brm(f3+f4,data=df,iter=6000,chains=4,cores=4,family="gaussian",control=list(adapt_delta=0.9),save_all_pars=TRUE)
and I now want to compute loo()
for each and compare using loo_compare()
. Using this tutorial as a guide Using the loo package (version >= 2.0.0) ā¢ loo, I compute loo
as follows:
loo1 <- loo(model_of_interest, moment_match=TRUE)
loo2 <- loo(null_model, moment_match=TRUE)
However, before I can enter this into loo_compare()
I get this error for both loo1
and loo2
:
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?
I am confused because I have definitely set save_all_pars=TRUE
in both model fits, and I canāt seem to find helpful guidance online about how to solve this. I am using R version 4.0.2. I appreciate any advice, thanks very much.