- Notifications
You must be signed in to change notification settings - Fork0
JSzitas/fable.tbats
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
fable.tbats is a wrapper around the implementation oftbatsoriginally from theforecastpackage, though it now works without this dependency.
pak::pkg_install("JSzitas/fable.tbats")
Used just like any model infable:
library(tsibbledata)library(fable)library(fable.tbats)library(dplyr)# fit models to the pelt dataset until 1930:train<-pelt %>% filter(Year<1930)test<-pelt %>% filter(Year>=1930)models<-train %>% model(ets= ETS(Lynx),bats= BATS(Lynx),tbats= TBATS(Lynx) )# generate forecasts on the test setforecasts<- forecast(models,test)# visualizeautoplot(forecasts,pelt)
Similarly, accuracy calculation works:
train_accuracies<- accuracy(models)knitr::kable(train_accuracies)
.model | .type | ME | RMSE | MAE | MPE | MAPE | MASE | RMSSE | ACF1 |
---|---|---|---|---|---|---|---|---|---|
ets | Training | -77.59902 | 12891.891 | 9824.778 | -20.073965 | 52.20456 | 0.9934890 | 0.9948210 | 0.5352087 |
bats | Training | 1768.39519 | 8540.088 | 6105.791 | -2.816831 | 27.18703 | 0.6174222 | 0.6590080 | 0.1656173 |
tbats | Training | 1653.48581 | 7955.411 | 5577.862 | -3.003260 | 26.36744 | 0.5640376 | 0.6138906 | 0.0367109 |
test_accuracies<- accuracy(forecasts,test)knitr::kable(test_accuracies)
.model | .type | ME | RMSE | MAE | MPE | MAPE | MASE | RMSSE | ACF1 |
---|---|---|---|---|---|---|---|---|---|
bats | Test | -10363.643 | 16253.210 | 10829.331 | -40.43004 | 43.33877 | NaN | NaN | 0.4460149 |
ets | Test | 1061.473 | 10669.984 | 9770.000 | -36.63239 | 71.41690 | NaN | NaN | 0.5558575 |
tbats | Test | -1898.560 | 3444.412 | 3208.959 | -16.86434 | 24.23634 | NaN | NaN | 0.1667398 |
As does refitting:
models<- refit(models,pelt )
Of the functionality available in theforecast package, onlyforecast::tbats.components() is missing.
Fitting bats/tbats to a few long series can (potentially) be slowerusing this wrapper than using the forecast package. This is due to thefact that the internal tbats/bats algorithm always executes sequentially(i.e. withuse.parallel = FALSE ) to prevent issues with nestedparallelism (as thefabletools::model function is taken to beresponsible for handling parallelization).
This should never be a problem on many time series, but does lead to asignificant slow-down if you are only modelling a single/few timeseries. Nonetheless, in those cases thefasster package might be muchbetter suited for your use case anyways.
About
A fable wrapper for TBATS
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.