Skip to main content

LINEST

The LINEST function returns the parameters of a straight line that passes closest to all available data points using the least squares method.

This function is useful in statistical analysis and forecasting.

Syntax​

LINEST(known_data_y, [known_data_x], [b], [stats])

ArgumentDescriptionPermitted values
known_data_yArray or range of known dependent values (y)Any numerical values, ranges of cells with numbers. Text values or empty cells without numbers are not allowed
[known_data_x](optional) Values of independent variables that correspond to the “known_data_y” argument. If the argument is not specified, an array of numbers {1;2;3;...} is used.Any numerical values, ranges of cells with numbers. Text values or empty cells without numbers are not allowed
[b](optional) The logical value that determines the variable to be calculated in the linear equation y = m·x+b. Calculates the parameter b (TRUE) or the value of the parameter m (FALSE). By default, TRUETRUE or FALSE
[stats](optional) Boolean value that determines whether to calculate additional regression statistics for variables (TRUE) or only the values of variables b and m (FALSE). By default, FALSETRUE or FALSE

Statistics output structure​

RowColumn 1Column 2Description
1m (Xk)bRegression coefficients –m = slope (coefficient at X) –b = free term (constant) Equation: y = m·x + b
2SE(m)SE(b)Standard errors of coefficients –SE(m) = accuracy of slope estimation –SE(b) = accuracy of constant estimation If SE > 2, then the coefficient is significant
3R²SE(y)Model quality indicators –R² = coefficient of determination (0 to 1) –SE(y) = standard error of the estimate Y R² = 0.95 means: 95% of the variability in Y is explained by the model
4F statdfAnalysis of variance (ANOVA) –F = F-statistic (model significance) –df = degrees of freedom of residuals = n-k-1
5SSregSSresSums of squares –SSreg = explained sum of squares –SSres = residual sum of squares

Examples of use​

A simple example of linear regression

If you have sales and expense data and want to find ratios:

=LINEST(A2:A10, B2:B10)

Here, A2:A10 is the range of y values (for example, sales), and B2:B10 is the range of x values (for example, expenses).

Select two cells and press Ctrl+Shift+Enter after entering the formula.

The result will be an array where the first element is the slope coefficient and the second is the free term.

Linear regression calculation with statistics output

Suppose that the y data array is located in cells A1:A7: [1, 3, 5, 7, 10, 15, 19], and the x data array is located in cells B1:B7: [2, 5, 7, 9, 13, 17, 21].

To obtain regression data with statistics, select a cell array of 5 rows × 2 columns, enter the formula =LINEST(A1:A7, B1:B7, 1, 1), and press Ctrl+Shift+Enter.

Result:

Column 1Column 2Description
0.9601036269-1.578238342m = slope (coefficient at X) b = free term (constant) Equation: y = 0.9601·x − 1.5782
0.03365164310.413713877SE(m) = accuracy of slope estimation SE(b) = accuracy of constant estimation Both coefficients are significant, since m/SE(m) = 28.5 > 2 and b/SE(b) = 3.8 > 2.
0.99389498360.5587736387R² = coefficient of determination (0 to 1) SE(y) = standard error of the estimate Y R² = 0.994 means: 99.4% of the variability in Y is explained by the model
813.998625015F = F-statistic (model significance) df = here n (total observations) is specified, not df of residuals F > Fcrit: The model is statistically significant
254.153145821.5611398964SSreg = explained sum of squares SSres = residual sum of squares SSreg/SSres = 162.8: The model explains the data well

Notes​

  • The function returns an array of values, so you need to select the range and press Ctrl+Shift+Enter.
  • Make sure your ranges are the same length, otherwise the function will return an error.