首页 > 解决方案 > python中Arch和GARCH模型的问题

问题描述

我正在尝试对 Apple 数据进行研究,以获得有关数据集波动性和方差的更多信息。我的想法是使用 Garch 和 Arch 模型。但是,当用训练好的部分进行预测时,结果没有逻辑。

from arch import arch_model
n_test = 100
train, test = AAPL[:-n_test], AAPL[-n_test:]

model = arch_model(train, mean='Zero', vol='ARCH', p = 20)
model_fit = model.fit()

我用 ARCH 模型拟合模型,当我做预测时

import matplotlib.pyplot as plt
yhat =model_fit.forecast(horizon=n_test)

var = [i*0.01 for i in range(0,100)]
plt.plot(var[-n_test:])

plt.plot(yhat.variance.values[-1, :])
plt.show()

测试数据和预测图

标签: time-seriesvolatilearch

解决方案


推荐阅读