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

Merge statespace module from https://github.com/jessegrabowski/pymc_statespace #174

Merged
merged 140 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from 129 commits
Commits
Show all changes
140 commits
Select commit Hold shift + click to select a range
6dba1dc
move https://github.com/jessegrabowski/pymc_statespace to pymc-experim…
jessegrabowski May 29, 2023
d9f3239
Make tests compatible with float32
jessegrabowski May 29, 2023
c37fb77
Fix remaining tests that failed when dtype is float32
jessegrabowski May 29, 2023
5f48976
Fix remaining tests that failed when dtype is float32
jessegrabowski May 29, 2023
d04adaf
Merge remote-tracking branch 'origin/statespace' into statespace
jessegrabowski May 29, 2023
6b0a123
Merge branch 'main' into statespace
jessegrabowski May 29, 2023
12b4db5
Merge branch 'pymc-devs:main' into statespace
jessegrabowski Jul 8, 2023
ead1036
Merge branch 'statespace' of https://github.com/jessegrabowski/pymc-e…
jessegrabowski Jul 8, 2023
c6a4f85
Replace print with `logger.info`
jessegrabowski Jul 12, 2023
8e18779
Use `getattr` to access model variables in `gather_required_random_va…
jessegrabowski Jul 12, 2023
8b05fb7
Reduce code duplication, eliminate use of `pathlib` in favor of expli…
jessegrabowski Jul 12, 2023
389bfbe
Refactor `PyMCStateSpace` and `PytensorRepresentation` to no longer r…
jessegrabowski Jul 12, 2023
b3d5c2a
Merge remote-tracking branch 'origin/statespace' into statespace
jessegrabowski Jul 13, 2023
e577590
Refactor kalman filters to remove singleton dimensions everywhere pos…
jessegrabowski Jul 13, 2023
c761d85
Add tests for sarimax, add first pass at state space distribution
jessegrabowski Jul 13, 2023
4d5cf7e
Merge remote-tracking branch 'origin/statespace' into statespace
jessegrabowski Jul 14, 2023
96cca74
Add more helpers to statespace class for building PyMC model
jessegrabowski Jul 15, 2023
9532901
Changes to SARIMAX to make states interpretable, plus bad draft pymc …
jessegrabowski Jul 16, 2023
953542e
Distribution attempt 2
jessegrabowski Jul 16, 2023
ec03342
Distribution attempt 3
jessegrabowski Jul 18, 2023
9cf56d1
Fix broken tests
jessegrabowski Jul 18, 2023
496f815
Fix remaining tests
jessegrabowski Jul 19, 2023
7e3ed2f
Preserve name/shape information after updates to matrices
jessegrabowski Jul 19, 2023
9efa465
Add test for `SequenceMvNormal`
jessegrabowski Jul 19, 2023
5ef77a9
Add logp as parameter to `SequenceMvNormal`
jessegrabowski Jul 20, 2023
8648155
Add logp argument to `SequenceMvNormal` test
jessegrabowski Jul 20, 2023
9a4636d
Refactor shape checking to use `type.shape`
jessegrabowski Jul 20, 2023
ceecd15
Refactor shape checking to use `type.shape`
jessegrabowski Jul 20, 2023
d31c220
Add float32 test skip back to `test_filters_match_statsmodel_output`
jessegrabowski Jul 21, 2023
cf49e92
Refactor `LinearGaussianStateSpace` for use in prior/posterior predic…
jessegrabowski Jul 21, 2023
570d613
Infer coordinates for statespace matrices from parameters
jessegrabowski Jul 21, 2023
90dcf69
Refactor posterior predictive sampling, coords, and data handling
jessegrabowski Jul 22, 2023
15a337c
Remove typecheck with `Union`
jessegrabowski Jul 22, 2023
d76a12c
Fix float32 error in tests
jessegrabowski Jul 22, 2023
6b8575a
Fix float32 error in tests
jessegrabowski Jul 22, 2023
2f19ec1
Fix bugs in SARMIAX, add measurement error option to SARIMAX, update …
jessegrabowski Jul 22, 2023
ef32c5b
always add `TIME_DIM` to model coords, even when data aren't given dims
jessegrabowski Jul 22, 2023
de72922
always add `TIME_DIM` to model coords, even when data aren't given dims
jessegrabowski Jul 22, 2023
d982566
Add forecast method to `Statespace`, add coord/dim info to `VARMAX`, …
jessegrabowski Jul 23, 2023
dd81173
Add `impulse_response_function` method to `Statespace`, update `ARIMA…
jessegrabowski Jul 24, 2023
6538d18
Update VARMAX notebook, remove `pm.DiracDelta` from `Statespace.forec…
jessegrabowski Jul 24, 2023
36d7901
Update VARMAX example notebook
jessegrabowski Jul 25, 2023
c1208db
Add docstrings to statespace methods and utilities
jessegrabowski Jul 25, 2023
d9caa01
Merge remote-tracking branch 'origin/statespace' into statespace
jessegrabowski Jul 25, 2023
8f47ef3
More docstrings
jessegrabowski Jul 26, 2023
96b1f37
documentation
jessegrabowski Jul 27, 2023
04ad689
More docs, fix failing tests
jessegrabowski Jul 27, 2023
4f41b2a
Implement conditional and unconditonal sampling from prior idata
jessegrabowski Jul 27, 2023
1b6297f
Trying to get the API docs to render
jessegrabowski Jul 27, 2023
3f766d3
Trying to get the API docs to render
jessegrabowski Jul 27, 2023
ca91078
Revert "Trying to get the API docs to render"
jessegrabowski Jul 27, 2023
1de05e8
Trying to get the API docs to render, revert local change to `pyproje…
jessegrabowski Jul 27, 2023
94876b1
Trying to get the API docs to render
jessegrabowski Jul 27, 2023
8cf95b4
Remove `specify_broadcast` in `SingleTimeseriesFilter.update`
jessegrabowski Jul 27, 2023
849ba1b
Fixing docstrings
jessegrabowski Jul 27, 2023
7ff39e2
Fixing docstrings
jessegrabowski Jul 27, 2023
e921698
create toctree hierarchy
jessegrabowski Jul 27, 2023
4e0b463
create toctree hierarchy
jessegrabowski Jul 27, 2023
a0f3343
create toctree hierarchy
jessegrabowski Jul 27, 2023
d91fc37
docstrings
jessegrabowski Jul 27, 2023
ad933b7
docstrings
jessegrabowski Jul 27, 2023
29a88ff
docstrings
jessegrabowski Jul 27, 2023
61b6945
Making a table in a docstring
jessegrabowski Jul 27, 2023
ae106c2
Making a table in a docstring
jessegrabowski Jul 27, 2023
b75ff41
More docs
jessegrabowski Jul 28, 2023
12f56c4
More docstrings
jessegrabowski Jul 28, 2023
812d6c5
More docstrings
jessegrabowski Jul 28, 2023
c7772ac
More docstrings
jessegrabowski Jul 28, 2023
7670f4e
Remove `BayesianLocalLevel`, add a new `StructuralTimeSeries` module
jessegrabowski Jul 29, 2023
f525166
Remove `BayesianLocalLevel`, add a new `StructuralTimeSeries` module
jessegrabowski Jul 29, 2023
32c58bc
Bug fixes in `structural`, new example notebook
jessegrabowski Jul 30, 2023
a231c29
Bug fixes in `structural`, update structural example
jessegrabowski Jul 31, 2023
e2b93e6
Kalman filter no longer returns a forecast on the predicted states
jessegrabowski Jul 31, 2023
0f2a2b9
Fix bugs in IRF API
jessegrabowski Jul 31, 2023
95a9860
Fix bugs in IRF API
jessegrabowski Jul 31, 2023
caa3e0b
Add `airpass.csv` test data
jessegrabowski Jul 31, 2023
cf2157e
More docstrings
jessegrabowski Jul 31, 2023
6b8c9c9
More docstrings
jessegrabowski Jul 31, 2023
01d063a
More docstrings
jessegrabowski Jul 31, 2023
7f824dc
More docstrings
jessegrabowski Jul 31, 2023
f2b5281
Fix VARMAX tests
jessegrabowski Jul 31, 2023
669382a
More docs
jessegrabowski Jul 31, 2023
f961eac
More docs, allow user to name states in seasonal components
jessegrabowski Jul 31, 2023
5631ad3
more docs, rename `test_structural_model` to `test_structural`
jessegrabowski Aug 1, 2023
21570c2
Allow non-integer seasonal length in `FrequencySeasonality` (breaks t…
jessegrabowski Aug 1, 2023
5b1dbc8
Seed `sample_posterior` and `sample_prior` tests, unbreak `test_struc…
jessegrabowski Aug 1, 2023
edcd9ca
Set test seed as a global constant
jessegrabowski Aug 2, 2023
ee4a817
Remove numba dependency
jessegrabowski Aug 2, 2023
68ac3c2
Add helper function to `StructuralTimeSeries` to reconstruct componen…
jessegrabowski Aug 2, 2023
f899096
Add `fast_eval` as test utility
jessegrabowski Aug 2, 2023
c4aee6b
Changes from review feedback
jessegrabowski Aug 2, 2023
29d1778
Try to fix failing test
jessegrabowski Aug 2, 2023
f324db2
Catch expected test warnings with `pytest.mark.filterwarnings`
jessegrabowski Aug 2, 2023
b9a6dd2
Scope fixtures in sampling tests to speed them up a bit
jessegrabowski Aug 2, 2023
69395ef
More fixes from review
jessegrabowski Aug 3, 2023
c6485a0
Trying to fix the failing test
jessegrabowski Aug 3, 2023
90f9fdd
Remove numba from `windows-environment-test.yml`
jessegrabowski Aug 3, 2023
86b7642
Test for NaNs in sampled statespace objects
jessegrabowski Aug 3, 2023
6b69719
Redo the `Custom Statespace` notebooks
jessegrabowski Aug 3, 2023
b4a2d87
Add `ImputationWarning` to `mask_missing_values_in_data`
jessegrabowski Aug 3, 2023
5a3d4cd
Add `ImputationWarning` to `mask_missing_values_in_data`
jessegrabowski Aug 3, 2023
b2cdc1c
Add off-diagonal averaging to covariance `stabilize` function.
jessegrabowski Aug 3, 2023
ab67bb8
Covariance matrices output by kalman filter not always PSD
jessegrabowski Aug 4, 2023
795910c
Add some stability tricks to Kalman filters
jessegrabowski Aug 4, 2023
cd7e712
Add `measurement_error` kwarg to `PyMCStateSpace`
jessegrabowski Aug 4, 2023
221a6ef
Allow `eig == 0.0` to pass PSD test
jessegrabowski Aug 4, 2023
ff0cd98
Add stability tests to VARMAX and SARIMAX
jessegrabowski Aug 4, 2023
adf5e82
LGSS distribution doesn't need to know anything about measurement error
jessegrabowski Aug 5, 2023
78d982f
Re-run Structural Timeseries Modeling.ipynb with some new features
jessegrabowski Aug 5, 2023
cf0f0c0
Delete out-of-date example notebook
jessegrabowski Aug 5, 2023
3060676
Updates to Making a Custom Statespace Model.ipynb
jessegrabowski Aug 5, 2023
53226cb
Link to the bVAR example notebook in the VARMAX Example.ipynb
jessegrabowski Aug 5, 2023
bd2e7e7
Make the IRF plots more readable in ARIMA Example.ipynb
jessegrabowski Aug 5, 2023
225810f
Increase `JITTER_DEFAULT` when pytensor is in `float32` mode
jessegrabowski Aug 5, 2023
fdefbee
Increase `JITTER_DEFAULT` when pytensor is in `float32` mode
jessegrabowski Aug 5, 2023
de9618d
Merge remote-tracking branch 'origin/statespace' into statespace
jessegrabowski Aug 5, 2023
b8995aa
Add stabilization to univariate filter covariance
jessegrabowski Aug 5, 2023
b0cf3de
Trying to get the last tests to pass
jessegrabowski Aug 5, 2023
3a143a3
Different stability strategy for UnivariateFilter
jessegrabowski Aug 5, 2023
259f6f4
Skip overly sensitive float32 tests
jessegrabowski Aug 5, 2023
7f299a3
Remove `update` function
jessegrabowski Aug 8, 2023
1ce2c7a
All tests pass
jessegrabowski Aug 9, 2023
593745c
Update Making a Custom Statespace Model.ipynb to reflect refactor
jessegrabowski Aug 9, 2023
5748bca
Relax float32 test tolerance in `test_structural.py`
jessegrabowski Aug 9, 2023
2f87538
Set dtype on numpy arrays used in test_structural.py
jessegrabowski Aug 9, 2023
c3dcfa8
Remove dictionary merge with pipe
jessegrabowski Aug 9, 2023
3cd9dd9
Disable all PSD tests for univariate filter when floatX=float32
jessegrabowski Aug 9, 2023
44d7db0
Remove `variable_by_shape` helper, use `pt.tensor` directly.
jessegrabowski Aug 9, 2023
c60ff4e
Remove unused helper functions
jessegrabowski Aug 9, 2023
27163c5
Adjust new tests for float32
jessegrabowski Aug 10, 2023
03c59db
Add test for equivalence between SARIMA representations
jessegrabowski Aug 10, 2023
731228f
Add test for equivalence between SARIMA representations
jessegrabowski Aug 10, 2023
0c8b590
Use `self.mode` in all kalman filter scans
jessegrabowski Aug 10, 2023
688fd01
Begin adding seasonal components to SARIMAX.py
jessegrabowski Aug 12, 2023
891a823
Implement seasonal lags and differences in SARIMAX
jessegrabowski Aug 13, 2023
a3b0958
Add an Exogenous Regression component to `structural.py`
jessegrabowski Aug 14, 2023
65b4294
Expand support for exogenous variables in statespace models
jessegrabowski Aug 18, 2023
cfe6e0a
Tweak tests
jessegrabowski Aug 18, 2023
e4cdd12
Tweak tests
jessegrabowski Aug 18, 2023
1342afa
Merge remote-tracking branch 'origin/statespace' into statespace
jessegrabowski Aug 18, 2023
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
1 change: 1 addition & 0 deletions conda-envs/environment-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dependencies:
- pytest>=3.0
- dask
- xhistogram
- statsmodels
- pip:
- pymc>=5.6.0 # CI was failing to resolve
- blackjax
Expand Down
1 change: 1 addition & 0 deletions conda-envs/windows-environment-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ dependencies:
- pytest>=3.0
- dask
- xhistogram
- statsmodels
- pip:
- pymc>=5.6.0 # CI was failing to resolve
- scikit-learn
10 changes: 10 additions & 0 deletions docs/api_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,13 @@ Utils
prior.prior_from_idata
model_fgraph.fgraph_from_model
model_fgraph.model_from_fgraph

Statespace Models
=================
.. automodule:: pymc_experimental.statespace
.. toctree::
:maxdepth: 1

statespace/core
statespace/filters
statespace/models
10 changes: 10 additions & 0 deletions docs/statespace/core.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
********************
Statespace Core
********************

.. automodule:: pymc_experimental.statespace.core
.. autosummary::
:toctree: generated

PytensorRepresentation
PyMCStateSpace
15 changes: 15 additions & 0 deletions docs/statespace/filters.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
********************
Kalman Filters
********************

.. automodule:: pymc_experimental.statespace.filters
.. autosummary::
:toctree: generated

StandardFilter
UnivariateFilter
SteadyStateFilter
KalmanSmoother
SingleTimeseriesFilter
CholeskyFilter
LinearGaussianStateSpace
20 changes: 20 additions & 0 deletions docs/statespace/models.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
*****************
Statespace Models
*****************

.. automodule:: pymc_experimental.statespace.models
.. autosummary::
:toctree: generated

BayesianARIMA
BayesianVARMAX

*********************
Structural Components
*********************

.. currentmodule:: pymc_experimental.statespace.models
.. toctree::
:maxdepth: 2

models/structural
16 changes: 16 additions & 0 deletions docs/statespace/models/structural.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
*********************
Structural Components
*********************

.. automodule:: pymc_experimental.statespace.models.structural
.. autosummary::
:toctree: generated

LevelTrendComponent
AutoregressiveComponent
TimeSeasonality
FrequencySeasonality
MeasurementError

StructuralTimeSeries
Component
2,141 changes: 2,141 additions & 0 deletions notebooks/ARMA Example.ipynb

Large diffs are not rendered by default.

Loading
Loading