robjhyndman / forecast

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

Variance of fitted tbats model is very high #198

Closed nelsonauner closed 8 years ago

nelsonauner commented 8 years ago

Possibly related to an issue you closed: https://github.com/robjhyndman/forecast/issues/87 Original SO report here: http://stackoverflow.com/questions/34333967/computational-instability-in-r-forecast-package

When fitting a multiseasonal time series model with tbats, the variance of the fitted model is very high. In addition, the fitted model varies if you use


series <- c(10, 25, 8, 27, 18, 21, 12, 9, 31, 18, 8, 30, 14, 13, 10, 14, 
            14, 14, 6, 9, 22, 21, 22, 8, 7, 6, 22, 21, 36, 16, 2, 13, 23, 
            40, 12, 27, 18, 10, 11, 37, 44, 30, 40, 25, 13, 11, 58, 56, 46, 
            39, 28, 27, 19, 20, 97, 90, 70, 73, 30, 22, 97, 34)

x.msts <- msts(series,seasonal.periods = 7)
model_1 <- tbats(x.msts) #variance is 4.9e+17
model_2 <- tbats( series, seasonal.periods = 7) #variance is 0.969

This is still an issue if you have more than one seasonality factor :

x2.msts <- msts(series,seasonal.periods = c(7,30))
model_x2_1 <- tbats(x2.msts) #same high variance
model_x2_2 <- tbats( series, seasonal.periods = c(7,30) ) #also high variance

I accept that I might not be using these models as they are intended to be used, but I thought it was possible that the intended result of using this code may not be these high variance forecasts

nelsonauner commented 8 years ago

Sorry -- series is defined as:

series <- c(10, 25, 8, 27, 18, 21, 12, 9, 31, 18, 8, 30, 14, 13, 10, 14, 
            14, 14, 6, 9, 22, 21, 22, 8, 7, 6, 22, 21, 36, 16, 2, 13, 23, 
            40, 12, 27, 18, 10, 11, 37, 44, 30, 40, 25, 13, 11, 58, 56, 46, 
            39, 28, 27, 19, 20, 97, 90, 70, 73, 30, 22, 97, 34)
robjhyndman commented 8 years ago

Now fixed in https://github.com/robjhyndman/forecast/commit/1755d9d62b50bb37dd088d63dc7e393648abebde

nelsonauner commented 8 years ago

:+1: thank you. great package!