The LINEST function in Google Sheets is a powerful tool designed for statistical analysis, specifically to provide insights into linear relationships. Utilizing the least-squares method, this function calculates essential parameters of a linear trend, making it invaluable for data analysis and interpretation in various fields such as finance, science, and social research.
Syntax
LINEST(known_data_y, [known_data_x], [const], [stats])
- known_data_y: The dependent variable data points. This is the data you are trying to predict.
- known_data_x: The independent variable data points. This optional parameter represents the values affecting the dependent variable.
- const: A boolean indicating whether to calculate the y-intercept. If TRUE (or omitted), it calculates the intercept; if FALSE, it forces the intercept to zero.
- stats: A boolean indicating whether to return additional regression statistics. If TRUE, it provides an array of statistics; if FALSE (or omitted), it returns only the coefficients.
Example #1
=LINEST(A1:A10, B1:B10)
This function calculates the parameters of the linear trend based on known y-values from A1 to A10 and corresponding x-values from B1 to B10. For instance, if A1:A10 contains values [2, 4, 6, 8, 10] and B1:B10 corresponds to [1, 2, 3, 4, 5], the result might be {2, 0} indicating a slope of 2 and an intercept of 0.
Example #2
=LINEST(A1:A10, B1:B10, TRUE, TRUE)
This function performs the same linear regression as the previous example but also returns additional statistics including R², standard error, and other relevant metrics. Given the same data, the output may yield values such as {2, 0, 5, 0, 1}, providing a comprehensive view of the linear relationship.
Example #3
=LINEST(A1:A10, , FALSE)
This function calculates the linear trend without including an intercept. Using the values from A1:A10 only, this might return a slope indicating the rate of change in the data. If A1:A10 contained [1, 2, 3, 4, 5], the output may be {1}.
Error handling
- VALUE! – This error occurs when the ranges provided are not compatible or contain non-numeric values. Ensure that all provided data ranges include only numbers.
- N/A – This error appears if LINEST cannot calculate a valid result due to insufficient or inappropriate data. Check that the known data ranges contain adequate and relevant values.
- REF! – This error indicates that a reference is invalid, often due to ranges that reference cells outside of the available sheet area. Verify the ranges used in your function call are correct.