2

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?

Adrian Martin
  • 780
  • 7
  • 21
  • Please provide a reproducible example of the problem. – Rob Hyndman Apr 01 '20 at 21:21
  • Unfortunately the reproducible example I built doesn't lead to the error! And I am not sure why. The classes of each column of the tsibble are identical, both include zero counts, no NA values, no factor levels. I did find that the xreg part of the fit of the models in my real data was NULL; in my attempt to reproduce the problem, it's a matrix, length 1/3 of my data. I forced xregs in my functioning mable to NULL and forecast() still worked. Willing to try any ideas you have! – Adrian Martin Apr 02 '20 at 02:41
  • 1
    Unless you can provide a reproducible example, I can't help. – Rob Hyndman Apr 02 '20 at 05:17
  • I started from scratch and rewrote my code and the error does not reappear, so this is moot. – Adrian Martin Apr 03 '20 at 21:14

0 Answers0