Hello to everybody.
Could anybody explain to me the logic behind indexing in the .predict() mehod of tsa.ar_model.AutoReg ?
I'm working on a project where an error on the precise autoregression lag to be used
is crucial.
Hereafter I attach a snippet code of what I get in an
ultra-simplified setting.
I include the outputs, which I don't understand at all.
#------------------------
import numpy as np
from statsmodels.tsa.ar_model import AutoReg
# version 0.12.2
train = np.array([0.,1.,0.,1.,0.,1.,0.,1.,0.,1.])
m_ord = 2
model = AutoReg(train, m_ord, trend='n', old_names=False)
res_ar = model.fit()
# statsmodels manual page for start and end in predict:
# 'Zero-indexed observation number...'
#
https://www.statsmodels.org/stable/generated/statsmodels.tsa.ar_model.AutoReg.predict.html#statsmodels.tsa.ar_model.AutoReg.predict#
# STRANGE behavior, if 0 is the start index
res_ar.predict(0,0) # array([1., 0., 1., 0., 1., 0.])
res_ar.predict(0,1) # array([])
res_ar.predict(0,2) # array([0.])
# if start is 1, is end actually end-1 ?
res_ar.predict(1,2) # array([0.])
res_ar.predict(1,3) # array([0., 1.])
# or, end is end?
res_ar.predict(2,4) # array([0., 1., 0.])
res_ar.predict(2,5) # array([0., 1., 0., 1.])
# why the same output as above?
res_ar.predict(1,5) # array([0., 1., 0., 1.])
Thank you.
Carlo