fintech-algorithms

Holt-Winters

Install and import

bash
npm install fintech-algorithms
ts
import { forecastHoltWintersAdditive } from "fintech-algorithms/statistical-time-series/forecast-models/holt-winters";

Signature

forecastHoltWintersAdditive(values, alpha, beta, gamma, period, horizon, initialLevel, initialTrend, initialSeasonals)

Worked example

executed Captured by running this function on the input its own test provides. Real output of real code — but not asserted against a published figure.

Input

values
[10, 12, 11, 13]
alpha
0.5
beta
0.5
gamma
0.5
period
2
horizon
2
initialLevel
9
initialTrend
1
initialSeasonals
[-1, 1]

Call

forecastHoltWintersAdditive(values, alpha, beta, gamma, period, horizon, initialLevel, initialTrend, initialSeasonals)

Returns

object with 5 fields: forecast, fitted, residuals, trace, state

{
  "forecast": [12.35546875, 14.58203125],
  "fitted": [9, 12.75, 11.6875, 13.796875],
  "residuals": [1, -0.75, -0.6875, -0.796875],
  "trace": [
    {
      "index": 0,
      "level": 10.5,
      "trend": 1.25,
      "seasonal": -0.75
    },
    {
      "index": 1,
      "level": 11.375,
      "trend": 1.0625,
      "seasonal": 0.8125
    },
    {
      "index": 2,
      "level": 12.09375,
      "trend": 0.890625,
      "seasonal": -0.921875
    }
  ],
  "state": {
    "level": 12.5859375,
    "trend": 0.69140625,
    "seasonals": [-0.921875, 0.61328125]
  }
}

Diagrams

Holt-Winters — boundary failure
Holt-Winters — diagnostic workbench
Holt-Winters — family handoff
Holt-Winters — forecast origin
Holt-Winters — recursion anatomy

How it works

This page states the contract — how to call it correctly. The article explains the concept: why it works, and where it breaks.

Read the article →

References