简体   繁体   中英

ARIMA summary showing as SARIMAX

I have an ARIMA(1,1,1) model I am trying to fit to a dataframe of stock prices. The index of the dataframe is a date.

The code below compiles but it produces a SARIMAX summary and not ARIMA (see image).

from statsmodels.tsa.arima.model import ARIMA
dataset_for_prediction.index = dataset_for_prediction.index.to_period('B')
model = ARIMA(dataset_for_prediction['Adj Close'], order=(1,1,1))
model_fit = model.fit()
print(model_fit.summary())

在此处输入图像描述

How can I then plot the actual results. I have tried the following but it just produces a horizontal line.

from statsmodels.graphics.tsaplots import plot_predict
plot_predict(model_fit)
plt.show()

Tried to print the predicted values:

print(model_fit.predict())

Output

Date
2014-12-31      0.000000
2015-01-02    108.382622
2015-01-05    109.424271
2015-01-06    107.839921
2015-01-07    105.537888
                 ...    
2022-04-25    133.380821
2022-04-26    134.080382
2022-04-27    131.454924
2022-04-28    130.273586
2022-04-29    130.850081

When drawing this picture(first element 0): 在此处输入图像描述 excluded the first element

fig = plot_predict(model_fit, start=dataset_for_prediction.index[1], end=dataset_for_prediction.index[-1], ax=ax)

在此处输入图像描述 All code:

import yfinance as yf
from statsmodels.tsa.arima.model import ARIMA
from statsmodels.graphics.tsaplots import plot_predict
import matplotlib.pyplot as plt

dataset_for_prediction = yf.download('IBM', start='2015-01-01', end='2022-04-30')

dataset_for_prediction.index = dataset_for_prediction.index.to_period('B')
model = ARIMA(dataset_for_prediction['Adj Close'], order=(1, 1, 1))
model_fit = model.fit()

fig, ax = plt.subplots()
ax = dataset_for_prediction['Adj Close'].plot(ax=ax)
fig = plot_predict(model_fit, start=dataset_for_prediction.index[1], end=dataset_for_prediction.index[-1], ax=ax)
legend = ax.legend(loc='upper left')
plt.show()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM