Reputation: 53
I'm trying to forecast with 36 steps with a SARIMAX model. First I remove heterocedasticity via sqrt and trend via a linear model. Fitted values of the model are similar to the series, but when i try to forecast the results are a bit off. I don't know if i messed up some parameter or something. Here is my code:
#remove heterocedasticity
datos_sqrt=np.sqrt(train)
#remove trend
X = np.array(range(0,len(datos_sqrt)))
X = np.reshape(X, (len(X), 1))
y = datos_sqrt.values
model = LinearRegression()
model.fit(X, datos_sqrt)
trend = model.predict(X)
train_sqrt_trend = datos_sqrt-trend
#fit model
model = SARIMAX(train_sqrt_trend,order = (1, 2, 0),seasonal_order = (2,2,0,12),
enforce_stationarity=False,
enforce_invertibility=False)
results = model.fit()
fitted_values = pd.DataFrame(results.fittedvalues)
#forecast
forecast = results.forecast(steps = 36)
fig, ax = plt.subplots(1, 1, figsize=(15, 5))
plt.plot(fitted_values,label='Fitted')
plt.plot(forecast,label='forecast')
plt.legend(loc='best')
Upvotes: 0
Views: 566
Reputation: 3195
You have specified a model that is integrated (and of order greater than 1), which is not appropriate for this process, and will always result in a trend in the forecast.
The order
argument should be a tuple (p, d, q)
, where p
is the autoregressive order, d
is the order of integration, and q
is the moving average order. Perhaps you meant to use order=(1, 0, 2)
?
Similarly, maybe you meant to use seasonal_order=(2, 0, 2, 12)
?
Upvotes: 1