State-Centered Temporal Processes#828
Merged
Merged
Conversation
dylanhmorris
requested changes
Jun 16, 2026
Collaborator
There was a problem hiding this comment.
Thanks @cdc-mitzimorris! Two requested changes:
- Change the
StateDifferencedAR1Distributionto sample only the post-init path (https://github.com/CDCgov/PyRenew/pull/828/changes#r3421572974) and adjust the sampling logic for the downstreamStateDifferencedAR1TemporalProcessaccordingly - Ensure tests of parameterization-agnostic
TemporalProcessproperties are conducted in one place for all parameterizations https://github.com/CDCgov/PyRenew/pull/828/changes#r3421572974
Also left some minor suggestions (mostly docs rendering and variable naming)
Collaborator
Author
|
@dylanhmorris made all changes per requests and suggestions. |
dylanhmorris
approved these changes
Jun 16, 2026
dylanhmorris
left a comment
Collaborator
There was a problem hiding this comment.
Thanks, @cdc-mitzimorris! A few suggestions for test readability and coverage but happy for you to merge without re-review.
Co-authored-by: Dylan H. Morris <dylanhmorris@users.noreply.github.com>
Co-authored-by: Dylan H. Morris <dylanhmorris@users.noreply.github.com>
for more information, see https://pre-commit.ci
…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"switches the internal sampling from standardized increments to the latent state path directly.All three state-centered variants are custom
numpyro.distributions.Distributionsubclasses inpyrenew/latent/state_centered_distributions.py:StateRandomWalk: samples the post-initial path as accumulated Normal increments from the deterministic initial value.StateAR1andStateDifferencedAR1: the AR(1) process on the level and on first differences, respectively.Each has a vectorized log_prob (slice arithmetic, no scan) that carries the MCMC gradient, and a sample method (cumsum for the walk, lax.scan for the AR(1) variants) used only for forward simulation such as prior and posterior predictive, not on the gradient path.
Both parameterizations encode the same prior over the state path; they differ only in sampler geometry, that is, which latent variables HMC 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)