Well, I'm a very newbie in time series forecasting methods, and I'm trying to fit an ARIMA to my time series data and the result is poor. See figure.
It seems to be stationary and the Dickey-Fuller test gives me p<0.05, so, I tried found what ARMA to use using statsmodels arma_order_select_ic
. Don't think is a time series transformation problem, because this results are far from good and when I tried use log (or sqrt) transformation, nothing seems to change in the fitting.
Here is the data and the code I'm using.
ts = pd.read_csv('path/data.csv',index_col=0,parse_dates=True)
ts = pd.Series(ts['ts'])
# # Testing stationarity
# import statsmodels.tsa.stattools as tsa
# dfuller_test = tsa.adfuller(ts, autolag='AIC')
# dfuller_output = pd.Series(dfuller_test[0:4], index=['Test Statistic','p-value','#Lags Used','Number of Observations Used'])
# print(dfuller_output)
# # Plotting ACF and PACF
# from statsmodels.graphics.tsaplots import plot_acf, plot_pacf
# plot_acf(ts,lags=50)
# plot_pacf(ts,lags=50)
# # Finding best p,q
# import statsmodels.api as sm
# res = sm.tsa.arma_order_select_ic(ts, ic=['aic', 'bic'], trend='nc')
# print(res.aic_min_order)
p,d,q = 4,0,1
import pyflux as pf
model = pf.ARIMA(data=pd.DataFrame(ts), ar=p, integ=d, ma=q)
x = model.fit()
model.plot_fit(figsize=(15,4))
mu, Y = model._model(model.latent_variables.get_z_values())
fitted_values = pd.Series(model.link(mu),index=ts.ix[-len(mu):].index)
ts.subtract(fitted_values).plot()
My question is if I'm missing something in this fitting process, or data needs any transformation or normalization? Do you think other model could do it better, as GARCH for instance?