'How to include the constant/intercept when fitting SARIMA model in python

I have implemented an auto SARIMA model in python with the code:

import pmdarima as pm

smodel = pm.auto_arima(df, start_p=1, start_q=1,
                         test='adf',
                         max_p=3, max_q=3, m=12,
                         start_P=0, seasonal=True,
                         d=1, D=1, trace=True,
                         error_action='ignore',  
                         suppress_warnings=True, 
                         stepwise=True)

smodel.summary()

The results show that the best model was with an intercept, as seen on the image. enter image description here But when I am trying to fit the best model (SARIMAX(0, 1, 2)x(2, 1, 0, 12)) with the code:

from statsmodels.tsa.statespace.sarimax import SARIMAX

model = SARIMAX(df, order=(0, 1, 2), seasonal_order=(2, 1, 0, 12))  
model_fit = model.fit(disp= False)
print(model_fit.summary())

I am obtaining a result without the Intercept, as seen on the image. enter image description here.

I would like to know why the intercept no more appear, and how to include it.

Thanks.



Solution 1:[1]

In the second case you can try insert trend argument equal c as follow:

from statsmodels.tsa.statespace.sarimax import SARIMAX

model = SARIMAX(df, order=(0, 1, 2), seasonal_order=(2, 1, 0, 12), trend = 'c')  
model_fit = model.fit(disp= False)
print(model_fit.summary())

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Marcos JĂșnio