user1700890
user1700890

Reputation: 7730

fable package error: no applicable method for 'model' applied to

Here is my code:

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))

It generates error:

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

I am not sure what I am doing wrong. I do not see how it is different from this fable example

Upvotes: 2

Views: 2597

Answers (1)

akrun
akrun

Reputation: 887048

Here we, need as_tsibble instead of as_tibble. According to ?model

.data - A data structure suitable for the models (such as a 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)>

Upvotes: 3

Related Questions