1

这是我的代码:

library(fpp3)
val <- seq(1,100,1)
time <- seq.Date(as.Date("2010-01-01"),  by = "day", length.out =  100 )
df <- data.frame(val = val, time = time)
fit <- df %>% as_tibble(., index = time) %>%
  model(arima = ARIMA(val))

它会产生错误:

Error in UseMethod("model") : 
  no applicable method for 'model' applied to an object of class "c('tbl_df', 'tbl', 'data.frame')"

我不确定我做错了什么。我看不出它与这个寓言的例子有什么不同

4

1 回答 1

1

在这里,我们需要as_tsibble而不是as_tibble. 根据?model

.data - 适用于模型的数据结构(例如 tsibble)

library(dplyr)
library(fpp3)
df %>% 
    as_tsibble(., index = time) %>% 
    model(arima = ARIMA(val))
# A mable: 1 x 1
#           arima
#         <model>
#1 <ARIMA(0,1,0)>
于 2020-09-10T20:21:21.767 回答