ARIMA Models in Python
James Fulton
Climate informatics researcher
diff_forecast = results.get_forecast(steps=10).predicted_mean
from numpy import cumsum
mean_forecast = cumsum(diff_forecast)
diff_forecast = results.get_forecast(steps=10).predicted_mean
from numpy import cumsum
mean_forecast = cumsum(diff_forecast) + df.iloc[-1,0]
Can we avoid doing so much work?
Yes!
ARIMA - Autoregressive Integrated Moving Average
from statsmodels.tsa.arima.model import ARIMA
model = ARIMA(df, order=(p,d,q))
ARIMA$(p,0,q)$ = ARMA$(p,q)$
# Create model model = ARIMA(df, order=(2,1,1))
# Fit model model.fit()
# Make forecast mean_forecast = results.get_forecast(steps=10).predicted_mean
# Make forecast
mean_forecast = results.get_forecast(steps=steps).predicted_mean
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
model = ARIMA(df, order=(p,1,q))
ARIMA Models in Python