11

我正在尝试在 python 中制作一个 ARMA-GARCH 模型,并且我使用了 arch 包。

但是在 arch 包中我找不到 ARMA 平均模型。

我尝试使用 ARX 均值模型并让 lags = [1,1],但摘要看起来不像 ARMA 模型。

这个包是否包括 ARMA 平均模型?

4

1 回答 1

1

我从 Jason Brownlee 那里学到了这项技术,他是 18 多本与应用机器学习、数学和统计学有关的书籍的作者:

为了在应得的地方给予适当的赞扬,我引用了我通过这些材料获得的学习来源:

引用参考书:

使用 Python 进行时间序列预测简介 © 版权所有 2020 Jason Brownlee。版权所有。版本:v1.10

Jason Brownlee,博士,机器学习精通

https://machinelearningmastery.com/develop-arch-and-garch-models-for-time-series-forecasting-in-python/

感谢 Jason 的无数个小时,毫无疑问是头痛和眼睛疲劳。你教会我机器学习可以很有趣!

Python 中的 ARCH 和 GARCH 模型

# create a simple white noise with increasing variance
from random import gauss
from random import seed
from matplotlib import pyplot

# seed pseudorandom number generator
seed(1)

# create dataset
data = [gauss(0, i*0.01) for i in range(0,100)]

# plot
pyplot.plot(data)
pyplot.show()

在此处输入图像描述

# create dataset
data = [gauss(0, i*0.01) for i in range(1,100+1)]

# check correlations of squared observations
from random import gauss
from random import seed
from matplotlib import pyplot
from statsmodels.graphics.tsaplots import plot_acf

# seed pseudorandom number generator
seed(1)

# create dataset
data = [gauss(0, i*0.01) for i in range(0,100)]

# square the dataset
squared_data = [x**2 for x in data]

# create acf plot
plot_acf(np.array(squared_data))
pyplot.show()

在此处输入图像描述

# split into train/test
n_test = 10
train, test = data[:-n_test], data[-n_test:]

# example of ARCH model
from random import gauss
from random import seed
from matplotlib import pyplot
from arch import arch_model

# seed pseudorandom number generator
seed(1)

# create dataset
data = [gauss(0, i*0.01) for i in range(0,100)]

# split into train/test
n_test = 10
train, test = data[:-n_test], data[-n_test:]

# define model
model = arch_model(train, mean='Zero', vol='ARCH', p=15)

# fit model
model_fit = model.fit()

# forecast the test set
yhat = model_fit.forecast(horizon=n_test)

# plot the actual variance
var = [i*0.01 for i in range(0,100)]
pyplot.plot(var[-n_test:])

# plot forecast variance
pyplot.plot(yhat.variance.values[-1, :])
pyplot.show()

在此处输入图像描述

在此处输入图像描述

# example of ARCH model
# seed pseudorandom number generator
seed(1)

# create dataset
data = [gauss(0, i*0.01) for i in range(0,100)]

# split into train/test
n_test = 10
train, test = data[:-n_test], data[-n_test:]

# define model
model = arch_model(train, mean='Zero', vol='GARCH', p=15, q=15)

# fit model
model_fit = model.fit()

# forecast the test set
yhat = model_fit.forecast(horizon=n_test)

# plot the actual variance
var = [i*0.01 for i in range(0,100)]
pyplot.plot(var[-n_test:])

# plot forecast variance
pyplot.plot(yhat.variance.values[-1, :])
pyplot.show()

# define model
model = arch_model(train, mean='Zero', vol='GARCH', p=15, q=15)

在此处输入图像描述

并且看到结果非常相似,但是迭代次数是原来的两倍多一点……

在此处输入图像描述

引用参考书:

使用 Python 进行时间序列预测简介 © 版权所有 2020 Jason Brownlee。版权所有。版本:v1.10

Jason Brownlee,博士,机器学习精通

https://machinelearningmastery.com/develop-arch-and-garch-models-for-time-series-forecasting-in-python/

于 2020-06-26T02:50:38.480 回答