State-Centered Temporal Processes#828
Open
cdc-mitzimorris wants to merge 79 commits into
Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #828 +/- ##
==========================================
+ Coverage 98.61% 98.71% +0.10%
==========================================
Files 55 56 +1
Lines 2023 2182 +159
==========================================
+ Hits 1995 2154 +159
Misses 28 28
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
for more information, see https://pre-commit.ci
…v/PyRenew into mem_810_centered_parameterization
Collaborator
Author
|
ran the benchmarks on my machine - here are the results: |
…e time 0) (#827) * bug fix and unit tests * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * update unit test to match code * revert changes, apply simpler fix --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
for more information, see https://pre-commit.ci
…v/PyRenew into mem_810_centered_parameterization
for more information, see https://pre-commit.ci
…v/PyRenew into mem_810_centered_parameterization
for more information, see https://pre-commit.ci
Collaborator
Author
|
@dylanhmorris @sbidari ready for code review |
…v/PyRenew into mem_810_centered_parameterization
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added state-centered parameterizations for all three temporal-process
classes in
pyrenew.latent:AR1— stationary AR(1) on log-Rt levelsDifferencedAR1— AR(1) on first differences of log-Rt (the productionprocess)
RandomWalk— unconstrained drift on log-RtEach class now takes a constructor argument
parameterization: Literal["innovation", "state"], defaulting to"innovation"to preserve current behavior. Setting"state"switchesthe internal sampling from standardized increments to the latent state
path directly.
The state-centered variants are implemented via:
RandomWalk: NumPyro's built-indist.GaussianRandomWalk, shiftedby the initial value.
AR1andDifferencedAR1: two new custom NumPyroDistributionsubclasses (
StateAR1,StateDifferencedAR1) inpyrenew/latent/state_centered_distributions.py. Both have vectorizedlog_probusing slice arithmetic (no scan during MCMC) andlax.scan-basedsample(only called for prior/posterior predictive,not on the MCMC gradient path).
Both parameterizations encode the same prior distribution over the
state path. They differ only in sampler geometry — which latent
variables HMC sees and operates on.
Code added
pyrenew/latent/state_centered_distributions.pyStateAR1,StateDifferencedAR1pyrenew/latent/temporal_processes.pyparameterizationflag on all three classes;_prepare_initial_valuehelpertest/test_temporal_processes.pytest/test_helpers.pyfixed_ar1_state,fixed_differenced_ar1_statefactoriestest/integration/conftest.pyhe_model_state_centered,he_weekly_rt_model_state_centered,he_weekly_model_state_centeredfixturestest/integration/test_population_infections_he_state_centered.pytest/integration/test_population_infections_he_weekly_rt_state_centered.pyWeeklyTemporalProcess_typos.tomlreparametrized_params(NumPyro upstream attribute name)