Web Simulation 

 

 

 

 

Time Series Analysis & Forecasting Tutorial 

This interactive tutorial visualizes Time Series Analysis using Holt-Winters Triple Exponential Smoothing. You can see how a model decomposes a signal into Level, Trend, and Seasonality, and then projects those components into the future with a confidence interval.

Mathematical Foundation

1. Time series decomposition

A time series yt can be expressed as the sum of three components:

yt = Levelt + Trendt + Seasonalt + Noiset

The Level (L) is the baseline value, the Trend (T) is the slope (how much the series increases or decreases per step), and the Seasonal (S) component captures repeating cyclic patterns. Noise is the random component.

2. Holt-Winters (Triple Exponential Smoothing)

The additive Holt-Winters method maintains three "state" variables that evolve over time, controlled by three smoothing parameters α, β, γ ∈ [0, 1]:

Level Lt = α(ytSt−m) + (1−α)(Lt−1 + Tt−1)
Trend Tt = β(LtLt−1) + (1−β)Tt−1
Seasonal St = γ(ytLt) + (1−γ)St−m
Forecast Ft+k = Lt + k·Tt + St−m+k

where m is the seasonal period (e.g. 12 steps for monthly data with yearly seasonality).

3. Smoothing parameters

  • α (Level): Controls how fast the level adapts. High α → reactive to recent data. Low α → smooth, stable baseline.
  • β (Trend): Controls trend responsiveness. High β → quickly picks up slope changes. Low β → dampens trend fluctuations.
  • γ (Seasonal): Controls seasonal adaptation. High γ → captures evolving patterns. Low γ → fixed seasonal shape.

4. Parameter estimation (Nelder-Mead)

In practice, α, β, γ are not set by hand — they are estimated by the algorithm. The standard approach is to minimize the Sum of Squared Errors (SSE) between the fitted values and the observed data:

