HOLT_FORECAST

This function fits Holt’s exponential smoothing model with level and trend components and returns point forecasts.

Holt’s method updates both a level and a trend term over time:

\ell_t = \alpha y_t + (1-\alpha)(\ell_{t-1}+b_{t-1}), \quad b_t = \beta(\ell_t-\ell_{t-1}) + (1-\beta)b_{t-1}

Forecasts are computed by extrapolating the estimated level and trend.

Excel Usage

=HOLT_FORECAST(endog, steps, exponential, damped_trend, initialization_method)
  • endog (list[list], required): Time-series observations as a 2D range (data points).
  • steps (int, optional, default: 1): Number of future periods to forecast (periods).
  • exponential (bool, optional, default: false): Whether to use exponential trend form (true/false).
  • damped_trend (bool, optional, default: false): Whether to damp the trend component (true/false).
  • initialization_method (str, optional, default: “estimated”): Initialization method such as estimated, heuristic, known, or legacy-heuristic (option).

Returns (list[list]): Row vector containing forecasted values for the requested forecast horizon.

Example 1: One-step Holt forecast

Inputs:

endog steps
10 12 14 16 18 20 1

Excel formula:

=HOLT_FORECAST({10,12,14,16,18,20}, 1)

Expected output:

22.0002

Example 2: Two-step Holt forecast with damped trend

Inputs:

endog steps damped_trend
4 5 7 9 11 13 2 true

Excel formula:

=HOLT_FORECAST({4,5,7,9,11,13}, 2, TRUE)

Expected output:

Result
14.99 16.97
Example 3: Holt with exponential trend form

Inputs:

endog exponential steps
2 2.5 3.2 4.1 5.3 6.8 true 1

Excel formula:

=HOLT_FORECAST({2,2.5,3.2,4.1,5.3,6.8}, TRUE, 1)

Expected output:

8.72385

Example 4: Holt with heuristic initialization

Inputs:

endog initialization_method steps
30 31 33 35 38 40 41 43 45 46 heuristic 1

Excel formula:

=HOLT_FORECAST({30,31,33,35,38,40,41,43,45,46}, "heuristic", 1)

Expected output:

48.6

Python Code

import numpy as np
from statsmodels.tsa.holtwinters import Holt as sm_Holt

def holt_forecast(endog, steps=1, exponential=False, damped_trend=False, initialization_method='estimated'):
    """
    Fit Holt trend exponential smoothing and return forecasts.

    See: https://www.statsmodels.org/stable/generated/statsmodels.tsa.holtwinters.Holt.html

    This example function is provided as-is without any representation of accuracy.

    Args:
        endog (list[list]): Time-series observations as a 2D range (data points).
        steps (int, optional): Number of future periods to forecast (periods). Default is 1.
        exponential (bool, optional): Whether to use exponential trend form (true/false). Default is False.
        damped_trend (bool, optional): Whether to damp the trend component (true/false). Default is False.
        initialization_method (str, optional): Initialization method such as estimated, heuristic, known, or legacy-heuristic (option). Default is 'estimated'.

    Returns:
        list[list]: Row vector containing forecasted values for the requested forecast horizon.
    """
    try:
        def to2d(x):
            return [[x]] if not isinstance(x, list) else x

        endog = to2d(endog)

        if not isinstance(endog, list) or not all(isinstance(row, list) for row in endog):
            return "Error: Invalid input - endog must be a 2D list"

        series = []
        for row in endog:
            for value in row:
                try:
                    series.append(float(value))
                except (TypeError, ValueError):
                    continue

        if len(series) < 3:
            return "Error: endog must contain at least 3 numeric values"

        if steps < 1:
            return "Error: steps must be at least 1"

        model = sm_Holt(
            series,
            exponential=bool(exponential),
            damped_trend=bool(damped_trend),
            initialization_method=initialization_method
        )
        fitted = model.fit()
        forecast = np.asarray(fitted.forecast(int(steps)), dtype=float).reshape(1, -1)
        return forecast.tolist()
    except Exception as e:
        return f"Error: {str(e)}"

Online Calculator

Time-series observations as a 2D range (data points).
Number of future periods to forecast (periods).
Whether to use exponential trend form (true/false).
Whether to damp the trend component (true/false).
Initialization method such as estimated, heuristic, known, or legacy-heuristic (option).