# Comparing loo for two complex multivariate models with large data

**URL:** <https://discourse.mc-stan.org/t/comparing-loo-for-two-complex-multivariate-models-with-large-data/18186>\
**Category:** brms\
**Tags:** loo\
**Created:** [September 24, 2020, 3:53pm UTC](https://discourse.mc-stan.org/t/comparing-loo-for-two-complex-multivariate-models-with-large-data/18186 "2020-09-24T15:53:04Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![htrier](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/htrier/32/9397_2.png) [@htrier](https://discourse.mc-stan.org/u/htrier)\
**Post date:** [September 29, 2020, 11:48am UTC](https://discourse.mc-stan.org/t/comparing-loo-for-two-complex-multivariate-models-with-large-data/18186/7 "2020-09-29T11:48:37Z")

</div>

Thanks, I’ve made a reproducible example that replicates the error from [this post](https://discourse.mc-stan.org/t/comparing-complex-multivariate-models-with-loo-compare/18071) (`Moment matching failed`), although I haven’t been able to replicate the invalid model error. But this is essentially what I’m trying to do:

```
# R version 4.0.2
library(loo)#version 2.3.1.9000
library(brms)#version 2.13.9
library(dplyr)

df <- mtcars
df <- mutate(df,ID=c(1:nrow(df)))
f1 = brmsformula('mpg~1+wt+cyl+hp+(1+wt+cyl+hp|ID)')
f2 = brmsformula('qsec~1+wt+cyl+hp+(1+wt+cyl+hp|ID)')
f3 = brmsformula('mpg~1+wt+cyl+(1+wt+cyl|ID)')
f4 = brmsformula('qsec~1+wt+cyl+(1+wt+cyl|ID)')
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)

loo1 <- brms::loo(model_of_interest, moment_match=TRUE)
loo2 <- brms::loo(null_model, moment_match=TRUE)
```

---

_[View the full topic](https://discourse.mc-stan.org/t/comparing-loo-for-two-complex-multivariate-models-with-large-data/18186)._
