Detect non-finite `log_lik` (`Inf` / `NaN`) and explicitely inform the user
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 68/100
Research direction
Start at the loo::loo() entry point and trace where the log_lik matrix is validated or passed into PSIS-LOO. Use the reproducible matrix containing +Inf to verify that non-finite values are clearly reported instead of silently producing NA estimates. Done means the user-facing behavior identifies the invalid log_lik values and the existing example no longer completes without that information.
Written by the indexing model from the issue text.
Description
Summary
If the pointwise log-likelihood matrix contains +Inf or NaN, loo::loo() currently completes without a clear error/warning and can return NA for elpd_loo.
Proposal
Before (or while) computing PSIS-LOO, check the log_lik matrix for non-finite values and message this clearly to the user.
Reproducible example
library(loo)
set.seed(1)
ll <- matrix(rnorm(400 * 20, -1, 0.5), 400, 20)
ll[1:5, 1] <- Inf
loo(ll)$estimates # elpd_loo is NA; no clear message that log_lik had +Inf
# Estimate SE
# elpd_loo NA NA
# p_loo NA NA
# looic NA NA
Context
Seen with truncated-normal log_lik from brms, where the truncation normalizer can underflow:
https://discourse.mc-stan.org/t/difficulty-adding-loo-criterion-to-longitudinal-truncated-normal-model/41447/12
Corresponding brms Issue: https://github.com/paul-buerkner/brms/issues/1899
- Dominant language
- R
- Stars
- 157
- Forks
- 38
- Avg merge
- 4d 16h
- Merged PRs (30d)
- 2
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from stan-dev/loo
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
-
Clean up issues Open
Difficulty 4/5 3-5 days Newbie friendliness 25/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
robjhyndman/forecast#1220 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
JamesHWade/deputy#192 ·
-
bug triage_needed
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
pharmaverse/rtables#1123 · 1 comment · 1 reaction ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100