pymc-devs / pymc-examples

Examples of PyMC models, including a library of Jupyter notebooks.
https://www.pymc.io/projects/examples/en/latest/
MIT License
282 stars 244 forks source link

Forecasting with AR models #450

Closed NathanielF closed 1 year ago

NathanielF commented 2 years ago

Notebook proposal

Title: Forecasting with AR models

Why should this notebook be added to pymc-examples?

It is a little opaque how to use AR style models to make future predictions since the shape handling required for the predict steps. I wanted to include an example document for how to fit an AR model and make the prediction step and how the prediction step becomes more complicated if you include other features which require specifying values in the future. I don't believe any of the timeseries examples currently show how to do this.

Suggested categories:

Related notebooks

This notebook would potentially build on the existing AR model example and draw on patterns in the Airlines prophet like bayesian structural timeseries model.

References

I would trying to replicate something like the pattern written in my blog here as discussed with @drbenvincent on twitter: https://nathanielf.github.io/post/bayesian_structural_timeseries/

NathanielF commented 2 years ago

Just wondering what best practice is for installing the required packages. I typically use a poetry venv to install e.g. pymc 4.1.7, but i note the requirements-write.txt only has pymc3? Are we free to install whatever versions we care to, just that the packages in the requirements are the minimum required for working to write. Just seems messy to install pymc3 and pymc on top of it...

drbenvincent commented 2 years ago

Hi @NathanielF

So the requirements file is out of date (https://github.com/pymc-devs/pymc-examples/issues/448). Personally I just use my own custom environment, and to be honest it is not that crucial because the notebooks are only ever run and evaluated locally. The docs are built remotely, but I believe that happens by directly converting the locally evaluated notebook content. So in short, don't worry about using requirements-write.txt and feel free to use whatever you want, as long as its pymc>=4

PS. Fully endorse this proposal. Feel very free to submit a PR when you like.

PPS Tagging @lucianopaz who might have some thoughts on forecasting with AR type models.

NathanielF commented 1 year ago

Great. Will work on it a bit more tomorrow!

NathanielF commented 1 year ago

I've adapted the broad structure of the blog post, with slight differences and less words. Happy to take feedback if you want more explanation or less or if you just think i've missed some crucial detail.