stan-dev / stan-dev/rstan

Zero-length vectors in data cause unnecessary warning messages

Open
#160 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
1.1k
Forks
266
Avg merge
2h 56m
Merged PRs (30d)
1

Description

If you call rstan::optimizing and the data includes zero-length vectors, then you get warning messages saying "Warning in max(abs(x)) : no non-missing arguments to max; returning -Inf". This appears to be happening when rstan::optimizing calls rstan:::data_preprocess, in a test near the end of the function.

I know this is a minor issue, but spurious warning messages either (1) cause you to waste a lot of time tracking down their source, or (2) end up making you ignore all warning messages, even the important ones.

As mentioned in Stan issue #1435, the zero-length vector use case arises when you've created a model that has some optional parts.

Contributor guide

No contributing guide indexed for this repository

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 reproducing the warning with rstan::optimizing and a model whose data includes a zero-length vector. Inspect rstan:::data_preprocess, especially the test near the end of the function, and verify that the same call completes without the spurious max(abs(x)) warning.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.