(α*, β*, γ*) = argminα,β,γt (ytFt

This simulation uses the Nelder-Mead (Downhill Simplex) algorithm, a derivative-free optimizer that maintains a simplex of 4 vertices in (α, β, γ) space. At each iteration, it evaluates the SSE at each vertex and applies one of four geometric operations to replace the worst vertex:

Reflect Mirror the worst vertex through the centroid. If the result is better than the 2nd-worst but not the best, accept it.
Expand If the reflected point is the new best, try going even further in the same direction. Accept whichever is better.
Contract If reflection didn’t help, pull the worst vertex toward the centroid. Accept if improved.
Shrink If nothing else works, shrink all vertices toward the best one. Last resort.

The simplex converges when all vertices have nearly equal SSE, meaning the algorithm has found the minimum. Use the Step Fwd/Bwd buttons to watch this process unfold, seeing each decision and its formula.

5. Confidence interval

The 95% forecast confidence interval is estimated as Ft+k ± 1.96 × σresid × √(1 + 0.05k), where σresid is the standard deviation of the in-sample residuals. The interval widens with the forecast horizon, reflecting increasing uncertainty about the future.

6. Synthetic data generation

The simulation generates synthetic data using: yt = trend × t + A × sin(2πt / m) + noise. By controlling trend, amplitude, and noise, you can see how well the Holt-Winters model captures known ground truth.

Historical Fitted (HW) Forecast 95% CI Level Level+Trend Seasonal
Residuals (Actual − Fitted)
Holt-Winters Equations (Additive)
Level:   Lt = α(yt − St−m) + (1−α)(Lt−1 + Tt−1)
Trend:   Tt = β(Lt − Lt−1) + (1−β)Tt−1
Seasonal:   St = γ(yt − Lt) + (1−γ)St−m
Forecast:   Ft+k = Lt + k·Tt + St−m+k
Step-by-Step Parameter Estimation —
Press Step Fwd to walk through the Nelder-Mead simplex optimization: each iteration chooses Reflect, Expand, Contract, or Shrink to find better (α, β, γ).
Data Synthesis
0.50
12
5
30
Model Parameters — Estimated (SSE-minimized)
0.40
0.15
0.30
MSE
MAE
Residual σ
Forecast End
How to read this: The blue line is the raw historical data. The amber/yellow line is the Holt-Winters fit. The red dashed line is the forecast, surrounded by a shaded 95% confidence band. Click “Show Components” to see the decomposed Level (green), Level+Trend (orange), and Seasonal (purple) components.

Auto-Fit: The model parameters α, β, γ are automatically estimated by minimizing the Sum of Squared Errors (SSE) using the Nelder-Mead simplex algorithm. When you change the data, parameters are re-estimated. Dragging a slider manually enters “Manual Override” mode — click “Re-estimate” to return to automatic fitting.

 

Usage

Use the controls to explore how Holt-Winters decomposes and forecasts time series data:

  1. Data Synthesis: Use "Trend Strength", "Seasonality (Amp)", and "Noise Level" sliders to control the synthetic ground-truth signal. Click "New Random Data" to generate a fresh random seed.
  2. Model Parameters (Auto-Estimated): By default, α, β, γ are automatically optimized by minimizing SSE whenever the data changes. The sliders update to show the estimated values. You can manually override them by dragging the sliders — this enters "Manual Override" mode. Click "Re-estimate" to return to automatic fitting.
    • High α → model reacts quickly to level shifts (reactive).
    • Low α → model is stable and slow to adapt.
    • High β → model aggressively follows trend changes.
    • High γ → model closely captures seasonal patterns.
  3. Forecast Horizon: Controls how far into the future the model predicts (5–60 steps).
  4. Show Components: Toggles visibility of the decomposed Level (green dashed), Level+Trend (orange dashed), and Seasonal (purple dashed) curves behind the main chart.
  5. Step-by-Step Parameter Estimation: Walk through the optimization process that finds the best α, β, γ.
    • Step Fwd / Step Bwd — advance or go back one improvement step. Each step is a moment when the optimizer found a better (lower SSE) parameter combination. The chart and sliders update to reflect the current candidate parameters, so you can see the fit improve in real time.
    • Run / Stop — auto-play the estimation steps as an animation. Pressing Step Fwd or Step Bwd while running will stop the animation first.
    • Reset Steps — exit step mode and restore the final optimal parameters.
    • The info box shows: the simplex operation (Reflect / Expand / Contract / Shrink), why it was chosen, the 4 simplex vertices with SSE, the formula for the new candidate point, and a convergence bar chart.

Visualizations

  • Historical (blue): The raw synthetic data — the ground truth that the model tries to fit.
  • Fitted (amber/yellow): The Holt-Winters one-step-ahead fitted values. Shows how well the model tracks the historical data.
  • Forecast (red dashed): The projected future values beyond the historical data.
  • 95% CI (red band): The confidence interval widens as the forecast extends further, reflecting increasing uncertainty.
  • Residuals chart: Bar chart of (Actual − Fitted). Blue bars = over-estimate, red bars = under-estimate. Ideally these should be small and random (no pattern).

Summary Panel

  • MSE: Mean Squared Error of the in-sample fit (lower is better).
  • MAE: Mean Absolute Error (more interpretable than MSE).
  • Residual σ: Standard deviation of residuals, used to compute the confidence interval.
  • Forecast End: The predicted value at the last forecast step.

Key Insights

  • Overfitting vs. Smoothing: Setting all parameters to 1.0 makes the model copy the data exactly (overfitting) — the forecast becomes unreliable. Very low values produce a smooth but potentially inaccurate fit.
  • Noise sensitivity: Increase noise and observe how the residuals grow. A well-tuned model keeps residuals small even with moderate noise.
  • No seasonality: Set "Seasonality (Amp)" to 0 and observe that the seasonal component flatlines — the model correctly reduces to double exponential smoothing.