使用 GARCH 进行时间序列预测

Time Series Forecasting with GARCH

我正在尝试使用 GARCH(1,1) 模型预测 R 中的时间序列对象。我的目标是使用 GARCH 模型提前预测 24 个实例。虽然我在预测时使用了时间序列对象,但出现以下错误:

is.constant(y) 错误: (list) object 不能强制类型为 'double'

这些是我正在使用的命令:

library(forecast)
library(tseries)


trainer1 <- ts(trainer, frequency=24)
m1 <- garch(trainer1, order = c(1,1))
forecasts1 <- forecast(m1, h=24)

我使用的示例数据如下:

124.30
98.99
64.00
64.00
123.99
123.99
34.97
123.99
139.91
140.00
164.30
178.99
140.00
169.95
161.18
139.94
161.31
124.00
115.01
124.00

非常感谢您的帮助:)

garch 不是 forecast 包的函数。因此,您不能在 m1 模型上应用 forecast 函数。 garch 函数在 tseries 包中可用。因此,要使用 garch 进行预测,您必须使用

library(forecast)
library(tseries)
trainer1 <- ts(df, frequency=24)
m1 <- garch(trainer1, order = c(1,1))
forecasts1 <- predict(m1, trainer1)

如果你想预测你可以使用像

这样的fGarch
library(fGarch)
fit <- garchFit(~ arma(0,1) + garch(1,1), data = trainer1, trace = FALSE)
predict(fit,n.ahead=24,plot=TRUE)

数据

df = structure(list(trainer = c(124.3, 98.99, 64, 64, 123.99, 123.99, 
34.97, 123.99, 139.91, 140, 164.3, 178.99, 140, 169.95, 161.18, 
139.94, 161.31, 124, 115.01, 124)), class = "data.frame", row.names = c(NA, 
-20L))