Skip to content

Conversation

@cdc-mitzimorris
Copy link
Collaborator

This PR adds work that was done in https://github.com/cdcent/cfa-pyrenew-hierarchical/pull/4 to PyRenew.

It adds the base observation process class, concrete implementations for Count processes and the abstract base class for Measurement processes, together with unit tests and two new tutorials for count and measurement observation processes respectively.

Once this PR and the work done in https://github.com/cdcent/cfa-pyrenew-hierarchical/pull/5 have been added to PyRenew, subsequent PRs will deprecate unused features and harmonize the documentation and tutorials.

@codecov
Copy link

codecov bot commented Dec 23, 2025

Codecov Report

❌ Patch coverage is 97.41379% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.13%. Comparing base (02446c5) to head (6dff8cd).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pyrenew/observation/noise.py 94.33% 3 Missing ⚠️
pyrenew/observation/count_observations.py 96.66% 2 Missing ⚠️
pyrenew/observation/measurements.py 94.73% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #644      +/-   ##
==========================================
+ Coverage   96.98%   97.13%   +0.15%     
==========================================
  Files          42       48       +6     
  Lines        1094     1326     +232     
==========================================
+ Hits         1061     1288     +227     
- Misses         33       38       +5     
Flag Coverage Δ
unittests 97.13% <97.41%> (+0.15%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
Copy link

github-actions bot commented Dec 23, 2025

Thank you for your contribution @pre-commit-ci[bot] 🚀! Your github-pages is ready for download 👉 here 👈!
(The artifact expires on 2026-01-05T15:18:42Z. You can re-generate it by re-running the workflow here.)

Count observation processes model the lag between infections and an observed outcome such as hospital admissions, emergency department visits, confirmed cases, or deaths.
Observed data can be aggregated or available as subpopulation-level counts, which are modeled by classes `Counts` and `CountsBySubpop`, respectively.

Count observation processes transform infections into expected observed counts by applying an ascertainment rate and convolving with a delay distribution.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Count observation processes transform infections into expected observed counts by applying an ascertainment rate and convolving with a delay distribution.
Count observation processes transform infections into predicted counts by applying an event probability and/or ascertainment rate and convolving with a delay distribution.


Count observation processes transform infections into expected observed counts by applying an ascertainment rate and convolving with a delay distribution.

The expected observations on day $t$ are:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The expected observations on day $t$ are:
The predicted observations on day $t$ are:

where:

- $I_{t-d}$ is the number of incident (new) infections on day $t-d$ (i.e., $d$ days before day $t$)
- $\alpha$ is the ascertainment rate (e.g., infection-hospitalization ratio)
Copy link
Collaborator

@dylanhmorris dylanhmorris Dec 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- $\alpha$ is the ascertainment rate (e.g., infection-hospitalization ratio)
- $\alpha$ is the rate of ascertained counts per infection (e.g., infection-to-hospital admission rate). This can model a mix of biological effects (e.g. some percentage of infections lead to hospital admissions, but not all) and reporting effects (e.g. some percentage of admissions that occur are reported, but not all).

- $p_d$ is the delay distribution from infection to observation, conditional on an infection leading to an observation
- $D$ is the maximum delay

Discrete observations are generated by sampling from a noise distribution—either Poisson or negative binomial—to model reporting variability.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Discrete observations are generated by sampling from a noise distribution—either Poisson or negative binomial—to model reporting variability.
Discrete observations are generated by sampling from a noise distribution—e.g. Poisson or negative binomial—to model reporting variability.

Discrete observations are generated by sampling from a noise distribution—either Poisson or negative binomial—to model reporting variability.
Poisson assumes variance equals the mean; negative binomial accommodates the overdispersion common in surveillance data.

**Note on terminology:** In real-world inference, infections are *latent* (unobserved) and must be estimated from observed data like hospital admissions. In this tutorial, we simulate the observation process by specifying infections directly and showing how they produce hospital admissions through convolution and sampling.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
**Note on terminology:** In real-world inference, infections are *latent* (unobserved) and must be estimated from observed data like hospital admissions. In this tutorial, we simulate the observation process by specifying infections directly and showing how they produce hospital admissions through convolution and sampling.
**Note on terminology:** In real-world inference, incident infections are typically a *latent* (unobserved) quantity and must be estimated from observed data like hospital admissions. In this tutorial, we simulate the observation process by specifying infections directly and showing how they produce hospital admissions through convolution and sampling.

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.

3 participants