5. Refreshing your ARIMA models

There are two ways to keep your models up-to-date with Pyramid:

  1. Periodically, your ARIMA will need to be refreshed given new observations. See this discussion and this one on either re-using auto_arima-estimated order terms or re-fitting altogether.
  2. If you’re not ready to refresh your model parameters, but would like to add observations to your model (so new forecasts originate from the latest samples), the ARIMA class makes it possible to add new samples. See this example for more info.

5.1. Adding observations to your model

The easiest way to keep your model up-to-date without refreshing it is simply to add observations to your model so that future forecasts take the newest observations into consideration. Assume that you fit the following model:

import pyramid as pm
from pyramid.datasets import load_wineind

y = load_wineind()
train, test = y[:125], y[125:]

# Fit an ARIMA
arima = pm.ARIMA(order=(1, 1, 2), seasonal_order=(0, 1, 1, 12))
arima.fit(y)

After fitting and persisting your model (see Serializing your ARIMA models), you use your model to produce forecasts. After a few forecasts, you want to record the actual observed values so your model considers them when making newer forecasts:

arima.add_new_observations(test)  # pretend these are the new ones

Your model will now produce forecasts from the new latest observations. Of course, you’ll have to re-persist your ARIMA model after updating it!