预测R

时间:2018-02-23 15:08:36

标签: r forecasting density-plot volatility

这是我在这里发表的第一篇文章,所以我不太清楚如何在这里提出问题,但我会尽我所能 我试图预测每日汇率的密度,我选择欧元/美元作为我想预测的货币对。我正在使用GARCH模型进行预测。我使用“rugarch”包完成了我的编码。代码看起来像这样

> ex1 <- as.xts(DEXUSEU) #DEXUSEU is the daily data of exchange rates
> ex2 <- ex1[!is.na(ex1)] 
> lex2 <- 100*log((ex2[2:Nd,])/(ex2[1:(Nd-1),])) #taking log differences, it 
  has 4496 observations



> model1=ugarchspec (variance.model = list(model = "sGARCH", garchOrder = c(1, 
  1), submodel = NULL, external.regressors = NULL, variance.targeting = 
  FALSE),mean.model = list(armaOrder = c(0, 0), include.mean = TRUE, 
  archm = FALSE, archpow = 1, arfima = FALSE, external.regressors = NULL, 
  archex = FALSE),distribution.model = "std") #specifying garch model with 
  student t distribution


> modelfit1=ugarchfit(model,data=lex2,out.sample = 2000) #fitting model


> modelroll1=ugarchroll (
  model1, data=lex2, n.ahead = 1, forecast.length = 2000,
  n.start = NULL, refit.every = 50, refit.window = c("rolling"),
  window.size = NULL, solver = "hybrid", fit.control = list(),
  solver.control = list(), calculate.VaR = TRUE, VaR.alpha = 0.01,
  cluster = NULL, keep.coef = TRUE) #doing rolling window forecast

> plot(modelroll1,which=1)

这是密度预测的样子,我很确定这里出了问题,它不应该是这样的:

enter image description here

任何人都可以帮忙告诉我我做错了什么。如果需要,我可以提供额外的数据/信息。我不知道还能提供什么,因为这是我在这里的第一篇文章。任何形式的帮助都将非常感激。

0 个答案:

没有答案