Formula Deep-Dive: Time Series Forecasting Methods
What is Time Series Forecasting?
Goal: Predict future values based on historical patterns in sequential data.
Examples: Stock prices, temperature, sales, website traffic
Key Assumption: Past patterns will continue into the future
ARIMA: AutoRegressive Integrated Moving Average
- \(p\) = order of AutoRegression (AR)
- \(d\) = degree of differencing (I)
- \(q\) = order of Moving Average (MA)
Component 1: AR (AutoRegressive)
Predict current value from previous values:
Example: Today's temperature depends on yesterday's and the day before.
- \(y_t\) = value at time \(t\)
- \(\phi_i\) = coefficients (weights)
- \(\epsilon_t\) = error term
Component 2: I (Integrated / Differencing)
Remove trend by taking differences:
Why? Many time series have trends (upward/downward). Differencing makes them stationary (constant mean).
Example: Sales: [100, 105, 110, 115] → Differences: [5, 5, 5] (now stationary!)
Component 3: MA (Moving Average)
Predict from previous forecast errors:
Insight: If we overshot yesterday's forecast, adjust today's prediction.
- \(\theta_i\) = MA coefficients
- \(\epsilon_{t-i}\) = past forecast errors
Full ARIMA Model
Combining all three components:
Where:
- \(B\) = backshift operator (\(By_t = y_{t-1}\))
- \(\phi(B)\) = AR polynomial
- \(\theta(B)\) = MA polynomial
- \((1-B)^d\) = differencing operator
Choosing Parameters (p, d, q)
- d: Apply differencing until data is stationary (constant mean/variance)
- p: Look at ACF (AutoCorrelation Function) plot
- q: Look at PACF (Partial AutoCorrelation Function) plot
- Or use AIC/BIC to compare models automatically
SARIMA: Seasonal ARIMA
- \((p,d,q)\) = non-seasonal part (same as ARIMA)
- \((P,D,Q)\) = seasonal part
- \(m\) = seasonal period (e.g., 12 for monthly data with yearly seasonality)
The Problem with ARIMA
ARIMA can't handle seasonality (repeating patterns):
- Ice cream sales peak every summer
- Website traffic drops every weekend
- Electricity usage spikes at 6 PM daily
SARIMA adds seasonal components to capture these patterns.
Seasonal Components
Seasonal AR (P)
Value depends on same period in previous cycles:
Example: January sales depend on last January, January before that, etc.
Seasonal Differencing (D)
Remove seasonal trend:
Example: \(y_{\text{Jan 2026}} - y_{\text{Jan 2025}}\)
Seasonal MA (Q)
Adjust based on seasonal forecast errors:
Example: Monthly Sales
SARIMA(1,1,1)(1,1,1)12
- (1,1,1): Short-term dependencies (yesterday affects today)
- (1,1,1)12: Seasonal dependencies (last January affects this January)
- m=12: Monthly data with yearly cycle
Holt-Winters (Triple Exponential Smoothing)
Philosophy: Recent observations matter more than old ones.
Three components: Level, Trend, Seasonality
The Three Equations
1. Level (Smoothed Series)
Weighted average of deseasonalized observation and forecasted level.
2. Trend (Slope)
Weighted average of current trend and previous trend.
3. Seasonality
Weighted average of current seasonal index and seasonal index from same period last cycle.
Forecast (h steps ahead)
- \(\alpha\) = smoothing parameter for level (0 to 1)
- \(\beta\) = smoothing parameter for trend (0 to 1)
- \(\gamma\) = smoothing parameter for seasonality (0 to 1)
- \(m\) = seasonal period (e.g., 12 for monthly)
✓ Holt-Winters Variants
Additive: Seasonal variations constant in size
Multiplicative: Seasonal variations proportional to level
When to Use Which?
- Additive: +/- 100 units every summer (constant amplitude)
- Multiplicative: ×2 every summer (percentage increase)
Which Method to Choose?
| Method | Best For | Pros | Cons |
|---|---|---|---|
| ARIMA | Non-seasonal data with trend | Flexible, well-studied, works for many cases | Can't handle seasonality, requires stationarity |
| SARIMA | Seasonal data with trend | Handles both trend and seasonality | Complex parameter tuning, computationally heavy |
| Holt-Winters | Strong trend + strong seasonality | Simple, fast, intuitive | Less flexible than SARIMA, assumes patterns continue |
Decision Tree
- Is there seasonality?
- No → ARIMA
- Yes → Continue
- Is seasonality strong and regular?
- Yes → Holt-Winters (faster)
- Complex pattern → SARIMA (more flexible)
- Do you need interpretability?
- Yes → ARIMA/SARIMA (clear parameters)
- No → Try both, compare forecasts
Practical Implementation Tips
Common Workflow
- Plot your data — Look for trends, seasonality, outliers
- Check stationarity — Use Augmented Dickey-Fuller test
- Difference if needed — Apply differencing until stationary
- Choose parameters — ACF/PACF plots or grid search
- Fit model — Train on historical data
- Validate — Check residuals (should look like white noise)
- Forecast — Predict future values with confidence intervals
Python Example (statsmodels)
import pandas as pd
from statsmodels.tsa.statespace.sarimax import SARIMAX
# Fit SARIMA model
model = SARIMAX(data,
order=(1, 1, 1), # (p,d,q)
seasonal_order=(1, 1, 1, 12)) # (P,D,Q,m)
results = model.fit()
# Forecast
forecast = results.forecast(steps=12)
Python Example (Holt-Winters)
from statsmodels.tsa.holtwinters import ExponentialSmoothing
# Fit Holt-Winters
model = ExponentialSmoothing(data,
seasonal='multiplicative',
seasonal_periods=12)
results = model.fit()
# Forecast
forecast = results.forecast(steps=12)
Key Takeaways
- ARIMA: Foundation for time series — models trend and short-term patterns
- SARIMA: Extends ARIMA with seasonal components — best for complex patterns
- Holt-Winters: Simple exponential smoothing — fast and effective for clear trends + seasonality
- Always validate with train/test split and check residuals
- Consider modern alternatives: Prophet (Facebook), LSTM (deep learning) for very complex patterns