arfimaforecast-methods(rugarch)
arfimaforecast-methods()所属R语言包:rugarch
function: ARFIMA Forecasting
功能:ARFIMA预测
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Method for forecasting from an ARFIMA model.
从ARFIMA模型预测方法。
用法----------Usage----------
arfimaforecast(fitORspec, data = NULL, n.ahead = 10, n.roll = 0, out.sample = 0,
external.forecasts = list(mregfor = NULL), ...)
参数----------Arguments----------
参数:fitORspec
Either an ARFIMA fit object of class ARFIMAfit or alternatively an ARFIMA specification object of class ARFIMAspec with valid parameters supplied via the fixed.pars argument in the specification.
无论是一个的ARFIMA适合对象类ARFIMAfit或者一个的ARFIMA规范对象的类ARFIMAspec提供有效的参数通过fixed.pars参数的规范。
参数:data
Required if a specification rather than a fit object is supplied.
被供给时需要的规范,而不是一个合适的对象。
参数:n.ahead
The forecast horizon.
预测水平。
参数:n.roll
The no. of rolling forecasts to create beyond the first one (see details).
没有。滚动预测,以创造超越的第一个(见详情)。
参数:out.sample
Optional. If a specification object is supplied, indicates how many data points to keep for out of sample testing.
可选。如果提供一个规范的对象,表示保留多少个数据点出样品测试。
参数:external.forecasts
A list with a matrix of forecasts for the external regressors in the mean.
列表矩阵的外部回归系数的平均预测。
参数:...
.
。
Details
详细信息----------Details----------
The forecast function has two dispatch methods allowing the user to call it with either a fitted object (in which case the data argument is ignored), or a specification object (in which case the data is required) with the parameters entered via the set.fixed<- methods on an ARFIMAspec object.<br> One step ahead forecasts are based on the value of the previous data, while n-step ahead (n>1) are based on the unconditional mean of the model.<br> The ability to roll the forecast 1 step at a time is implemented with the n.roll argument which controls how many times to roll the n.ahead forecast. The default argument of n.roll = 0 denotes no rolling beyond the first forecast and returns the standard n.ahead forecast. Critically, since n.roll depends on data being available from which to base the rolling forecast, the arfimafit function needs to be called with the argument out.sample being at least as large as the n.roll argument, or in the case of a specification being used instead of a fit object, the out.sample argument directly in the forecast function.
的预测函数有两个调度允许用户调用它与嵌合对象(在这种情况下,参数的数据被忽略),或一个规范对象的参数(在这种情况下,需要对数据进行)的方法通过<输入X>set.fixed<-对象。<BR>一步超前预测是基于以前的数据的价值的方法,而N-领先一步(N> 1)的基础上的无条件均值的模型。参考的能力,一步一个脚印滚动预测实现的ARFIMAspec参数,它控制了多少遍推出的n.ahead的预测。默认参数的n.roll = 0表示没有滚动超出了第一的预测,并返回标准n.ahead预测。更重要的是,因为n.roll取决于数据所依据的滚动预测,n.roll功能需要调用的参数arfimafit至少的n.roll参数,或在一个合适的对象,而不是正在使用的规范,out.sample直接在预测函数的参数的情况下。
值----------Value----------
A ARFIMAforecast object containing details of the ARFIMA forecast. See the class for details on the returned object and methods for accessing it and performing some tests.
AARFIMAforecast对象,其中详细的ARFIMA预测。在返回的对象和方法来访问它,并进行了一些测试的详细信息,请参阅类。
(作者)----------Author(s)----------
Alexios Ghalanos
实例----------Examples----------
## Not run: [#不运行:]
# Long Horizon Forecast[龙地平线预测]
data(sp500ret)
fit = vector(mode = "list", length = 9)
dist = c("norm", "snorm", "std", "sstd", "ged", "sged", "nig", "ghyp", "jsu")
for(i in 1:9){
spec = arfimaspec(mean.model = list(armaOrder = c(1,1), include.mean = TRUE,
arfima = FALSE), distribution.model = dist[i])
fit[[i]] = arfimafit(spec = spec, data = sp500ret, solver = "solnp",
fit.control = list(scale = 1))
}
cfmatrix = matrix(NA, nrow = 9, ncol = 7)
colnames(cfmatrix) = c("mu", "ar1", "ma1", "sigma", "skew", "shape", "ghlambda")
rownames(cfmatrix) = dist
for(i in 1:9){
cf = coef(fit[[i]])
cfmatrix[i, match(names(cf), colnames(cfmatrix))] = cf
}
umean = rep(0, 9)
for(i in 1:9){
umean[i] = uncmean(fit[[i]])
}
forc = vector(mode = "list", length = 9)
for(i in 1:9){
forc[[i]] = arfimaforecast(fit[[i]], n.ahead = 100)
}
lmean40 = sapply(forc, FUN = function(x) as.numeric(as.data.frame(x)[40,1]))
cfmatrix1 = cbind(cfmatrix, umean, lmean40)
colnames(cfmatrix1) = c(colnames(cfmatrix1[,1:7]), "uncmean", "forecast40")
# forecast with spec to check results[预测与规格的检查结果]
forc2 = vector(mode = "list", length = 9)
for(i in 1:9){
spec = arfimaspec(mean.model = list(armaOrder = c(1,1), include.mean = TRUE,
arfima = FALSE), distribution.model = dist[i])
setfixed(spec) = as.list(coef(fit[[i]]))
forc2[[i]] = arfimaforecast(spec, data = sp500ret, n.ahead = 100)
}
lmean240 = sapply(forc2, FUN = function(x) as.numeric(as.data.frame(x)[40,1]))
cfmatrix2 = cbind(cfmatrix, umean, lmean240)
colnames(cfmatrix2) = c(colnames(cfmatrix2[,1:7]), "uncmean", "forecast40")
cat("\nARFIMAforecast from ARFIMAfit and ARFIMAspec check:")
cat("\nFit\n")
print(cfmatrix1, digits = 4)
cat("\nSpec\n")
print(cfmatrix2, digits = 4)
# methods and slots[方法和槽]
slotNames(forc[[1]])
showMethods(classes="ARFIMAforecast")
# summary[总结]
show(forc[[1]])
# Extractor Functions[提取功能]
# as array (array dimension [3] is 1 since n.roll = 0 i.e. no rolling beyond [作为数组(array维[3]为1,因为n.roll = 0,即没有滚动超越]
# the first)[第一批)]
as.array(forc[[1]])
# as.data.frame[as.data.frame]
as.data.frame(forc[[1]])
# as.list[as.list]
as.list(forc[[1]])
# Rolling Forecast[滚动预测]
data(sp500ret)
fit = vector(mode = "list", length = 9)
dist = c("norm", "snorm", "std", "sstd", "ged", "sged", "nig", "ghyp", "jsu")
for(i in 1:9){
spec = arfimaspec(mean.model = list(armaOrder = c(1,1), include.mean = TRUE,
arfima = FALSE), distribution.model = dist[i])
fit[[i]] = arfimafit(spec = spec, data = sp500ret, solver = "solnp",
out.sample = 1000, fit.control = list(scale = 1))
}
cfmatrix = matrix(NA, nrow = 9, ncol = 7)
colnames(cfmatrix) = c("mu", "ar1", "ma1", "sigma", "skew", "shape", "ghlambda")
rownames(cfmatrix) = dist
for(i in 1:9){
cf = coef(fit[[i]])
cfmatrix[i, match(names(cf), colnames(cfmatrix))] = cf
}
forc = vector(mode = "list", length = 9)
for(i in 1:9){
forc[[i]] = arfimaforecast(fit[[i]], n.ahead = 1, n.roll = 999)
}
rollforc = sapply(forc, FUN = function(x) t(unlist(as.data.frame(x,
rollframe = "all", aligned = FALSE))))
# forecast performance measures:[预测的性能指标:]
fpmlist = vector(mode = "list", length = 9)
for(i in 1:9){
fpmlist[[i]] = fpm(forc[[i]], summary = FALSE)
}
par(mfrow = c(1,2))
dd = rownames(tail(sp500ret, 1250))
clrs = rainbow(9, alpha = 1, start = 0.4, end = 0.95)
plot(as.Date(dd), tail(sp500ret[,1], 1250), type = "l",
ylim = c(-0.02, 0.02), col = "lightgrey", ylab = "", xlab = "",
main = "Rolling 1-ahead Forecasts\nvs Actual")
for(i in 1:9){
tmp = tail(sp500ret[,1], 1250)
tmp[251:1250] = rollforc[1:1000,i]
lines(as.Date(dd), c(rep(NA, 250), tmp[-(1:250)]), col = clrs[i])
}
legend("topleft", legend = dist, col = clrs, fill = clrs, bty = "n")
# plot deviation measures and range[图偏差的措施和范围]
tmp = vector(mode = "list", length = 9)
for(i in 1:9){
tmp[[i]] = fpmlist[[i]][,"AE"]
names(tmp[[i]]) = dist[i]
}
boxplot(tmp, col = clrs, names = dist, range = 6, notch = TRUE,
main = "Rolling 1-ahead Forecasts\nAbsolute Deviation Loss")
# fpm comparison[FPM比较]
compm = matrix(NA, nrow = 3, ncol = 9)
compm = sapply(fpmlist, FUN = function(x) c(mean(x[,"SE"]), mean(x[,"AE"]),
mean(x[,"DAC"])))
colnames(compm) = dist
rownames(compm) = c("MSE", "MAD", "DAC")
cat("\nRolling Forecast FPM\n")
print(compm, digits = 4)
cat("\nMethods Check\n")
as.data.frame(forc[[1]], rollframe = 0)
as.data.frame(forc[[1]], rollframe = 999)
t(as.data.frame(forc[[1]], rollframe = "all", aligned = FALSE))
fpm(forc[[1]], summary = TRUE)
show(forc[[1]])
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|