如何解决R Forecast 'ts' 对象必须有一个或多个观察
不明白为什么会出现以下错误。我不习惯在 r 中使用 ts 对象。我可以看到数据中有观察。
head(bike_sales)
library(tidyverse)
library(lubridate)
library(zoo)
library(sweep)
library(tidyr)
library(forecast)
library(forecastHybrid)
library(timetk)
data <- bike_sales %>%
mutate(order.month = as_date(as.yearmon(order.date))) %>%
group_by(category.secondary,customer.id,order.month) %>%
summarise(total.qty = sum(quantity))
nested_monthly <- data %>%
group_by(category.secondary,customer.id) %>%
rename()
nest(.key = "series") %>%
ungroup()
nested_monthly %>%
mutate(train.ts = map(series,~.x %>%
filter(order.month < make_date(2014,1,1)) %>%
tk_ts(frequency = 12,start = c(2011,1),end = c(2013,12),silent = T)),test.ts = map(series,~.x %>%
filter(order.month >= make_date(2014,1)) %>%
tk_ts(frequency = 12,start = c(2014,end = c(2015,# aggregate results for yearly predictions
train.ts.agg = map(train.ts,~.x %>%
stats::filter(.,rep(1,sides = 1) %>%
stats::window(start = c(2011,12))),test.ts.agg = map(test.ts,~.x %>%
stats::filter(.,sides = 1) %>%
stats::window(start = c(2014,12))))
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。