I am getting a very weird indexing problem with pandas and the arch package. Please see below.
2018-07-01 12:00:00 0.13140109854255924
0 2018-07-01 16:00:00 0.144556
1 2018-07-01 20:00:00 0.158099
2 2018-07-02 00:00:00 0.171786
3 2018-07-02 04:00:00 0.185339
4 2018-07-02 08:00:00 0.198468
5 2018-07-02 12:00:00 2.513214
notice anything wrong. Its driving me doolaly cos I can't get rid of it. Now see:
df = df.iloc[1:,:]
print(df)
2018-07-01 12:00:00 0.13140109854255924
2 2018-07-02 00:00:00 0.171786
3 2018-07-02 04:00:00 0.185339
4 2018-07-02 08:00:00 0.198468
5 2018-07-02 12:00:00 2.513214
6 2018-07-02 16:00:00 2.157013
now look at
df2 = pd.Series(range(100))
print(df2)
0 0
1 1
2 2
3 3
4 4
5 5
df3 = df.loc[df2.index,:]
print(df3)
2018-07-01 12:00:00 0.13140109854255924
0 NaN NaN
1 NaN NaN
2 2018-07-02 00:00:00 0.171786
3 2018-07-02 04:00:00 0.185339
4 2018-07-02 08:00:00 0.198468
5 2018-07-02 12:00:00 2.513214
6 2018-07-02 16:00:00 2.157013
I think it may be the package. Because df2 above looks ok. So here is my code for generating df.
from arch import arch_model
am = arch_model(series)
res = am.fit(update_freq=5,disp='off')
sres = res.resid/res.conditional_volatility
vola = res.conditional_volatility
print(sres)
sres.to_csv(filename,index=True)