对 R 中两个时间序列对象的行元素求和



我有一个两ts对象

如下
> ts_forecast$mean
Sep      Oct      Nov
5 12.74330 13.44875 14.15419

> tail(ts_full$time.series[,2],n=3)
Jun      Jul      Aug
5 55.22149 55.64993 56.22575

ts_forecast$mean我从stlf预测函数中得到(package forecast).ts_full只不过是时间序列的随机部分,并且是作为

ts_full <-stl(ts_historic,s.window='periodic') 
ts_full$time.series[,2] <----Trend part
ts_full$time.series[,3] <-----Random Part and this was used in stlf forecast function. 

目标:我想将趋势部分添加到上面获得的三个预测值中。

简单来说:

forecast_mean <-ts_forecast$mean + tail(ts_full$time.series[,2],n=3)

但是我收到一条警告消息:

Warning message:
In .cbind.ts(list(e1, e2), c(deparse(substitute(e1))[1L], deparse(substitute(e2))[1L]),  :
non-intersecting series

我不想使用mean(tail(ts_full$time.series[,2],n=3))并将其添加到ts_forecast$mean. 我在这里缺少什么?是因为ts_forecast$meants_full的月份不同吗?

欣赏任何线索。

forecast_mean <- suppressWarnings(as.numeric(ts_forecast$mean) + as.numeric(tail(ts_full$time.series[,2],n=3)))

最新更新