The Excel LINEST function returns statistics for a best fit straight line through supplied x and y values. The values returned by LINEST include slope, intercept, standard error values, and more. To find the best fit of a line to the data, LINEST uses the "least squares" method.
Get parameters of linear trend
Array of values
=LINEST (known_ys, [known_xs], [const], [stats])
known_ys - An array or range of dependent y values values.
known_xs - [optional] An array or range of independent x values.
const - [optional] Boolean - normal or force the constant b to equal 0. Default is TRUE = normal calculation.
stats - [optional] Boolean - return additional statistics. Default is FALSE = slope and intercept only.
The LINEST function returns statistics for a best fit straight line through supplied x and y values. The values returned by LINEST include slope, intercept, standard error values, and more, up to 10 different statistics in total. To find the best fit of a line to the data, the LINEST function uses the "least squares" method, the standard approach in regression analysis.
The LINEST function returns more than one value at a time in an array. In its most basic form, LINEST returns just intercept and slope. Optionally, LINEST can also return 10 separate statistics for the regression analysis as shown in the worksheet above. In Excel 365, which supports dynamic arrays, the array of values will spill into cells in the worksheet automatically. In other versions of Excel, you must enter the LINEST as a multi-cell array formula to see all values.
The table below shows the statistics that can be returned by the LINEST function. Note the first two, slope and intercept are returned by default. The other statistics are returned by setting the stats argument to TRUE. When all statistics are returned, they are delivered in a 2D array, 5 rows by 2 columns. In the worksheet shown above, the range F4:G8 shows the order in which statistics are returned.
Standard error of slope
Standard error of intercept
Coefficient of determination
Standard error of y estimate
F statistic (F-observed value)
Degrees of freedom
Regression sum of squares
Residual sum of squares
By default, LINEST returns just two statistics, slope and intercept. For example: