stan-dev / stan-dev/cmdstanr

During-sampling diagnostics (feature request & design discussion)

Open
#425 2 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
R
Stars
160
Forks
69
Avg merge
1d 19h
Merged PRs (30d)
15

Description

I propose to add optional computation of diagnostics during sampling.

To achieve this, I propose to read the csv files to:
(1) track the proportion of treedepth exceeded
(2) track whether any post-warmup divergences were encountered
(3) track the Bulk & Tail ESS of parameters (with option to specify which to include/exclude)
(4) track the Rhat of parameters (with option to specify which to include/exclude)

To enable efficient incremental parsing of the CSV files, I propose keeping track of how many lines have been read so far and skipping that many lines the next time a read is triggered, storing new samples together with prior samples in an object kept in memory.

To enable resuming this monitoring across R sessions, we could either start the csv parsing from scratch, or we could be writing the contents to a faster binary format (I'm thinking NetCDF) from the outset. This latter has the benefit of leaving the Stan output in a much better format than CSV. If we opted for this, I propose storing both the CSVs and NetCDF fils in a stan_scratch folder (n.b. said folder is involved in the proposed implementations of these FRs as well: Background/asynchronous sampling, Recompile only on changes to output of stanc3 auto-formatter )

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 reviewing the CSV parsing proposal and the related #424 and #423 discussions, then compare resuming from CSVs with writing NetCDF files in a stan_scratch folder. Done means an agreed design covers incremental diagnostics for treedepth, divergences, ESS, and Rhat, including parameter selection and cross-session monitoring.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.