snsten / SP500_Time-Series_Forecasting

S&P500 Stock Index Movement Forecastor with various Statistical and Machine Learning Models
MIT License
10 stars 5 forks source link

Errors #12

Open trandafile opened 4 months ago

trandafile commented 4 months ago

I'm trying to use the code.

This section: from statsmodels.tsa.seasonal import seasonal_decompose

decomposition = seasonal_decompose(df_sample['SP500'], model='additive', freq=30) plt.rcParams["figure.figsize"] = [13, 7] fig = decomposition.plot()

Gives these errors: TypeError Traceback (most recent call last) Cell In[53], line 3 1 from statsmodels.tsa.seasonal import seasonal_decompose ----> 3 decomposition = seasonal_decompose(df_sample['SP500'], model='additive', freq=30) 4 plt.rcParams["figure.figsize"] = [13, 7] 5 fig = decomposition.plot()

TypeError: seasonal_decompose() got an unexpected keyword argument 'freq'

snsten commented 4 months ago

What's the version of statsmodels package are you using?

trandafile commented 4 months ago

Ciao, thanks a lot for your reply. The version is: 0.14.2

Luigi

Il giorno dom 7 lug 2024 alle ore 21:22 Shashank @.***> ha scritto:

What's the version of statsmodels package are you using?

— Reply to this email directly, view it on GitHub https://github.com/snsten/SP500_Time-Series_Forecasting/issues/12#issuecomment-2212544381, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJOIAEQFKUZUCU73NIFSZ5LZLGINTAVCNFSM6AAAAABKH2TKJKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMJSGU2DIMZYGE . You are receiving this because you authored the thread.Message ID: @.***>

snsten commented 4 months ago

I checked the docs for 0.14.2 and the keyword freq is changed to period. So in the new version of library the code is: decomposition = seasonal_decompose(df_sample['SP500'], model='additive', period=30)

trandafile commented 4 months ago

Thanks a lot for your feedback. Now this section of the code is working. However, I get this error: --------------------------------------------------------------------------- NotImplementedError Traceback (most recent call last) Cell In[24], line 3 1 from statsmodels.tsa.arima_model import ARIMA ----> 3 model = ARIMA(df_sample.y_log, order=(1,1,2)) 4 model_fit = model.fit(disp=0) 5 print(model_fit.summary())

File c:\Users\Luigi Boccia\AppData\Local\Programs\Python\Python312\Lib\site-packages\statsmodels\tsa\arima_model.py:45, in ARIMA.init(self, *args, kwargs) 44 def init(self, *args, *kwargs): ---> 45 super().init(args, kwargs)

File c:\Users\Luigi Boccia\AppData\Local\Programs\Python\Python312\Lib\site-packages\statsmodels\tsa\arima_model.py:29, in ARMA.init(self, *args, *kwargs) 28 def init(self, args, **kwargs): ---> 29 raise NotImplementedError(ARIMA_DEPRECATION_ERROR)

NotImplementedError: statsmodels.tsa.arima_model.ARMA and statsmodels.tsa.arima_model.ARIMA have been removed in favor of statsmodels.tsa.arima.model.ARIMA (note the . between arima and model) and statsmodels.tsa.SARIMAX.

statsmodels.tsa.arima.model.ARIMA makes use of the statespace framework and is both well tested and maintained. It also offers alternative specialized parameter estimators.

trandafile commented 4 months ago

I've solved it using this code:

import pandas as pd from statsmodels.tsa.arima.model import ARIMA model = ARIMA(df_sample['y_log'], order=(1, 1, 2)) model_fit = model.fit()

print(model_fit.summary())