-
Notifications
You must be signed in to change notification settings - Fork 0
Observational Model First Pass #21
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
Merged
Merged
Conversation
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
To begin work on incorporating observations into the model generate an example dataset of observations from a prior predictive sample.
Created a sample dataset with both incidence and prevelance values along with plots.
Added an internal helper to `vaxflux._util` to do some light validations and formatting of user provided observations, mostly extracted from `SeasonalUptakeModel.__init__`. Sets stage for observations specific formatting.
Fixed a bug where only one incidence time series per a season was saved to the `incidence` dict inside of `SeasonalUptakeModel.build`. Didn't affect model for sampling since already added to model graph, but need it for observational model.
* Added extra comments to `SeasonalUptakeModel.build`, and * Added a custom potential term to constrain prevalence to [0, 1] interval when generating incidence time series.
Added * A value error for missing required columns, and * Nowcasting provided for the `vaxflux._util._validate_and_format_observations` function, along with corresponding unit tests and documentation.
Add validation to `vaxflux._util._validate_and_format_observations` to ensure a 'season' column is provided.
Added `SeasonalUptakeModel.add_observations` helper method to create a duplicate instance of `vaxflux.uptake.SeasonalUptakeModel` but with observations added.
Minor bug fixes throughout to allow for providing observations in the form of a pandas DataFrame. Most of the bugs arising from pandas DataFrames not being truthy.
Incorporate observations into the seasonal uptake model created by `SeasonalUptakeModel.build` with an approximate normal distribution due to the inability to directly represent the sum of random variables.
Create a concrete well formatted data set of weekly uptake data generated from one of the prior sample draws. Sampling is done using the `blackjax` package because the built in PyMC NUTS sampler has trouble compiling this model. Added benefit is that `blackjax` is pretty fast anyways.
c9795d5 to
00d5af9
Compare
Extract the observational sigma constant to a class constant from a hard-coded number.
Added the `sample` method to `vaxflux.uptake.SeasonalUptakeModel` as a wrapper around `pymc.sample` with built in defaults for the random seed and NUTS sampler.
* Added required columns 'type' and 'value' for type of obs and the obs value itself, * Expanded input checking in `_validate_and_format_observations` for observations, and * Expanded type coercion in `_validate_and_format_observations` for a more uniform observations return.
In similar style to scikit-learn changed the `SeasonalUptakeModel.sample` method to return self instead of the fitted trace. This allows the instance to have access to the trace for further work like summarization utilities.
TimothyWillard
added a commit
that referenced
this pull request
Apr 15, 2025
Observational Model First Pass
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.
No description provided.