robjhyndman / forecast

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

Thetaf creates extreme unrealistic high forecasts #867

Closed Someone894 closed 3 years ago

Someone894 commented 3 years ago

Over the time I've seen some rare cases, where the thetaf forecast creates extreme unrealistic big forecasts. Since these cases are rare and some days ago I found one of them, I thought it would be good to show it to you.

Here is a MWE:

raw <- c(
  203.18450, 0.00050, 0.00050, 0.00050, 0.00050, 0.00050, 0.00050,
  0.00050, 0.00050, 0.00050, 0.00050, 0.00050, 196.42155, 0.00050,
  0.00050, 0.00050, 0.00050, 0.00050, 0.00050, 0.00050, 0.00050,
  0.00050, 674.73050, 130.85868, 269.89313, 0.00050, 0.00050, 0.00050,
  0.00050, 0.00050, 0.00050, 81.39669, 74.31876, 0.00050, 603.28991,
  0.00050, 0.00050, 0.00050, 0.00050, 0.00050, 0.00050, 210.23732,
  0.00000, 105.11868, 301.64441, 0.00050, 513.91272, 210.23732, 0.00050,
  0.00050, 0.00050, 121.71787, 0.00050, 0.00050, 0.00050, 0.00050,
  0.00050, 0.00050, 0.00050, 0.00050, 220.24812, 0.00050, 0.00050,
  0.00050, 0.00050, 243.43418, 0.00050, 0.00050, 0.00050,
  420.47686, 0.00050
)

bad <- forecast::thetaf(ts(raw, frequency = 12), 24)

# max(raw)      ->     674.7305
# max(bad$mean) -> 8678388

This is the result on my win 10 x86_64 laptop:

      Point Forecast    Lo 80    Hi 80      Lo 95    Hi 95
Dec 6  1090444.82330 -3201579  5382469 -5473639.8  7654529
Jan 7  6877335.56059  2585311 11169360   313250.9 13441420
Feb 7       20.12222 -4292004  4292044 -6564064.6  6564105
Mar 7       20.32050 -4292004  4292045 -6564064.4  6564105
Apr 7   591235.07224 -3700789  4883259 -5972849.7  7155320
May 7       13.25812 -4292011  4292038 -6564071.5  6564098
Jun 7   891127.10654 -3400897  5183151 -5672957.7  7455212
Jul 7       24.12397 -4292000  4292049 -6564060.7  6564109
Aug 7   793328.32517 -3498696  5085353 -5770756.6  7357413
Sep 7  1393072.46158 -2898952  5685097 -5171012.4  7957157
Oct 7       25.28653 -4291999  4292050 -6564059.7  6564110
Nov 7  7799462.42959  3507438 12091487  1235377.5 14363547
Dec 7  1227483.62699 -3064541  5519508 -5336601.4  7791569
Jan 8  7732669.08532  3440645 12024694  1168584.0 14296754
Feb 8       22.59914 -4292002  4292047 -6564062.5  6564108
Mar 8       22.79644 -4292002  4292047 -6564062.3  6564108
Apr 8   662549.57376 -3629475  4954574 -5901535.6  7226635
May 8       14.84139 -4292010  4292039 -6564070.3  6564100
Jun 8   996496.18522 -3295528  5288521 -5567589.0  7560581
Jul 8       26.94862 -4291998  4292052 -6564058.3  6564112
Aug 8   885320.53560 -3406704  5177345 -5678764.7  7449406
Sep 8  1553063.37312 -2738961  5845088 -5011021.9  8117149
Oct 8       28.16310 -4291997  4292053 -6564057.2  6564113
Nov 8  8678387.58569  4386363 12970412  2114302.2 15242473

Do you have any idea where this comes from and what one can do about it?

robjhyndman commented 3 years ago

Fixed in https://github.com/robjhyndman/forecast/commit/4204d3f053db05c0944ca75a43017f535790f1d5