stan-dev / stan-dev/loo

"Error in if (varx == 0) { : missing value where TRUE/FALSE needed" with fit$loo() but not loo::loo(fit$draws("log_lik"))

Open
#272 16 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
157
Forks
38
Avg merge
4d 16h
Merged PRs (30d)
2

Description

Hi,

Unfortunately I don't have a reproducible example because this is just popping up with a few versions of a big model. When I fit the model with cmdstanr, the following works:

> loo::loo(fit_mvn$draws("log_lik"))

Computed from 400 by 590 log-likelihood matrix.

         Estimate     SE
elpd_loo -31300.8 3489.9
p_loo       323.5   14.9
looic     62601.5 6979.8
------
MCSE of elpd_loo is NA.
MCSE and ESS estimates assume independent draws (r_eff=1).

Pareto k diagnostic values:
                          Count Pct.    Min. ESS
(-Inf, 0.62]   (good)     367   62.2%   37      
   (0.62, 1]   (bad)      177   30.0%   <NA>    
    (1, Inf)   (very bad)  46    7.8%   <NA>    
See help('pareto-k-diagnostic') for details.

But this doesn't:

> fit_mvn$loo()
Error in if (varx == 0) { : missing value where TRUE/FALSE needed

I checked and there's no NAs anywhere:

> fit_mvn$draws("log_lik") |> anyNA()
[1] FALSE

Does anyone have any idea? Sorry I can't be more helpful with reproducible code. I'd be happy to share the Stan program with simulation file.

Thanks,

Matt

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing the fit$loo() entry point with loo::loo(fit$draws("log_lik")), using the reported error and the 400-by-590 log-likelihood matrix as the reference case. Reproduce the discrepancy with the Stan program and simulation file if they are shared, then verify that both entry points handle this input consistently without the missing-value error.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.