robjhyndman / forecast

Forecasting Functions for Time Series and Linear Models
http://pkg.robjhyndman.com/forecast
1.13k stars 342 forks source link

forecast 6.2 bats() gives 'inf' results but forecast 6.1 works fine. #189

Closed Yongyiw closed 8 years ago

Yongyiw commented 8 years ago

Hello, first I have to say this forecast package is so awesome! It helps a lot with our daily utility prediction and is amazingly accurate.

The problem is that after we updated to forecast 6.2(with R 3.2.2), the bats() provides a model that produce inf and '0' predictions. I believe it is probably a corner case, since bats() works fine in other time windows for forecast 6.2.

The problematic model in 6.2 is like:

BATS(0.01, {4,2}, 0.8, {24})

Call: bats(y = data.ts, use.box.cox = NULL, use.damped.trend = NULL, 
    seasonal.periods = 24, use.arma.errors = TRUE, bc.lower = 0, 
    bc.upper = 1)

Parameters
  Lambda: 0.009933
  Alpha: -0.0520767
  Beta: 0.07430051
  Damping Parameter: 0.8
  Gamma Values: -0.1739601
  AR coefficients: 2.070776 -2.083752 1.197448 -0.390615
  MA coefficients: -0.78427 0.33961

Seed States:
               [,1]
 [1,]  3.7759293191
 [2,]  0.0006916385
 [3,]  0.2056735986
 [4,]  0.0501103169
 [5,] -0.3305103752
 [6,] -0.6619372282
 [7,] -0.8291656805
 [8,] -0.7856205048
 [9,] -0.6695743390
[10,] -0.4535756170
[11,]  0.0153510219
[12,]  0.2094678983
[13,]  0.2868203867
[14,]  0.3141381458
[15,]  0.3150782736
[16,]  0.3378756196
[17,]  0.3716366608
[18,]  0.3133099874
[19,]  0.2175716936
[20,]  0.1640572134
[21,]  0.1173136127
[22,]  0.1570978708
[23,]  0.2693052790
[24,]  0.1266836493
[25,]  0.1220792424
[26,]  0.1539606912
[27,]  0.0000000000
[28,]  0.0000000000
[29,]  0.0000000000
[30,]  0.0000000000
[31,]  0.0000000000
[32,]  0.0000000000

Sigma: 5.846455e+19
AIC: 1059.342

Thanks in advance for your help :D

Yongyiw commented 8 years ago

Maybe related to https://github.com/robjhyndman/forecast/issues/28

robjhyndman commented 8 years ago

tbats works fine on the same data.

Yongyiw commented 8 years ago

Yes, tbats() works fine but bats() is not. But since tbats() considers multiple seasonalities and seems more stable (only produce one negative forecast as far as I observed) than bats(), so I just use tbats() with (24,168) seasonality for now.

And it doesn't matter with version 6.1 or 6.2, because in 6.1 bats() still make inf forecast on some other time windows.

At last, I have one question in my mind: Since for our data, ets MAdM model makes quite accurate forecast on weekdays and tbats() makes "conservative" forecast on weekends, does it make sense to concatenate the forecast made by MAdM on weekdays with that by tbats on weekends? Or is there any related work done by people I could refer to?

Thank you so much for your time, I am really appreciated for your help.

Yongyiw commented 8 years ago

We are building a near real-time forecasting application, so the stability of the forecasting models is also one of our concerns :)

robjhyndman commented 8 years ago

I started looking at this today on a different computer and needed to download the data again, but it has disappeared from the link provided. Can you please share again?

robjhyndman commented 8 years ago

Now fixed with https://github.com/robjhyndman/forecast/commit/79a8b94ba96535e3c08e4921f45cca72553134d5