请选择 进入手机版 | 继续访问电脑版
楼主: yangyifan1003
21311 18

[问答] R ugarchforecast rolling window遇到的问题 [推广有奖]

jete 发表于 2017-5-23 13:21:28 |显示全部楼层 |坛友微信交流群
yangyifan1003 发表于 2014-4-28 21:31
这是我的例子,希望能帮助到你
getSymbols("^GSPC", src = "yahoo",from="2000-01-01",to="2014-03-31") ...
感谢!

使用道具

ryoeng 在职认证  发表于 2018-9-20 01:43:38 |显示全部楼层 |坛友微信交流群
yangyifan1003 发表于 2014-4-28 21:31
这是我的例子,希望能帮助到你
getSymbols("^GSPC", src = "yahoo",from="2000-01-01",to="2014-03-31") ...
您好,僕前阵子使用ugarchroll并没有使用out.sample参数而使用n.start = ns, forecast.length = n,就不晓得会不会是out.sample一样呢?out.sample的原理是把原有数据分成in.sample来预测out.sample,而in.sampleout.sample相等于完整数据的n数量。僕使用n.start = ns, forecast.length = n的原理是从完整数据中的n点开始预测直到完整数据n数量为止。不晓得效果会不会一样呢?
4.1.2 Method 2 : Markov Chain
  1. armaOrder = opt_arma(x)
  2.    
  3.     spec = ugarchspec(
  4.     variance.model = list(
  5.         model = 'sGARCH', garchOrder = c(1, 1),
  6.     submodel = NULL, external.regressors = NULL,
  7.     variance.targeting = FALSE),
  8.     mean.model = list(
  9.         armaOrder = armaOrder[c(1, 3)],
  10.         include.mean = TRUE, archm = FALSE,
  11.         archpow = 1, arfima = TRUE,
  12.         external.regressors = NULL,
  13.         archex = FALSE),
  14.     fixed.pars = list(arfima = armaOrder[2]),
  15.     distribution.model = 'snorm')
  16.    
  17.     ns <- which(index(x) == timeID0)
  18.     n <- nrow(x) - ns

  19.     roll <- ugarchroll(spec, data = x, n.start = ns, forecast.length = n,
  20.                        refit.every = 1, refit.window = 'moving',
  21.                        cluster = .cl)
复制代码
原文:binary.com Interview Question I - Comparison of Univariate GARCH Models

Scιβrοκεrs Trαdιηg
世博量化
http://gitee.com/englianhu

使用道具

ryoeng 在职认证  发表于 2018-9-20 02:20:00 |显示全部楼层 |坛友微信交流群
ryoeng 发表于 2018-9-20 01:43
您好,僕前阵子使用ugarchroll并没有使用out.sample参数而使用n.start = ns,  ...
刚刚再次查询了下ugarchroll-methods,才发现当初走马看花,理解错误。

n.start

Instead of forecast.length, this determines the starting point in the dataset from which to initialize the rolling forecast.


forecast.length

The length of the total forecast for which out of sample data from the dataset will be used for testing.


n.start是数据的初始点,而forecast.length是out.sample,再加上refit.window=1和moving.window的话,那么就可以知道数据量、起始点和开始预测的日期直到完整数据n。(怪不得当初僕就奇怪为啥运行后的结果会那么奇怪,所以也干脆使用最原始的方法就是自个儿定义移动数据的多寡与起始点,通过for loop来逐日预测如以下4.1.3。)
4.1.3 Method 3 : Markov Chain 2
  1. ...
复制代码
原文:binary.com Interview Question I - Comparison of Univariate GARCH Models

Scιβrοκεrs Trαdιηg
世博量化
http://gitee.com/englianhu

使用道具

ev2018 发表于 2020-3-7 21:22:13 |显示全部楼层 |坛友微信交流群
ryoeng 发表于 2018-9-20 02:20
刚刚再次查询了下ugarchroll-methods,才发现当初走马看花,理解错误。

n.startInstead of forecast ...
请问为什么我用ugarchforecast预测出来的,始终是一条直线呀?n.roll是滚动预测阶数, n.ahead是测试集的元素个数,这样理解对吗?所以n.roll应该如何设置呢?查了help,但是没有看懂……

使用道具

ryoeng 在职认证  发表于 2020-3-14 00:31:22 来自手机 |显示全部楼层 |坛友微信交流群
ev2018 发表于 2020-3-7 21:22
请问为什么我用ugarchforecast预测出来的,始终是一条直线呀?n.roll是滚动预测阶数, n.ahead是测试集的 ...
用 ugarchforecast(n.ahead) 吧!我也是使用forecast而非n.roll,n.roll不好使。

使用道具

ev2018 发表于 2020-3-14 12:14:53 |显示全部楼层 |坛友微信交流群
ryoeng 发表于 2020-3-14 00:31
用 ugarchforecast(n.ahead) 吧!我也是使用forecast而非n.roll,n.roll不好使。
比如我2400个样本,取最后的90个做回测,前面的2310全是训练集
那么只留一个n.ahead=90的参数吗?

使用道具

ryoeng 在职认证  发表于 2020-3-18 00:47:01 来自手机 |显示全部楼层 |坛友微信交流群
ev2018 发表于 2020-3-14 12:14
比如我2400个样本,取最后的90个做回测,前面的2310全是训练集
那么只留一个n.ahead=90的参数吗?
我看了ugarchroll还是不清楚怎么使用,或许你可以直接联系作者。他以下的个人部落格有他的联系方式。
http://www.unstarched.net/about/

相关文章:
1 https://r.789695.n4.nabble.com/Getting-different-days-ahead-forecast-apart-from-of-1-day-ahead-using-rugarch-td4407321.html
2 https://books.google.com.ph/books?id=LlEyDwAAQBAJ&pg=PA179&lpg=PA179&dq=ugarchroll+n.ahead&source=bl&ots=SwiXYcgxRt&sig=ACfU3U16qJa_d-qYjuy9qMWgpV5kFcdsig&hl=zh-CN&sa=X&ved=2ahUKEwiXgIHR-aHoAhWsy4sBHe2TDLUQ6AEwAnoECAcQAQ#v=onepage&q=ugarchroll%20n.ahead&f=false

使用道具

ev2018 发表于 2020-3-18 12:04:29 |显示全部楼层 |坛友微信交流群
ryoeng 发表于 2020-3-18 00:47
我看了ugarchroll还是不清楚怎么使用,或许你可以直接联系作者。他以下的个人部落格有他的联系方式。
ht ...
十分感谢,不过我打算自己写脚本了

使用道具

13210360 发表于 2022-2-12 16:34:16 |显示全部楼层 |坛友微信交流群
yangyifan1003 发表于 2014-4-28 21:31
这是我的例子,希望能帮助到你
getSymbols("^GSPC", src = "yahoo",from="2000-01-01",to="2014-03-31") ...
大佬,可以请教您n.ahead取1是不是向前一步样本外滚动预测呢,我想做的滚动预测是训练集数量一定,每次向后滚动一天这种,可以直接像您那样写吗。

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-4-16 22:41