Introductie tot ARIMA-modellen

ARIMA-modellen in Python

James Fulton

Climate informatics researcher

Herhaling: niet-stationaire tijdreeksen

ARIMA-modellen in Python

Herhaling: niet-stationaire tijdreeksen

ARIMA-modellen in Python

Forecast van gedifferentieerde tijdreeks

ARIMA-modellen in Python

Oorspronkelijke tijdreeks herstellen na differencing

diff_forecast = results.get_forecast(steps=10).predicted_mean

from numpy import cumsum
mean_forecast = cumsum(diff_forecast)
ARIMA-modellen in Python

Oorspronkelijke tijdreeks herstellen na differencing

diff_forecast = results.get_forecast(steps=10).predicted_mean

from numpy import cumsum
mean_forecast = cumsum(diff_forecast) + df.iloc[-1,0]
ARIMA-modellen in Python

Oorspronkelijke tijdreeks herstellen na differencing

ARIMA-modellen in Python

Het ARIMA-model

 

  • Neem het verschil
  • Pas ARMA-model toe
  • Integreer de forecast

Kunnen we dit vermijden?

Ja!

ARIMA - Autoregressief Geïntegreerd Moving Average

ARIMA-modellen in Python

Het ARIMA-model gebruiken

from statsmodels.tsa.arima.model import ARIMA

model = ARIMA(df, order=(p,d,q))
  • p - aantal autoregressieve vertragingen
  • d - orde van differencing
  • q - aantal moving-average-vertragingen

ARIMA$(p,0,q)$ = ARMA$(p,q)$

ARIMA-modellen in Python

Het ARIMA-model gebruiken

# Create model
model = ARIMA(df, order=(2,1,1))

# Fit model model.fit()
# Make forecast mean_forecast = results.get_forecast(steps=10).predicted_mean
ARIMA-modellen in Python

Het ARIMA-model gebruiken

# Make forecast
mean_forecast = results.get_forecast(steps=steps).predicted_mean

ARIMA-modellen in Python

De orde van differencing kiezen

adf = adfuller(df.iloc[:,0])
print('ADF Statistic:', adf[0])
print('p-value:', adf[1])
ADF Statistic: -2.674
p-value: 0.0784
adf = adfuller(df.diff().dropna().iloc[:,0])
print('ADF Statistic:', adf[0])
print('p-value:', adf[1])
ADF Statistic: -4.978
p-value: 2.44e-05
ARIMA-modellen in Python

De orde van differencing kiezen

model = ARIMA(df, order=(p,1,q))
ARIMA-modellen in Python

Laten we oefenen!

ARIMA-modellen in Python

Preparing Video For Download...