LINEST
A least-squares line through columns of the model, in one row: slopes, intercept, their standard errors and the fit's statistics.
Group: Statistics. Compatible with DAX.
Syntax
LINEST ( <columnY>, <columnX> [, <columnX>] … [, <const>] )
| Parameter | Type | Description |
|---|---|---|
columnY | Column | The column whose values the line explains. |
columnX | Column repeatable | A column that explains them, of the same table; one or more. |
const | Boolean optional | TRUE or left out to fit an intercept; FALSE for a line through the origin. Written as TRUE or FALSE, last. |
Returns
Table. One row: Slope1 … SlopeN, Intercept, StandardErrorSlope1 … StandardErrorSlopeN, StandardErrorIntercept, CoefficientOfDetermination, StandardError, FStatistic, DegreesOfFreedom, RegressionSumOfSquares and ResidualSumOfSquares.
Remarks
- The rows are those of the columns' table that the current filters leave. A blank y or x counts as 0: a row drops out only when all its values, y and every x, are blank.
- All the columns must come from one table. For a column of a related table, or any other expression, use
LINESTXwithRELATED. - A prediction is Intercept + Slope1 × x1 + Slope2 × x2 …; the slopes and their standard errors are those R's lm reports.
- An x column that follows from the others, such as one twice another or a constant, gets a slope of 0 and a standard error of 0, and the others share the fit.
- With const FALSE there is no Intercept column, nor its standard error.
- No more rows than coefficients is an error: one x with an intercept needs three rows at least.
Examples
Driving minutes against meters
Over every pair of places: what each extra kilometer costs, and what a trip costs before it starts.
EVALUATE
SELECTCOLUMNS (
LINEST ( Distances[Minutes], Distances[Meters] ),
"Minutes per km", [Slope1] * 1000,
"Minutes to start", [Intercept],
"R squared", [CoefficientOfDetermination]
)
| Minutes per km | Minutes to start | R squared |
|---|---|---|
| 0.824822534555227 | 6.37487614431497 | 0.468833646514482 |
The whole row, in the current filters
Only the trips that start at the depot.
EVALUATE
CALCULATETABLE (
LINEST ( Distances[Minutes], Distances[Meters] ),
Distances[From] = "Depot Alnabru"
)
| Slope1 | Intercept | StandardErrorSlope1 | StandardErrorIntercept | CoefficientOfDetermination | StandardError | FStatistic | DegreesOfFreedom | RegressionSumOfSquares | ResidualSumOfSquares |
|---|---|---|---|---|---|---|---|---|---|
| 0.000636878569422338 | 6.43457073307743 | 0.000185687562926292 | 1.830964742055 | 0.475040182949063 | 2.2159407405537 | 11.7638001571816 | 13 | 57.7648862466061 | 63.8351137533938 |