Skip to content
SK Subham KumarTSF Hub · time-series forecasting
Classical & statistical2011Multiple seasonalityState space

TBATS

Trigonometric seasonality, Box-Cox, ARMA errors, Trend and Seasonal components

An exponential-smoothing state-space model built for complex seasonality: hourly data with daily and weekly cycles, or daily data with a 365.25-day year.

Overview

ETS and SARIMA handle one seasonal period of modest length. Real data often has several: electricity load has daily, weekly and yearly cycles; call-centre volume has half-hourly and weekly ones. TBATS models each seasonal pattern with a small number of Fourier (trigonometric) terms, so long and even non-integer periods cost only a handful of parameters.

A Box-Cox transform stabilises the variance, a damped trend captures growth, and ARMA errors soak up leftover autocorrelation. The automatic version tries combinations and picks the best by AIC.

How it works

On the Box-Cox transformed series \(y_t^{(\omega)}\):

\[y_t^{(\omega)}=\ell_{t-1}+\phi b_{t-1}+\sum_{i=1}^{M}s^{(i)}_{t-1}+d_t\]

Each seasonal component \(i\) with period \(m_i\) is a sum of \(k_i\) harmonics, \(s^{(i)}_t=\sum_{j=1}^{k_i}s^{(i)}_{j,t}\), that rotate with frequency \(\lambda_j=2\pi j/m_i\):

\[s_{j,t}=s_{j,t-1}\cos\lambda_j+s^{*}_{j,t-1}\sin\lambda_j+\gamma_1 d_t,\qquad s^{*}_{j,t}=-s_{j,t-1}\sin\lambda_j+s^{*}_{j,t-1}\cos\lambda_j+\gamma_2 d_t\]

\(d_t\) follows an ARMA(p, q) process; level \(\ell_t\) and damped trend \(b_t\) update as in ETS.

When to use it

Use it for

  • Hourly or sub-daily data with daily + weekly cycles
  • Daily data with yearly seasonality (period 365.25)
  • When you want prediction intervals with minimal tuning

Avoid it for

  • Very long series where fitting becomes slow (try MSTL or Prophet)
  • Series driven mainly by external variables

Key settings

SettingWhat it controlsTypical value
season_lengthList of seasonal periods[24, 168] hourly; [7, 365.25] daily
use_boxcoxVariance-stabilising transformauto
use_damped_trendDamp the trend over the horizonauto
use_arma_errorsModel residual autocorrelationauto

Python example

✓ Tested: runs end to endDownload tbats.py
import numpy as np
import pandas as pd
from statsforecast import StatsForecast
from statsforecast.models import AutoTBATS, SeasonalNaive

# four weeks of hourly demand with a daily (24h) and a weekly (168h) cycle
rng = np.random.default_rng(42)
t = np.arange(24 * 7 * 4)
y = (100 + 0.02 * t + 15 * np.sin(2 * np.pi * t / 24) + 8 * np.sin(2 * np.pi * t / 168)
     + rng.normal(0, 3, t.size))
df = pd.DataFrame({"unique_id": "demand",
                   "ds": pd.date_range("2025-01-06", periods=t.size, freq="h"), "y": y})
train, test = df.iloc[:-48], df.iloc[-48:]

sf = StatsForecast(models=[AutoTBATS(season_length=[24, 168]), SeasonalNaive(season_length=168)],
                   freq="h")
fc = sf.forecast(df=train, h=48, level=[80])
for col in ["AutoTBATS", "SeasonalNaive"]:
    print(f"{col:14s} MAE {np.mean(np.abs(test['y'].values - fc[col].values)):.2f}")
print(fc[["ds", "AutoTBATS", "AutoTBATS-lo-80", "AutoTBATS-hi-80"]].head(3))

Tips & pitfalls

  • Give TBATS at least two full cycles of the longest period.
  • Fitting is slower than ETS; batch many series with statsforecast to parallelise.
  • Compare against MSTL + ETS, which is often faster with similar accuracy.

References

  1. De Livera, A. M., Hyndman, R. J., & Snyder, R. D. (2011). Forecasting time series with complex seasonal patterns using exponential smoothing. Journal of the American Statistical Association, 106(496), 1513–1527.