Statistical functions
FORECAST.LINEAR
Matches all 7 recorded answers
Recorded: 7 workbook cells. How we measure this · See the Rust code
No local names are recorded for this entry.
What it does
FORECAST.LINEAR(x, known_ys, known_xs)
FORECAST.LINEAR(x, known_ys, known_xs) fits a straight line to the paired data by ordinary
least squares and evaluates it at x. Microsoft's documented equation is a + bx, with the
sample means named as AVERAGE(all known_x) and AVERAGE(all known_y).
With n paired observations (xᵢ, yᵢ) and means x̄, ȳ:
b = Σ (xᵢ − x̄)(yᵢ − ȳ) / Σ (xᵢ − x̄)²
a = ȳ − b·x̄
FORECAST.LINEAR(x, …) = a + b·x
The full mathematical treatment — that this is a fit and not an interpolation, that no
extrapolation guard exists, that the denominator vanishes exactly when the xᵢ are all equal
and not when the yᵢ are — is set out on the FORECAST page and is not
repeated here. The name is the modern one: LINEAR distinguishes this member from the
FORECAST.ETS exponential-smoothing family introduced at the same time, which is why the
rename happened at all.
Arguments
| Argument | Meaning |
|---|---|
x | The abscissa at which to evaluate the fitted line. |
known_y's | The dependent array or range. |
known_x's | The independent array or range. |
x is a scalar numeric slot; the two data arguments are consumed by scanning, not by
elementwise lifting. See Coercion and lifting.
Try it
Quirks
The relationship to FORECAST, stated precisely
This is a dotted-name/legacy-name pair, and the Handbook's rule for such pairs applies in full: a shared documentation page and matching wording are not evidence of a shared computation.
What can be said, with its warrant attached:
- The documentation describes the same computation. Both VBA reference pages give the equation as a + bx with the same definitions of a and b, and list the same three error conditions. That is a documented statement about intent.
- Microsoft marks the legacy method deprecated. The
Forecastpage carries "This member is deprecated in Office 2016 and later versions"; theForecast_Linearpage carries no such note. That is a supersession statement. - Nothing establishes that Excel does. No Handbook measurement compares Excel's two
surfaces against each other. The evidence record attached to this page says explicitly that
its rows are
FORECAST's, that there is noFORECAST.LINEARprobe anywhere in the corpus, and that inheriting the figure to this surface would be a shared-kernel inference rather than a measurement.
Point 5 is the load-bearing one. Anyone migrating formulas from FORECAST to
FORECAST.LINEAR on the assumption that results are unchanged in the last bit is making an
assumption this Handbook cannot support.
Result and edge cases
Returns Number — a scalar, never an array.
The edge-case inventory is identical in shape to FORECAST's: two points fit exactly; all-x
identical is a zero denominator; constant y is a well-posed fit with zero slope; length
mismatch and empty input are documented as #N/A; large common offsets in x are the accuracy
hazard. See FORECAST. Whether the two surfaces
actually agree on any of these in Excel is unmeasured, which is precisely why the inventory is
worth probing on both surfaces rather than on one.
Errors
As documented by Microsoft on the VBA reference page for this method:
| Error | Condition |
|---|---|
#VALUE! | x is nonnumeric |
#N/A | the known_y and known_x parameters are empty, or contain a different number of data points |
#DIV/0! | the variance of the known_x parameters equals zero |
How to implement
Numerical notes
The numerical content of this function is the numerical content of the least-squares slope, and it is set out on the FORECAST page: centered accumulation versus the raw-sums form, the catastrophic cancellation that the raw form suffers when the xᵢ share a large offset, the conditioning argument from Björck, and the fact that publishing as a + b·x rather than ȳ + b·(x − x̄) changes the last bits without changing the mathematics.
Rust code
Show the CalcFunc source of this function
Quoted from the public repository DnaCalc/DnaCalc, crates calc-func and calc-fml, at commit 9e1884369a67. Comments are the source's own. A kernel shared with other functions appears once, on its module page.
FORECAST.LINEAR · 4 lines · calc-func/src/catalogue/statistics.rs on GitHub45 forecast_linear "FORECAST.LINEAR" (3, 3) [V "x", R "known_ys", R "known_xs"] |s, a, sv| {
let x = num(s, a, 0)?;
forecast(s, x, &pairs(s, a, 2, 1, PairScalars::Coerce, sv)?)
}
Kernels shared with other functions
forecastcatalogue/statistics
Argument and result plumbing
No implementation has been published with a Handbook test suite for this function.
Version differences
No comparison between specific Excel builds is recorded here yet. This does not establish that all builds behave alike.
Alternatives
Relationships
- FORECAST — the legacy spelling, documented as deprecated. The precise statement of what is and is not known about the pair is in the section above.
FORECAST.ETS,FORECAST.ETS.CONFINT,FORECAST.ETS.SEASONALITY,FORECAST.ETS.STAT— the exponential-smoothing time-series family that shares theFORECAST.prefix and shares nothing else. The.LINEARsuffix exists to keep these apart. A reader who wants seasonality handling wants the ETS members; a reader who wants a straight line wants this one.TREND— the array-valued generalisation to several predictors and several evaluation points.SLOPEandINTERCEPT— the same fit exposed as its two coefficients.LINEST— the full regression report.GROWTH— the exponential analogue, fitted in log-space.
Named variants
No named variants are recorded yet.
Suggest a correction or contribute an implementation · For agents