Search code examples
python-3.xtime-seriesstatsmodelsarima

Returning training set predicted values with statsmodels.tsa


I have been training ARIMA models using the statsmodels (v0.12.2) package, and would like to check out how a model fits on the training data

Current Code:

from statsmodels.tsa.arima.model import ARIMA

#for some p,d,q
model = ARIMA(train, order = (p,d,q)
model_fit = model.fit()

Attempting to do:

I would like to plot the predictions of the training set against the actual training values.
I have been trying to use the following after reading this documentation:

model_fit.get_prediction()

However, this returns:

<statsmodels.tsa.statespace.mlemodel.PredictionResultsWrapper at 0x7f804bf5bbe0>

Question:

How can I return these predicted values for the training set?

Advice appreciated!


Solution

  • I think you are looking for the fitted values of the model, if so then use,

    model_fit.fittedvalues
    

    You can find a complete example here.