Skip to content

A.2. How forecasts are calculated

Linear regression, Holt-Winters, ARIMA, SARIMA

This chapter covers where the forecast line and the confidence band come from. You do not have to choose. The method is decided automatically from the data. Knowing why a particular method was used, however, helps you judge how far to trust the result.

The four at a glance

MethodWhat it forecasts fromData neededWhat it suits
Linear regressionA single straight line through everything2 points or moreSomething that rises or falls steadily
Holt-WintersLevel + trend + repeating pattern2 cycles or moreSomething that repeats daily or weekly
ARIMARecent values + recent forecast errors30 points or more recommendedSomething influenced by its previous values
SARIMAARIMA + a seasonal termMore stillBoth repetition and previous values

1. Linear regression

What it does

It draws the single straight line that fits the points best and extends it.

The line has the form value = intercept + slope × time. The slope is exactly "how much it increases per unit of time".

How the line is decided — least squares

  1. Assume a line
  2. Measure the vertical distance from each observed point to that line
  3. Square those distances and add them up
  4. Choose the line where that sum is smallest

There is a reason for squaring. Adding the distances as they are lets overshoots and undershoots cancel out, which makes a poor line look good.

Where the confidence band comes from

It comes from how far the past points sat from the line.

If the observationsThe band is
Clustered close to the lineNarrow
Scattered well above and belowWide

So a wide band means "this metric was erratic to begin with".

When it is used

ConditionWhy
Fewer than 10 data pointsThe other methods need something to learn from, and there is not enough
A clear straight-line trendNo reason to go for anything more complex
None of the other conditions matchedIt is the default

It suits metrics that only move one way, such as disk usage.

Limits

  • It only draws straight lines. It cannot represent a relationship where response time rises sharply only after CPU passes 80%
  • It ignores repeating patterns — a metric that differs between day and night is flattened into one line
  • It handles sudden changes poorly

2. Holt-Winters

What it does

It splits the metric into three layers, tracks each separately, and combines them again.

LayerWhat it isIn traffic terms
LevelWhere it is now"about 300 requests per second these days"
TrendWhich way it is heading"rising by 20 per week"
SeasonalityThe repeating highs and lows"high during the day, low overnight"
forecast = level + trend × steps ahead + the seasonal effect at that point

Because it separates the three, it can properly express a state such as "the trend is rising, but it is low right now because it is the middle of the night." Linear regression flattens that into one line.

The three smoothing parameters — α, β, γ

These decide how much each layer favours recent values when it updates. All three are between 0 and 1.

ParameterSensitivity ofLarge valueSmall value
αLevelReacts quickly to recent valuesWeighs the past evenly
βTrendFollows a change of direction immediatelyKeeps the trend stable
γSeasonalitySensitive to changes in the patternKeeps the past pattern

Nobody sets them by hand. Everything is tried and the best fit wins.

Finding the Holt-Winters parameters — a two-stage grid search

It searches broadly first and then narrows down. Going straight to 0.05 steps across the whole range would take far too long.

When it is used

When a repeating pattern is detected and there are at least two cycles of data.

When there are fewer than 30 points, so the ARIMA family is unavailable, this is chosen if there is seasonality.

Limits

  • It needs at least two cycles to learn a pattern. With one cycle there is no way to tell a pattern from a single rise and fall
  • When the pattern changes abruptly, it takes time to catch up
  • Used on data with no repetition, it invents a pattern that is not there

3. ARIMA

The name combines three letters.

LetterNameWhat it does
ARAutoregressionDecides the next value from recent values
IIntegration (differencing)Looks at the change, not the value itself
MAMoving averageFeeds in how wrong the recent forecasts were

AR — looking at recent values

If response time is 200 ms now, it is likely to be near 200 ms a minute from now. The value five minutes ago is worth something too.

next value ≈ weight₁ × previous value + weight₂ × the one before + …

How many to look back over is p.

I — converting to changes

For a metric that keeps rising, the amount it rises by is more regular than the value itself.

Differencing — looking at the change instead of the value

That conversion is differencing, and how many times it is applied is d.

MA — correcting by how wrong it was

previous forecast 100, actual 105 → short by 5
next forecast = calculated value + correction × 5

How many past errors to look at is q.

How p, d and q are decided

They are found automatically.

The process of deciding ARIMA's p, d and q

AICc scores "how well it fitted" and "how complex it is" together. Complex models are penalised, to prevent a model that fits the past well but predicts the future badly.

What "stationary" means

ARIMA works properly only when the data is stationary, which means two things.

  • The mean does not change much over time
  • The size of the fluctuations does not change much over time

A metric that keeps rising is not stationary, which is why it is differenced into a stationary form first and then calculated.

When it is used

When the correlation with the immediately preceding value exceeds 0.5 — that is, a metric strongly influenced by its previous values.

4. SARIMA

This is ARIMA with a seasonal term added.

Where ARIMA looks at "the last few values", SARIMA also looks at "the same position one cycle ago."

SARIMA — it also looks at the same position one cycle ago

It has two sets of parameters

It is written SARIMA(p,d,q)(P,D,Q,s).

ParameterWhat it is
p · d · qThe ordinary terms — as in ARIMA
PHow many values one cycle back to use
DThe number of seasonal differences
QHow many errors one cycle back to use
sThe cycle length (for a daily cycle, the number of points in a day)

Seasonal differencing

Where ordinary differencing is "now − previous", seasonal differencing is "now − the same position one cycle ago."

It removes the periodic highs and lows and leaves only the change beyond the cycle.

5. Which one gets used — automatic selection

The checks are made in order.

Automatic selection of the forecasting algorithm

The three criteria

WhatHowThreshold
Repeating patternAutocorrelation (ACF) analysisPresent when confidence is 0.5 or above
Influence of previous valuesCorrelation with the immediately preceding valueHigh above 0.5
Straight-line trendSlope + explanatory power (R²)Slope significant and R² > 0.1

With little data it always ends up as linear regression, because the more complex methods need data to learn from.

What follows from a three-day evidence window

The widget offers only four time ranges: 1 hour, 6 hours, 1 day, 3 days. That feeds directly into the selection above.

Range chosenMethods realistically available
1 hourToo few points — almost always linear regression
6 hoursLinear regression or ARIMA
1 dayOnly one daily cycle, so seasonality cannot be learned
3 daysHolt-Winters becomes possible for a daily cycle

A weekly pattern cannot be learned from any of the ranges, because that needs two cycles — two weeks — and the maximum is three days.

This is why a forecast does not reflect the weekend for a service whose traffic drops then. Forecasting on a Friday from three days of data extends the weekday trend without knowing about the weekend drop.

How the fit is measured

How closely a forecast matched reality is measured with five metrics. Appendix: Can you trust it covers them.

Further detail

The formulas and the calculation steps are in the algorithm guide (600-algorithm_guide.md) in the Forecast MCP server documentation. This chapter is an operator's summary.

Next