fable: Error: Problem with `mutate()` input `arima`

1.7k Views Asked by At

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_tsibble(., index = time) %>% 
  model(arima = ARIMA(val))

fc<- fit %>% forecast(h=7)

It generates:

Error: Problem with `mutate()` input `arima`.
x Input must be a vector, not a `fcdist` object.
i Input `arima` is `(function (object, ...) ...`.

This is essentially the same as in this example. What am I missing? I already double checked for fat fingers error.

2

There are 2 best solutions below

6
On BEST ANSWER

It is working fine with fableTools ‘0.2.1’ and fpp3 0.3

fit %>%
     forecast(h = 7)
# A fable: 7 x 4 [1D]
# Key:     .model [1]
#  .model time             val .mean
#  <chr>  <date>        <dist> <dbl>
#1 arima  2010-04-11 N(100, 1)   100
#2 arima  2010-04-12 N(100, 2)   100
#3 arima  2010-04-13 N(100, 3)   100
#4 arima  2010-04-14 N(100, 4)   100
#5 arima  2010-04-15 N(100, 5)   100
#6 arima  2010-04-16 N(100, 6)   100
#7 arima  2010-04-17 N(100, 7)   100
0
On

Maybe a NAMESPACE problem. E.g some packages loaded, that masked the fable, fabletools functions.

Can easily happen in this case, since you loaded fable, fabletools only with a library(fpp3) call. You did not call with e.g. fable::forecast in your code and you also did not load library(fable) before.

When you just load library(fpp3) it will not mask functions for fable.

E.g.

library(forecast)
library(fpp3)

In this case, your code will call forecast::forecast(). The library(fpp3) call does not mask the forecast, model,ARIMA functions of other packages. So if you had forecast loaded in your Namespace before, you will in this case call forecast::forecast() instead of fable::forecast().

If you call

library("fpp3")
library("forecast")

You get:

Attache Paket: ‘forecast’

The following objects are masked from ‘package:fabletools’:
   accuracy, forecast

So maybe it would have worked, if you would have called library(fable), library(fabletools) before, since this would have made sure, similar named functions are masked. Or used fabletools::. This might also be why it worked after an update .. since the namespace was then free of other functions and loaded packages.