I’m developing a Python Package for Bayesian time series analysis, called PyBATS. The package specializes in dynamic generalized linear models (DGLMs), which can be used to analyze time series of counts (Poisson DGLMs), 0/1 events (Bernoulli DGLMs), and of course continuous outcomes (Normal DLMs).
The PyBATS webpage contains a quick-start example of analysis, plus an in-depth example of forecasting sales data. Here are some highlights from the quick-start example. After loading in the data, we’re able to conduct the full analysis with updating and forecasting using one command (and lots of customization options):
from pybats.analysis import analysis mod, samples = analysis(Y, X, family="poisson", forecast_start=forecast_start, # First time step to forecast on forecast_end=forecast_end, # Final time step to forecast on k=k, # Forecast horizon. prior_length=6, # How many data points to use in defining prior rho=.5, # Random effect to increase variance deltrend=0.95, # Discount factor on the intercept parameter delregn=0.95 # Discount factor on the regression parameters )
We can then use the samples to plot the true sales, our forecast values, and 95% credible intervals:
PyBATS is in active development, and feedback is very welcome! Please send me an email if you have suggestions for features you’d like to see, find any bugs, or are interested in contributing.