Skip to content

Stop spurious NA R-hat warnings from estimate_secondary - #1516

Merged
sbfnk merged 2 commits into
mainfrom
fix-secondary-rhat-monitoring
Sep 2, 2026
Merged

Stop spurious NA R-hat warnings from estimate_secondary#1516
sbfnk merged 2 commits into
mainfrom
fix-secondary-rhat-monitoring

Conversation

@sbfnk-bot

@sbfnk-bot sbfnk-bot commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Description

This PR closes #1497.

The remaining case of that issue was estimate_secondary(), which still emitted the spurious The largest R-hat is NA, indicating chains have not mixed. warning (plus the accompanying near-zero-ESS warnings) for both chains. estimate_infections() (#1499) and estimate_truncation() (#1501) were already handled; secondary was never covered because the monitoring-exclusion in create_stan_args() was gated on identical(model, "estimate_infections").

Reproducing fit_secondary_fixed from the prior choice guide, the only parameters with NA R-hat are delay_np_pmf_use[1..31], the structurally-constant nonparametric delay PMF, which is the same quantity already excluded for estimate_infections. Every real parameter is well converged. This PR extends the exclusion to estimate_secondary so that quantity is no longer monitored, which removes the spurious NA R-hat (verified: 0 NA-R-hat parameters afterwards).

It also bumps the prior choice guide's MCMC settings from samples = 100, warmup = 100 to samples = 500, warmup = 250. At 100 samples the genuine Bulk/Tail ESS warnings appear across the guide's fits simply because 100 post-warmup draws is too few (for estimate_secondary, 54 to 85 of 115 real parameters fell below an ESS of 100). At 500/250 those fits converge cleanly (0 real parameters below ESS 100, max R-hat 1.01) at roughly 8 s per secondary fit. The baked prior_choice_guide.Rmd is regenerated by the render-prior_choice_guide.yaml workflow, which fires on push to main when the .orig changes, so it is not committed here.

Initial submission checklist

  • My PR is based on a package issue and I have explicitly linked it.
  • I have tested my changes locally.
  • I have added or updated unit tests where necessary.
  • I have updated the documentation if required and rebuilt docs if yes.
  • I have followed the established coding standards.
  • I have added a news item linked to this PR.

sbfnk-bot and others added 2 commits September 1, 2026 09:47
Co-authored-by: sbfnk <sebastian.funk@lshtm.ac.uk>
Co-authored-by: sbfnk <sebastian.funk@lshtm.ac.uk>
@sbfnk-bot
sbfnk-bot requested a review from sbfnk September 1, 2026 08:47
Comment thread R/create.R
@sbfnk
sbfnk marked this pull request as ready for review September 1, 2026 10:12
@sbfnk

sbfnk commented Sep 2, 2026

Copy link
Copy Markdown
Member

merging as minimal change to output

@sbfnk
sbfnk merged commit 6bccf43 into main Sep 2, 2026
13 checks passed
@sbfnk
sbfnk deleted the fix-secondary-rhat-monitoring branch September 2, 2026 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rstan monitors deterministic internal quantities, producing spurious R-hat/ESS warnings

2 participants