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

ArgumentMeaning
xThe abscissa at which to evaluate the fitted line.
known_y'sThe dependent array or range.
known_x'sThe 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

Input cells (optional)

Example: {"B2": 3, "B3": 4}. A1 holds the formula. Other cells need values before a formula can read them.

Enter a formula, then calculate.

Runs locally in your browser with OneCalc. Its answer may differ from Excel. Use English function names and commas between arguments.

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:

  1. 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.
  2. Microsoft marks the legacy method deprecated. The Forecast page carries "This member is deprecated in Office 2016 and later versions"; the Forecast_Linear page carries no such note. That is a supersession statement.
  3. 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 no FORECAST.LINEAR probe 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:

ErrorCondition
#VALUE!x is nonnumeric
#N/Athe 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 GitHub
45 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

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 the FORECAST. prefix and shares nothing else. The .LINEAR suffix 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.
  • SLOPE and INTERCEPT — 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