简体   繁体   中英

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

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.

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

Maybe a NAMESPACE problem. Eg 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 eg 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 .

Eg

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM