楼主: saiyanxtc
1643 2

[问答] 如何用R做iterated forecast [推广有奖]

  • 14关注
  • 0粉丝

高中生

20%

还不是VIP/贵宾

-

威望
0
论坛币
0 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
1314 点
帖子
13
精华
0
在线时间
31 小时
注册时间
2014-7-30
最后登录
2016-8-18

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
求大神指导一下,怎么用R写iterated two-quarter ahead out of sample forecast,多谢多谢。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:iterated Forecast forecas ERAT Rate 如何

沙发
DM小菜鸟 发表于 2014-12-28 22:17:08 |只看作者 |坛友微信交流群
呃,都贴进来吧,都用得上...

One-step forecasts without re-estimation

train <- window(hsales,end=1989.99)
fit <- auto.arima(train)
refit <- Arima(hsales, model=fit)
fc <- window(fitted(refit), start=1990)

Multi-step forecasts without re-estimation

h <- 5
train <- window(hsales,end=1989.99)
test <- window(hsales,start=1990)
n <- length(test) - h + 1
fit <- auto.arima(train)
fc <- ts(numeric(n), start=1990+(h-1)/12, freq=12)
for(i in 1:n)
{  
  x <- window(hsales, end=1989.99 + (i-1)/12)
  refit <- Arima(x, model=fit)
  fc <- forecast(refit, h=h)$mean[h]
}

Multi-step forecasts with re-estimation

h <- 5
train <- window(hsales,end=1989.99)
test <- window(hsales,start=1990)
n <- length(test) - h + 1
fit <- auto.arima(train)
order <- arimaorder(fit)
fcmat <- matrix(0, nrow=n, ncol=h)
for(i in 1:n)
{  
  x <- window(hsales, end=1989.99 + (i-1)/12)
  refit <- Arima(x, order=order[1:3], seasonal=order[4:6])
  fcmat[i,] <- forecast(refit, h=h)$mean
}
A variation on this also re-selects the model at each iteration. Then the second line in the loop is replaced with
refit <- auto.arima(x)

使用道具

藤椅
saiyanxtc 发表于 2015-8-14 21:04:27 来自手机 |只看作者 |坛友微信交流群
厉害 学习学习

使用道具

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

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

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

GMT+8, 2024-6-15 09:35