I'm trying to create an ARIMA Model for my time series data. What can i do to my code for it to run smoothly?
I'm using statsmodels to create the ARIMA model in python but i'm getting error warnings
indexedDataset_logscale.head(10)
OUTPUT:
Price
Period
2013-02-08 2.515274
2013-02-11 2.526528
2013-02-12 2.520113
2013-02-13 2.515274
2013-02-14 2.543961
2013-02-15 2.544040
2013-02-19 2.530119
2013-02-20 2.516082
2013-02-21 2.508786
2013-02-22 2.5273
#AR Model
from statsmodels.tsa.arima_model import ARIMA
model = ARIMA(indexedDataset_logscale, order=(0, 1, 2))
results_AR = model.fit(disp = -1)
plt.plot(datasetLogDiffShifting)
plt.plot(results_AR.fittedvalues, color = 'red')
plt.title('RSS: %.4f' %sum((results_AR.fittedvalues-datasetLogDiffShifting['Price'])**2))
print('Plotting AR Model')
Error messages i get are:
"ValueWarning: A date index has been provided, but it has no associated frequency information and so will be ignored when eg forecasting. ignored when eg forecasting.', ValueWarning)
8 plt.title('RSS: %.4f' %sum((results_AR.fittedvalues-datasetLogDiffShifting['Price'])**2)) TypeError: 'str' object is not callable
1) It seems your index doesn't have set frequency Try adding this befor Arima
df.index.freq = 'D'
D is for daily timestamp, it seems your is not linear/regular, hard to define looking at what's in the question. Check other frequency option in pandas.
To avoid warnings type this at the beginning of the script:
#Clear console
import warnings
warnings.filterwarnings("ignore")
The problem is that in your data, the index seems to be daily, but some dates are not consecutive days. You can supply missing dates and then interpolate values for these dates, as follows:
df = df.resample('D').mean()
df["Price"] = df["Price"].interpolate(method='linear', axis=0).ffill().bfill()
You will then be able to build a model and plot the fitted values.
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.