使用GARCH进行时间序列预测 [英] Time Series Forecasting with GARCH

查看:425
本文介绍了使用GARCH进行时间序列预测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to forecast a time series object in R with GARCH(1,1) model. My goal is to hav 24 instances ahead forecast with the GARCH model. Although I am using a time series object while forecasting,I get the following error:

is.constant(y)中的错误: (列表)对象不能强制输入"double"

Error in is.constant(y) : (list) object cannot be coerced to type 'double'

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

Those are the commands that I am using:

library(forecast)
library(tseries)


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

我正在使用的示例数据如下:

And the sample data that I am using is as follows:

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进行预测,您必须使用

The garch is not a function of forecast package. So, you cannot apply forecast function on m1 model. The garch function is available in tseries package. So, to use garch for prediction you have to use

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

如果您要进行预测,可以使用fGarch程序包之类的

If you want to forecast you can use fGarch package like

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))

这篇关于使用GARCH进行时间序列预测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