Timeseries in R error with fable: slicing a scalar

301 Views Asked by At

I am trying to use the tidyverts packages (tsibble, feasts, fable) to do some time series analysis. I am following along the tutorial here. The data is ten years of daily counts.

> summary(mockTsib)
      Date            CallTypeCode           calls       
 Min.   :2010-01-01   Length:11181       Min.   :  0.00  
 1st Qu.:2012-07-20   Class :character   1st Qu.:  7.00  
 Median :2015-02-07   Mode  :character   Median : 21.00  
 Mean   :2015-02-07                      Mean   : 32.71  
 3rd Qu.:2017-08-27                      3rd Qu.: 58.00  
 Max.   :2020-03-15                      Max.   :148.00 

I have a mable with one key column, three rows, and two columns of models (ets and arima).

> mockMod
# A mable: 3 x 3
# Key:     CallTypeCode [3]
  CallTypeCode ets          arima                   
  <chr>        <model>      <model>                 
1 A            <ETS(A,N,A)> <ARIMA(2,1,1)(0,0,2)[7]>
2 B            <ETS(A,N,A)> <ARIMA(2,1,2)(1,0,0)[7]>
3 S            <ETS(A,N,A)> <ARIMA(0,1,2)(2,0,0)[7]>

When I pipe to forecast() to forecast 30 days of data, I get the following error:

> mockMod %>% forecast(h = 30)
Error: Can't slice a scalar

However when I pass the model columns directly to forecast(), it seems there's no problem.

etsPredictions <- mockMod$ets %>% forecast(h = 30)
arimaPredictions <- mockMod$arima %>% forecast(h = 30)

I can then manually build the fable, but that is a real pain, and I'm worried that I'm skipping an error that I don't understand.

Can anyone help me understand this error?

0

There are 0 best solutions below