FORECAST.LINEAR
Returns a predicted y-value at x from simple linear regression over known data.
FORECAST.LINEAR fits y = intercept + slope * x and evaluates that line at the requested x.
The Formualizer engine in this repository at 0.15.0 plus unreleased changes computes the example results. Known differences from Excel are listed on this page.
Syntax
=FORECAST.LINEAR(x, known_ys, known_xs)
Arguments
| Argument | Type | Required | Default |
|---|---|---|---|
x | number (range) | Required | — |
known_ys | number (range) | Required | — |
known_xs | number (range) | Required | — |
Remarks
- Requires
known_yandknown_xarrays with the same numeric length. - Alias
FORECASTis supported.
Error cases
- Returns
#N/Awhen arrays are empty or lengths do not match. - Returns
#DIV/0!whenknown_xhas zero variance.
Examples
Extend a linear pattern one step beyond the observed x range.
Formula =FORECAST.LINEAR(5,{2,4,6,8},{1,2,3,4})
Expected result 10
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
Interpolate between two observed x values.
Formula =FORECAST.LINEAR(2.5,{2,4,6,8},{1,2,3,4})
Expected result 5
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
Evaluate at the first x value of a two-point line.
Formula =FORECAST.LINEAR(1,{2,4},{1,2})
Expected result 2
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
Each known y must have a corresponding x.
Formula =FORECAST.LINEAR(5,{2,4,6},{1,2})
Expected result #N/A
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
Predict next point on a perfect line
Formula =FORECAST.LINEAR(4,{2,4,6},{1,2,3})
Expected result 8
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.
Forecast with non-zero intercept
Formula =FORECAST.LINEAR(5,{3,5,7},{1,2,3})
Expected result 11
Try this formula
This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.