# Error in validate\_ll(log\_ratios) when caculating loo

**URL:** <https://discourse.mc-stan.org/t/error-in-validate-ll-log-ratios-when-caculating-loo/27236>\
**Category:** Interfaces\
**Tags:** loo\
**Created:** [April 23, 2022, 12:32pm UTC](https://discourse.mc-stan.org/t/error-in-validate-ll-log-ratios-when-caculating-loo/27236 "2022-04-23T12:32:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zcai](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/zcai/32/10242_2.png) [@zcai](https://discourse.mc-stan.org/u/zcai)\
**Post date:** [April 23, 2022, 12:32pm UTC](https://discourse.mc-stan.org/t/error-in-validate-ll-log-ratios-when-caculating-loo/27236/1 "2022-04-23T12:32:45Z")

</div>

Hello,

I got an error `Error in validate_ll(log_ratios) : All input values must be finite.` when calculating loo using matrix method `loo(LLmat, r_eff = rel_n_eff, cores = cores, save_psis = FALSE)`. It seems related to the logarithm of the sum of two densities according to [Fixed a numerical issue in split\_moment\_matching by topipa · Pull Request #153 · stan-dev/loo · GitHub](https://github.com/stan-dev/loo/pull/153) and [Error in loo(stanfit, moment\_match=TRUE) · Issue #852 · stan-dev/rstan · GitHub](https://github.com/stan-dev/rstan/issues/852). Howerver, I am not using moment matching. Is it possible that the modification in [Fixed a numerical issue in split\_moment\_matching by topipa · Pull Request #153 · stan-dev/loo · GitHub](https://github.com/stan-dev/loo/pull/153) should have been applied to all loo function? or I am just simply making another mistake? Thanks a lot

---

<div class="post-metadata">

**Author:** ![avehtari](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/avehtari/32/5935_2.png) [@avehtari](https://discourse.mc-stan.org/u/avehtari)\
**Post date:** [April 24, 2022, 8:58am UTC](https://discourse.mc-stan.org/t/error-in-validate-ll-log-ratios-when-caculating-loo/27236/2 "2022-04-24T08:58:32Z")

</div>

> [@zcai](#):
>
> I got an error `Error in validate_ll(log_ratios) : All input values must be finite.` when calculating loo using matrix method `loo(LLmat, r_eff = rel_n_eff, cores = cores, save_psis = FALSE)` .

Have you checked that LLmat doesn’t have non-finite values? Can you provide that matrix and rel\_n\_eff, so I can test?

---

<div class="post-metadata">

**Author:** ![zcai](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/zcai/32/10242_2.png) [@zcai](https://discourse.mc-stan.org/u/zcai)\
**Post date:** [April 24, 2022, 9:57pm UTC](https://discourse.mc-stan.org/t/error-in-validate-ll-log-ratios-when-caculating-loo/27236/3 "2022-04-24T21:57:45Z")

</div>

Sure, honestly I didn’t save the csv file of this model fit. I looped 100 times the model fitting and loo for almost 8h so far, until now there is no error :( However, when I tested the code yesterday, this error happened around 3 times. Maybe there were some silly mistakes in my code. I will keep testing and save LLmat next time I see this error and send it here. Thanks
