Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test convolve mode in hospitaladmissionspy #398

Merged
merged 25 commits into from
Aug 26, 2024
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
65b248e
testing convolve mode
sbidari Aug 20, 2024
8d66ef8
Merge branch 'main' of https://github.com/CDCgov/multisignal-epi-infe…
sbidari Aug 20, 2024
17107c2
Merge branch 'main' into 385-incorrect-convolve-mode-in-hospitaladmis…
sbidari Aug 21, 2024
3a54855
update tutorial to work with convolve mode valid
sbidari Aug 21, 2024
399250f
Merge branch 'main' into 385-incorrect-convolve-mode-in-hospitaladmis…
sbidari Aug 21, 2024
9a7cbb3
update latent admissions test
sbidari Aug 21, 2024
cbff93c
update DOW tutorial for convolve mode valid
sbidari Aug 21, 2024
41b070f
update hosp model tests
sbidari Aug 21, 2024
e9130ce
create helper function for convolve and add tests
sbidari Aug 21, 2024
4737288
forgot to run precommit earlier
sbidari Aug 21, 2024
eb9e168
Merge branch 'main' into 385-incorrect-convolve-mode-in-hospitaladmis…
sbidari Aug 21, 2024
e87d742
update test for model with DOW effect
sbidari Aug 21, 2024
999d124
Merge branch 'main' of https://github.com/CDCgov/PyRenew into 385-inc…
sbidari Aug 22, 2024
b4c5ca2
renaming helper function, add n_initialization_point
sbidari Aug 22, 2024
6840243
Merge branch 'main' of https://github.com/CDCgov/PyRenew into 385-inc…
sbidari Aug 22, 2024
ed19002
Apply suggestions from code review
sbidari Aug 22, 2024
0599cfc
Merge branch 'main' into 385-incorrect-convolve-mode-in-hospitaladmis…
sbidari Aug 22, 2024
9095259
move helper function from metaclass to convolve.py
sbidari Aug 23, 2024
c69d6cc
uniformize starting point of all plots
sbidari Aug 23, 2024
c28ec02
adopt new var names
sbidari Aug 23, 2024
4bc1736
fix var names
sbidari Aug 23, 2024
ea72333
fix docstring
sbidari Aug 23, 2024
5c4395f
update n_initialization_points
sbidari Aug 23, 2024
554301b
Update pyrenew/convolve.py
damonbayer Aug 26, 2024
3efcfad
Update pyrenew/convolve.py
damonbayer Aug 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions pyrenew/convolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ def _new_scanner(


def compute_delay_ascertained_incidence(
incidence_to_observation_rate: ArrayLike,
p_observed_given_incident: ArrayLike,
latent_incidence: ArrayLike,
incidence_to_observation_delay_interval: ArrayLike,
delay_incidence_to_observation_delay_pmf: ArrayLike,
damonbayer marked this conversation as resolved.
Show resolved Hide resolved
damonbayer marked this conversation as resolved.
Show resolved Hide resolved
) -> ArrayLike:
"""
Computes incidences observed according
Expand All @@ -179,21 +179,21 @@ def compute_delay_ascertained_incidence(

Parameters
----------
incidence_to_observation_rate: ArrayLike
The rate at which latent incident counts translated into observed counts.
For example, setting ``incidence_to_observation_rate=0.001``
p_observed_given_incident: ArrayLike
The rate at which latent incident counts translate into observed counts.
For example, setting ``p_observed_given_incident=0.001``
when the incident counts are infections and the observed counts are
reported hospital admissions could be used to model disease and population
for which the probability (reported) hospital.admission given infection is
sbidari marked this conversation as resolved.
Show resolved Hide resolved
0.001.
latent_incidence: ArrayLike
Incidence values based on the true underlying process.
incidence_to_observation_delay_interval: ArrayLike
delay_incidence_to_observation_delay_pmf: ArrayLike
Probability mass function of delay interval from incidence to observation,
where the :math`i^{th}` entry (0-indexed) represents a delay of :math:`1+i`
time units, i.e. ``incidence_to_observation_delay_interval[0]`` represents
time units, i.e. ``delay_incidence_to_observation_delay_pmf[0]`` represents
the fraction of observations that are delayed 1 time unit,
``incidence_to_observation_delay_interval[1]`` represents the fraction
``delay_incidence_to_observation_delay_pmf[1]`` represents the fraction
that are delayed 2 time units, et cetera.

Returns
Expand All @@ -202,8 +202,8 @@ def compute_delay_ascertained_incidence(
The predicted timeseries of delayed observations.
"""
delay_obs_incidence = jnp.convolve(
incidence_to_observation_rate * latent_incidence,
incidence_to_observation_delay_interval,
p_observed_given_incident * latent_incidence,
delay_incidence_to_observation_delay_pmf,
mode="valid",
)
return delay_obs_incidence