Repository navigation
Refine AscertainmentModel component to allow for time-varying component - #897
cdc-mitzimorris wants to merge 75 commits into
Conversation
|
Thank you for your contribution @cdc-mitzimorris 🚀! Your github-pages is ready for download 👉 here 👈! |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The ascertainment tutorial references a nonexistent class and contains incorrect mathematical notation.
Review effort: Balanced
Findings: 3
Open (3)
What changed in this PR
Adds scalar and time-varying ascertainment processes, integrates them across models and observations, and expands documentation and tests.
Changes:
- Adds independent and temporal ascertainment APIs.
- Applies ascertainment after delay convolution.
- Adds extensive validation and integration coverage.
| File | Description |
|---|---|
pyrenew/ascertainment/base.py |
Centralizes sampling and validation. |
pyrenew/ascertainment/independent.py |
Adds independent ascertainment. |
pyrenew/ascertainment/joint.py |
Supports temporal deviations. |
pyrenew/ascertainment/linked.py |
Supports temporal deviations. |
pyrenew/ascertainment/__init__.py |
Exports the new class. |
pyrenew/convolve.py |
Adds delay-only convolution. |
pyrenew/observation/base.py |
Uses delay-only convolution. |
pyrenew/observation/count_observations.py |
Applies ascertainment after delay. |
pyrenew/model/multisignal_model.py |
Samples full-axis ascertainment. |
pyrenew/model/pyrenew_builder.py |
Documents updated integration. |
test/test_ascertainment.py |
Tests the new API. |
test/test_convolve.py |
Tests delay-only convolution. |
test/test_helpers.py |
Updates convolution helper usage. |
test/test_observation_counts.py |
Tests time-varying rates. |
test/test_pyrenew_builder.py |
Tests model integration. |
test/integration/conftest.py |
Configures independent ascertainment. |
test/integration/test_population_infections_he_weekly_joint_ascertainment.py |
Verifies joint baseline sites. |
test/integration/test_population_infections_he_weekly_ratio_linked_ascertainment.py |
Verifies linked baseline sites. |
docs/tutorials/ascertainment.qmd |
Documents ascertainment models. |
docs/tutorials/building_multisignal_models.qmd |
Updates convolution example. |
docs/tutorials/observation_processes_counts.qmd |
Explains revised ordering. |
docs/tutorials/observation_processes_measurements.qmd |
Updates convolution example. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #897 +/- ##
==========================================
+ Coverage 98.82% 98.85% +0.02%
==========================================
Files 58 59 +1
Lines 2128 2264 +136
==========================================
+ Hits 2103 2238 +135
- Misses 25 26 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
For a stronger end-to-end test than the integration test in this PR, I ran 4 PyRenew models using the time-varying IndividualAscertainment component on the NSSP (ED visit) signal on a grid of 2262 date/location/disease combinations for a 21-day forecast. the resulting CRPS scores were better than that of pyrenew-hew's E model on the same data. |
dylanhmorris
left a comment
There was a problem hiding this comment.
Thanks @cdc-mitzimorris. Reviewed the tutorial carefully and made some suggestions. Also think we should have a code examples for:
IndependentAscertainment(either/both fixed in time or time varying)- A case of time-varying dependent ascertainment
dylanhmorris
left a comment
There was a problem hiding this comment.
Many thanks @cdc-mitzimorris! Very excited for this. Had a few comments/questions/suggestions.
|
@dylanhmorris - ready for re-review. |

AscertainmentModelnow supports optional signal-specific temporal processes, combining scalar baselines with logit-scale deviations while centralizing validation, sampling, and deterministic outputs. The branch addsIndependentAscertainment, refactors joint and ratio-linked models around baseline sampling, and updates model/observation plumbing to apply scalar or full-axis ascertainment rates after delay convolution.MultiSignalModel/builder integration, including calendar-aligned temporal processes.Suggested review order:
joint.py, andlinked.py— review the concrete implementations.pyrenew_builder.py— trace sampling and model integration.convolve.py— verify how time-varying rates are applied after delay convolution.test/test_ascertainment.py, then observation/builder tests, and finish with the tutorial changes.