Skip to content

Conversation

@sbfnk
Copy link
Contributor

@sbfnk sbfnk commented Nov 25, 2025

Description

This PR closes #1181.

The trunc_rev_cmf vector in estimate_secondary.stan was declared with dimension delay_type_max[trunc_id] but the get_delay_rev_pmf() function call requests delay_type_max[trunc_id] + 1 elements, causing a dimension mismatch.

This fix aligns estimate_secondary.stan with the four other Stan files that correctly include + 1 in both the declaration and function call:

  • estimate_infections.stan
  • simulate_infections.stan
  • simulate_secondary.stan
  • estimate_truncation.stan

Initial submission checklist

  • My PR is based on a package issue and I have explicitly linked it.
  • I have tested my changes locally (using devtools::test() and devtools::check()).
  • I have added or updated unit tests where necessary.
  • I have updated the documentation if required and rebuilt docs if yes (using devtools::document()).
  • I have followed the established coding standards (and checked using lintr::lint_package()).
  • I have added a news item linked to this PR.

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Fixed incorrect dimension declaration in truncation delay calculations that was causing a mismatch when retrieving delay distributions. The delay probability mass function vector now correctly extends to accommodate all required bins in the truncation pathway.

✏️ Tip: You can customize this high-level summary in your review settings.

The vector declaration for trunc_rev_cmf was missing the + 1 that other
Stan files include, causing a dimension mismatch with get_delay_rev_pmf().

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 25, 2025

Walkthrough

A dimension mismatch bug in the truncation pathway of estimate_secondary.stan is fixed by updating the trunc_rev_cmf vector declaration to include + 1, aligning with the get_delay_rev_pmf() function call and matching the pattern used in other Stan files.

Changes

Cohort / File(s) Summary
Dimension mismatch fix in truncation kernel
NEWS.md, inst/stan/estimate_secondary.stan
Updated trunc_rev_cmf vector declaration from delay_type_max[delay_id_truncation] to delay_type_max[delay_id_truncation] + 1 to match the len argument passed to get_delay_rev_pmf(), resolving a dimension mismatch. Added corresponding bug fix entry to NEWS.md.

Suggested reviewers

  • seabbs

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarises the main change: fixing a dimension mismatch in the truncation PMF vector in estimate_secondary.stan file.
Linked Issues check ✅ Passed The PR fulfils all coding requirements from issue #1181: the trunc_rev_cmf vector declaration now includes +1 to match the get_delay_rev_pmf function call, aligning with other Stan files.
Out of Scope Changes check ✅ Passed All changes are within scope: the PR updates estimate_secondary.stan to fix the dimension mismatch and adds a NEWS.md entry documenting the bug fix.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/1181-trunc-rev-cmf-dimension

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sbfnk sbfnk enabled auto-merge November 25, 2025 09:08
@github-actions
Copy link
Contributor

Thank you for your contribution sbfnk 🚀! Your synthetic_recovery markdown is ready for download 👉 here 👈!
(The artifact expires on 2025-11-30T09:10:07Z. You can re-generate it by re-running the workflow here.)

@github-actions
Copy link
Contributor

This is how benchmark results would change (along with a 95% confidence interval in relative change) if f2aa04a is merged into main:
Further explanation regarding interpretation and methodology can be found in the documentation.

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.

Fix dimension mismatch in truncation kernel declaration in estimate_secondary.stan

2 participants