Skip to content

Commit 9ec062a

Browse files
Standardize observation process equation notation between READMEs and tutorials. (#715)
* update observation process tutorials * Update docs/tutorials/observation_processes_measurements.qmd --------- Co-authored-by: Dylan H. Morris <dylanhmorris@users.noreply.github.com>
1 parent fb69f1b commit 9ec062a

2 files changed

Lines changed: 13 additions & 15 deletions

File tree

docs/tutorials/observation_processes_counts.qmd

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,13 @@ Count observation processes transform infections into predicted counts by applyi
3636

3737
The predicted observations on day $t$ are:
3838

39-
$$\lambda_t = \alpha \cdot \sum_{d=0}^{D} I_{t-d} \cdot p_d$$
39+
$$\mu(t) = \alpha \sum_{s} I(t-s) \, \pi(s)$$
4040

4141
where:
4242

43-
- $I_{t-d}$ is the number of incident (new) infections on day $t-d$ (i.e., $d$ days before day $t$)
43+
- $I(t-s)$ is the number of incident (new) infections on day $t-s$ (i.e., $s$ days before day $t$)
4444
- $\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).
45-
- $p_d$ is the delay distribution from infection to observation, conditional on an infection leading to an observation
46-
- $D$ is the maximum delay
45+
- $\pi(s)$ is the delay distribution from infection to observation, conditional on an infection leading to an observation
4746

4847
Discrete observations are generated by sampling from a noise distribution—e.g. Poisson or negative binomial—to model reporting variability.
4948
Poisson assumes variance equals the mean; negative binomial accommodates the overdispersion common in surveillance data.
@@ -53,11 +52,11 @@ Poisson assumes variance equals the mean; negative binomial accommodates the ove
5352
## Hospital admissions example
5453

5554
For hospital admissions data, we construct a `Counts` observation process.
56-
The delay is the key mechanism: infections from $d$ days ago ($I_{t-d}$) contribute to today's hospital admissions ($\lambda_t$) weighted by the probability ($p_d$) that an infection leads to hospitalization after exactly $d$ days. The convolution sums these contributions across all past days.
55+
The delay is the key mechanism: infections from $s$ days ago ($I(t-s)$) contribute to today's expected hospital admissions ($\mu(t)$) weighted by the probability ($\pi(s)$) that an infection leads to hospitalization after exactly $s$ days. The convolution sums these contributions across all past days.
5756

5857
The process generates hospital admissions by sampling from a negative binomial distribution:
5958

60-
$$Y_t \sim \text{NegativeBinomial}(\mu = \lambda_t, \text{concentration} = \phi)$$
59+
$$Y_t \sim \text{NegativeBinomial}(\text{mean} = \mu(t), \text{concentration} = \phi)$$
6160

6261
The concentration parameter $\phi$ (sometimes called $k$ or the dispersion parameter) controls overdispersion: as $\phi \to \infty$, the distribution approaches Poisson; smaller values allow greater overdispersion.
6362

docs/tutorials/observation_processes_measurements.qmd

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,11 @@ The `Measurements` class models continuous signals derived from infections. Unli
4545

4646
All measurement observation processes follow the same pattern:
4747

48-
$$\text{observed} \sim \text{Noise}\bigl(\text{predicted}(\text{infections})\bigr)$$
48+
$$y_t \sim \text{Noise}(\mu(t))$$
4949

50-
where:
50+
where $\mu(t)$ is the predicted measurement value on day $t$, computed from infections via a domain-specific transformation, and the noise model adds stochastic variation around predictions.
5151

52-
1. **`_predicted_obs(infections)`**: Transforms infections into predicted measurement values (you implement this)
53-
2. **Noise model**: Adds stochastic variation around predictions (provided by PyRenew)
52+
Subclasses implement `_predicted_obs()` to compute $\mu(t)$ from infections. PyRenew provides the noise model.
5453

5554
The `Measurements` base class provides:
5655

@@ -159,7 +158,7 @@ class MyMeasurement(Measurements):
159158
## Measurement Example: Wastewater
160159

161160
To illustrate the framework, we specify a wastewater viral concentration observation process,
162-
based on the [PyRenew-HEW](https://github.com/cdcgov/pyrenew-hew) family of models.
161+
based on the [PyRenew-HEW](https://github.com/cdcgov/pyrenew-multisignal) family of models.
163162

164163
**The wastewater signal**
165164

@@ -172,18 +171,18 @@ The predicted concentration depends on:
172171

173172
The predicted log-concentration on day $t$ is:
174173

175-
$$\log(\lambda_t) = \log\left(\frac{G}{V} \cdot \sum_{d=0}^{D} I_{t-d} \cdot p_d\right)$$
174+
$$\log(\mu(t)) = \log\left(\frac{G}{V} \cdot \sum_{s} I(t-s) \, \pi(s)\right)$$
176175

177176
where:
178177

179-
- $I_{t-d}$ is infections on day $t-d$
180-
- $p_d$ is the shedding kinetics PMF (fraction shed on day $d$ post-infection)
178+
- $I(t-s)$ is infections on day $t-s$
179+
- $\pi(s)$ is the shedding kinetics PMF (fraction shed on day $s$ post-infection)
181180
- $G$ is genome copies shed per infection
182181
- $V$ is wastewater volume per person per day
183182

184183
Observations are log-concentrations with normal noise:
185184

186-
$$y_t \sim \text{Normal}(\log(\lambda_t) + \text{sensor\_mode}, \text{sensor\_sd})$$
185+
$$y_t \sim \text{Normal}(\log(\mu(t)) + \text{sensor\_mode}, \text{sensor\_sd})$$
187186

188187
### Implementing the Wastewater class
189188

0 commit comments

Comments
 (0)