Holt-Winters
Install and import
npm install fintech-algorithmsimport { 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
[10, 12, 11, 13]0.50.50.52291[-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
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.
References
- Forecasting: Principles and Practice — Holt-Winters — Rob J. Hyndman and George Athanasopoulos
- Exponential smoothing examples — statsmodels developers
- Forecasting: Principles and Practice — Evaluating point forecast accuracy — Rob J. Hyndman and George Athanasopoulos
- Forecasting: Principles and Practice — Time series cross-validation — Rob J. Hyndman and George Athanasopoulos
- Forecasting: Principles and Practice — Evaluating regression and residual behavior — Rob J. Hyndman and George Athanasopoulos