TypeError: fit() got an unexpected keyword argument 'disp' in In[4]

Course Name: Financial Time Series Analysis for Trading, Section No: 15, Unit No: 6, Unit type: Notebook

hi,

when I intruduce the code of In[4] I have this error:

TypeError: fit() got an unexpected keyword argument 'disp'

How can I solve it?

Hi David, 



When you run this notebook on your local system, you need to make sure that the version of statsmodels is 0.12.2. 



Hope this helps!



Thanks, 

Bhavika

Thanks Bhavika.



I´m not using Jupiter, I´m using Spyder.



My statsmodels version is 0.13.2



I would like to know what do I have to change in the code instead of install an older version just to an example.



Could you please help me?



Thanks in advance

Hi David, 



Since you want to continue using the new version of statsmodels, instead of using “from statsmodels.tsa.arima_model import ARIMA”, you can use “from statsmodels.tsa.arima.model import ARIMA”.



Also, in the new version of statsmodels, the “disp” parameter is no longer supported. Therefore, you can use the following code:

 

# Function to predict the price of 1 day
def predict_price_MA(train_data):
    # Define model
    model = ARIMA(train_data, order=(0, 1, 1))
    # Fit the model
    model_fit = model.fit()
    # Make forecast
    forecast_results = model_fit.forecast()
    return forecast_results

If want to know more about other changes in the library, you refer to this documentation. 

Thanks,
Bhavika