Applying models to multiple time-series

落爺英雄遲暮 提交于 2019-12-04 12:52:14

Simply use lapply here:

res <- lapply(dat.ts,arima,order=c(1,0,1))

If you want to use different order parameter for each time serie, you can use Map or mapply:

## generate a random list of orders
orders <- lapply(seq_len(ncol(dat.ts)),function(x)sample(c(0,1),3,rep=T))
## for each serie compute its arima with its corresponding order
Map(function(x,ord)arima(x,ord),as.list(dat.ts),orders)

EDIT get order using auto.arima fom forecast package:

Note I am rarely use this package, so I am not sure of the final result. I show here just the idea of using lapply:

orders <- lapply(dat.ts,function(x){
             mod <- auto.arima(x)
             mod$arma[c(1, 6, 2, 3, 7, 4, 5)][1:3]
 })
$Americas_Globe
[1] 0 1 0
$Americas_Lucky
[1] 0 1 0
$Americas_Star
[1] 0 1 1
$Asia_Star
[1] 0 1 0
$EuroPac_Globe
[1] 0 1 0
$EuroPac_Lucky
[1] 0 1 0
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!