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
| Method | What it forecasts from | Data needed | What it suits |
|---|---|---|---|
| Linear regression | A single straight line through everything | 2 points or more | Something that rises or falls steadily |
| Holt-Winters | Level + trend + repeating pattern | 2 cycles or more | Something that repeats daily or weekly |
| ARIMA | Recent values + recent forecast errors | 30 points or more recommended | Something influenced by its previous values |
| SARIMA | ARIMA + a seasonal term | More still | Both 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
- Assume a line
- Measure the vertical distance from each observed point to that line
- Square those distances and add them up
- 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 observations | The band is |
|---|---|
| Clustered close to the line | Narrow |
| Scattered well above and below | Wide |
So a wide band means "this metric was erratic to begin with".
When it is used
| Condition | Why |
|---|---|
| Fewer than 10 data points | The other methods need something to learn from, and there is not enough |
| A clear straight-line trend | No reason to go for anything more complex |
| None of the other conditions matched | It 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.
| Layer | What it is | In traffic terms |
|---|---|---|
| Level | Where it is now | "about 300 requests per second these days" |
| Trend | Which way it is heading | "rising by 20 per week" |
| Seasonality | The 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.
| Parameter | Sensitivity of | Large value | Small value |
|---|---|---|---|
| α | Level | Reacts quickly to recent values | Weighs the past evenly |
| β | Trend | Follows a change of direction immediately | Keeps the trend stable |
| γ | Seasonality | Sensitive to changes in the pattern | Keeps the past pattern |
How the parameters are found — a two-stage grid search
Nobody sets them by hand. Everything is tried and the best fit wins.
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.
| Letter | Name | What it does |
|---|---|---|
| AR | Autoregression | Decides the next value from recent values |
| I | Integration (differencing) | Looks at the change, not the value itself |
| MA | Moving average | Feeds 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.
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.
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."
It has two sets of parameters
It is written SARIMA(p,d,q)(P,D,Q,s).
| Parameter | What it is |
|---|---|
| p · d · q | The ordinary terms — as in ARIMA |
| P | How many values one cycle back to use |
| D | The number of seasonal differences |
| Q | How many errors one cycle back to use |
| s | The 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.
The three criteria
| What | How | Threshold |
|---|---|---|
| Repeating pattern | Autocorrelation (ACF) analysis | Present when confidence is 0.5 or above |
| Influence of previous values | Correlation with the immediately preceding value | High above 0.5 |
| Straight-line trend | Slope + 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 chosen | Methods realistically available |
|---|---|
| 1 hour | Too few points — almost always linear regression |
| 6 hours | Linear regression or ARIMA |
| 1 day | Only one daily cycle, so seasonality cannot be learned |
| 3 days | Holt-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.