
- Excel Functions - Home
- Compatibility Functions
- Compatibility Functions
- BETADIST Function
- BETAINV Function
- BINOMDIST Function
- CEILING Function
- CHIDIST Function
- CHIINV Function
- CHITEST Function
- CONFIDENCE Function
- COVAR Function
- CRITBINOM Function
- EXPONDIST Function
- FDIST Function
- FINV Function
- FLOOR Function
- FTEST Function
- GAMMADIST Function
- GAMMAINV Function
- HYPGEOMDIST Function
- LOGINV Function
- LOGNORMDIST Function
- MODE Function
- NEGBINOMDIST Function
- NORMDIST Function
- NORMINV Function
- NORMSDIST Function
- NORMSINV Function
- PERCENTILE Function
- PERCENTRANK Function
- POISSON Function
- QUARTILE Function
- RANK Function
- STDEV Function
- STDEVP Function
- TDIST Function
- TINV Function
- TTEST Function
- VAR Function
- VARP Function
- WEIBULL Function
- ZTEST Function
- Logical Functions
- Logical Functions
- AND Function
- FALSE Function
- IF Function
- IFERROR Function
- IFNA Function
- IFS Function
- NOT Function
- OR Function
- SWITCH Function
- TRUE Function
- XOR Function
- Text Functions
- Text Functions
- ARRAYTOTEXT Function
- BAHTTEXT Function
- CHAR Function
- CLEAN Function
- CODE Function
- CONCAT Function
- CONCATENATE Function
- DBCS Function
- DOLLAR Function
- Exact Function
- FIND Function
- FINDB Function
- FIXED Function
- LEFT Function
- LEFTB Function
- LEN Function
- LENB Function
- LOWER Function
- MID Function
- MIDB Function
- NUMBERVALUE Function
- PHONETIC Function
- PROPER Function
- REPLACE Function
- REPLACEB Function
- REPT Function
- RIGHT Function
- RIGHTB Function
- SEARCH Function
- SEARCHB Function
- SUBSTITUTE Function
- T Function
- TEXT Function
- TEXTAFTER Function
- TEXTBEFORE Function
- TEXTJOIN Function
- TEXTSPLIT Function
- TRIM Function
- UNICHAR Function
- UNICODE Function
- UPPER Function
- VALUE Function
- VALUETOTEXT Function
- Date & Time Functions
- Date & Time Functions
- DATE Function
- DATEDIF Function
- DATEVALUE Function
- DAY Function
- DAYS Function
- DAYS360 Function
- EDATE Function
- EOMONTH Function
- HOUR Function
- ISOWEEKNUM Function
- MINUTE Function
- MONTH Function
- NETWORKDAYS Function
- NETWORKDAYS.INTL Function
- NOW Function
- SECOND Function
- TIME Function
- TIMEVALUE Function
- TODAY Function
- WEEKDAY Function
- WEEKNUM Function
- WORKDAY Function
- WORKDAY.INTL Function
- YEAR Function
- YEARFRAC Function
- Cube Functions
- Cube Functions
- CUBEKPIMEMBER Function
- CUBEMEMBER Function
- CUBEMEMBERPROPERTY Function
- CUBERANKEDMEMBER Function
- CUBESET Function
- CUBESETCOUNT Function
- CUBEVALUE Function
- Math Functions
- Math Functions
- ABS Function
- AGGREGATE Function
- ARABIC Function
- BASE Function
- CEILING.MATH Function
- COMBIN Function
- COMBINA Function
- DECIMAL Function
- DEGREES Function
- EVEN Function
- EXP Function
- FACT Function
- FACTDOUBLE Function
- FLOOR.MATH Function
- GCD Function
- INT Function
- LCM Function
- LN Function
- LOG Function
- LOG10 Function
- MDETERM Function
- MINVERSE Function
- MMULT Function
- MOD Function
- MROUND Function
- MULTINOMIAL Function
- MUNIT Function
- ODD Function
- PI Function
- POWER Function
- PRODUCT Function
- QUOTIENT Function
- RADIANS Function
- RAND Function
- RANDBETWEEN Function
- ROMAN Function
- ROUND Function
- ROUNDDOWN Function
- ROUNDUP Function
- SERIESSUM Function
- SIGN Function
- SQRT Function
- SQRTPI Function
- SUBTOTAL Function
- SUM Function
- SUMIF Function
- SUMIFS Function
- SUMPRODUCT Function
- SUMSQ Function
- SUMX2MY2 Function
- SUMX2PY2 Function
- SUMXMY2 Function
- TRUNC Function
- Trigonometric Functions
- Trigonometric Functions
- ACOS
- ACOSH Function
- ACOT Function
- ACOTH Function
- ASIN Function
- ASINH Function
- ATAN Function
- ATAN2 Function
- ATANH Function
- COS Function
- COSH Function
- COT Function
- COTH Function
- CSC Function
- CSCH Function
- SEC Function
- SECH Function
- SIN Function
- SINH Function
- TAN Function
- TANH Function
- Database Functions
- Database Functions
- DAVERAGE
- DCOUNT
- DCOUNTA
- DGET
- DMAX
- DMIN
- DPRODUCT
- DSTDEV
- DSTDEVP
- DSUM
- DVAR
- DVARP
- Dynamic Array Functions
- Dynamic Array Functions
- FILTER Function
- RANDARRAY Function
- SEQUENCE Function
- SORT Function
- SORTBY Function
- UNIQUE Function
- XLOOKUP Function
- XMATCH Function
- Engineering Functions
- Engineering Functions
- BESSELI Function
- BESSELJ Function
- BESSELK Function
- BESSELY Function
- BIN2DEC Function
- BIN2HEX Function
- BIN2OCT Function
- BITAND Function
- BITLSHIFT Function
- BITOR Function
- BITRSHIFT Function
- BITXOR Function
- COMPLEX Function
- CONVERT Function
- DEC2BIN Function
- DEC2HEX Function
- DEC2OCT Function
- DELTA Function
- ERF Function
- ERF.PRECISE Function
- ERFC Function
- ERFC.PRECISE Function
- GESTEP Function
- HEX2BIN Function
- HEX2DEC Function
- HEX2OCT Function
- IMABS Function
- IMAGINARY Function
- IMARGUMENT Function
- IMCONJUGATE Function
- IMCOS Function
- IMCOSH Function
- IMCOT Function
- IMCSC Function
- IMCSCH Function
- IMDIV Function
- IMEXP Function
- IMLN Function
- IMLOG2 Function
- IMLOG10 Function
- IMPOWER Function
- IMPRODUCT Function
- IMREAL Function
- IMSEC Function
- IMSECH Function
- IMSIN Function
- IMSINH Function
- IMSQRT Function
- IMSUB Function
- IMSUM Function
- IMTAN Function
- OCT2BIN Function
- OCT2DEC Function
- OCT2HEX Function
- Financial Functions
- Financial Functions
- ACCRINT Function
- ACCRINTM Function
- AMORDEGRC Function
- AMORLINC Function
- COUPDAYBS Function
- COUPDAYS Function
- COUPDAYSNC Function
- COUPNCD Function
- COUPNUM Function
- COUPPCD Function
- CUMIPMT Function
- CUMPRINC Function
- DB Function
- DDB Function
- DISC Function
- DOLLARDE Function
- DOLLARFR Function
- DURATION Function
- EFFECT Function
- FV Function
- FVSCHEDULE Function
- INTRATE Function
- IPMT Function
- IRR Function
- ISPMT Function
- MDURATION Function
- MIRR Function
- NOMINAL Function
- NPER Function
- NPV Function
- ODDFPRICE Function
- ODDFYIELD Function
- ODDLPRICE Function
- ODDLYIELD Function
- PDURATION Function
- PMT Function
- PPMT Function
- PRICE Function
- PRICEDISC Function
- PRICEMAT Function
- PV Function
- RATE Function
- RECEIVED Function
- RRI Function
- SLN Function
- SYD Function
- TBILLEQ Function
- TBILLPRICE Function
- TBILLYIELD Function
- VDB Function
- XIRR Function
- XNPV Function
- YIELD Function
- YIELDDISC Function
- YIELDMAT Function
- Information Functions
- Information Functions
- CELL Function
- ERROR.TYPE Function
- INFO Function
- ISBLANK Function
- ISERR Function
- ISERROR Function
- ISEVEN Function
- ISFORMULA Function
- ISLOGICAL Function
- ISNA Function
- ISNONTEXT Function
- ISNUMBER Function
- ISODD Function
- ISREF Function
- ISTEXT Function
- N Function
- NA Function
- SHEET Function
- SHEETS Function
- TYPE Function
- Lookup & Reference Functions
- Lookup & Reference Functions
- ADDRESS Function
- AREAS Function
- CHOOSE Function
- COLUMN Function
- COLUMNS Function
- FORMULATEXT Function
- GETPIVOTDATA Function
- HLOOKUP Function
- HYPERLINK Function
- INDEX Function
- INDIRECT Function
- LOOKUP Function
- MATCH Function
- OFFSET Function
- ROW Function
- ROWS Function
- RTD Function
- TRANSPOSE Function
- VLOOKUP Function
- Statistical Functions
- Statistical Functions
- AVEDEV Function
- AVERAGE Function
- AVERAGEA Function
- AVERAGEIF Function
- AVERAGEIFS Function
- BETA.DIST Function
- BETA.INV Function
- BINOM.DIST Function
- BINOM.DIST.RANGE Function
- BINOM.INV Function
- CHISQ.DIST Function
- CHISQ.DIST.RT Function
- CHISQ.INV Function
- CHISQ.INV.RT Function
- CHISQ.TEST Function
- CONFIDENCE.NORM Function
- CONFIDENCE.T Function
- CORREL Function
- COUNT Function
- COUNTA Function
- COUNTBLANK Function
- COUNTIF Function
- COUNTIFS Function
- COVARIANCE.P Function
- COVARIANCE.S Function
- DEVSQ Function
- EXPON.DIST Function
- F.DIST Function
- F.DIST.RT Function
- F.INV Function
- F.INV.RT Function
- F.TEST Function
- FISHER Function
- FISHERINV Function
- FORECAST Function
- FORECAST.ETS Function
- FORECAST.ETS.CONFINT Function
- FORECAST.ETS.SEASONALITY Function
- FORECAST.ETS.STAT Function
- FORECAST.LINEAR Function
- FREQUENCY Function
- GAMMA Function
- GAMMA.DIST Function
- GAMMA.INV Function
- GAMMALN Function
- GAMMALN.PRECISE Function
- GAUSS Function
- GEOMEAN
- GROWTH
- HARMEAN
- HYPGEOM.DIST
- INTERCEPT Function
- KURT Function
- LARGE Function
- LINEST Function
- LOGEST Function
- LOGNORM.DIST Function
- LOGNORM.INV Function
- MAX Function
- MAXA Function
- MAXIFS Function
- MEDIAN Function
- MIN Function
- MINA Function
- MINIFS Function
- MODE.MULT Function
- MODE.SNGL Function
- NEGBINOM.DIST Function
- NORM.DIST Function
- NORM.INV Function
- NORM.S.DIST Function
- NORM.S.INV Function
- PEARSON Function
- PERCENTILE.EXC
- PERCENTILE.INC
- PERCENTRANK.EXC
- PERCENTRANK.INC
- PERMUT
- PERMUTATIONA
- PHI
- POISSON.DIST
- PROB
- QUARTILE.EXC
- QUARTILE.INC
- RANK.AVG
- RANK.EQ
- RSQ
- SKEW
- SKEW.P
- SLOPE
- SMALL
- STANDARDIZE
- STDEV.P
- STDEV.S
- STDEVA
- STDEVPA
- STEYX
- T.DIST
- T.DIST.2T
- T.DIST.RT
- T.INV
- T.INV.2T
- T.TEST
- TREND
- TRIMMEAN Function
- VAR.P Function
- VAR.S Function
- VARA Function
- VARPA Function
- WEIBULL.DIST Function
- Z.TEST Function
- Web Functions
- Web Functions
- ENCODEURL Function
- FILTERXML Function
- WEBSERVICE Function
Excel - LINEST Function
Description
The LINEST function calculates the statistics for a line by using the "least squares" method to calculate a straight line that best fits your data, and then returns an array that describes the line.
You can also combine LINEST with other functions to calculate the statistics for other types of models that are linear in the unknown parameters, including polynomial, logarithmic, exponential, and power series.
Since this function returns an array of values, it must be entered as an array formula.
Syntax
LINEST (known_y's, [known_x's], [const], [stats])
Arguments
Argument | Description | Required/ Optional |
---|---|---|
known_y's |
The set of y-values that you already know in the relationship y = mx + b. If the range of known_y's is in a single column, each column of known_x's is interpreted as a separate variable. If the range of known_y's is contained in a single row, each row of known_x's is interpreted as a separate variable. |
Required |
known_x's |
A set of x-values that you may already know in the relationship y = mx + b. The range of known_x's can include one or more sets of variables. If only one variable is used, known_y's and known_x's can be ranges of any shape, as long as they have equal dimensions. If more than one variable is used, known_y's must be a vector (that is, a range with a height of one row or a width of one column). If known_x's is omitted, it is assumed to be the array {1,2,3,...} that is the same size as known_y's. |
Optional |
const |
A logical value specifying whether to force the constant b to equal 0. If const is TRUE or omitted, b is calculated normally. If const is FALSE, b is set equal to 0 and the m-values are adjusted to fit y = mx. |
Optional |
stats |
A logical value specifying whether to return additional regression statistics. If stats is TRUE, LINEST returns the additional regression statistics. As a result, the returned array is {mn, mn-1 ,..., m1, b; sen ,sen-1, ..., se1, seb; r2, sey; F, df; ssreg, ssresid}. If stats is FALSE or omitted, LINEST returns only the mcoefficients and the constant b. The additional regression statistics are as given in the Table below. |
Optional |
Additional Regression Statistics
Sr.No | Statistic & Description |
---|---|
1 |
se1,se2,...,sen The standard error values for the coefficients m1,m2,...,mn. |
2 |
seb The standard error value for the constant b (seb = #N/A when const is FALSE). |
3 |
r2 The coefficient of determination. Compares estimated and actual yvalues, and ranges in value from 0 to 1. If it is 1, there is a perfect correlation in the sample there is no difference between the estimated y-value and the actual y-value. At the other extreme, if the coefficient of determination is 0, the regression equation is not helpful in predicting a y-value. For information about how r2 is calculated, see Notes below. |
4 |
sey The standard error for the y estimate. |
5 |
F The F statistic, or the F-observed value. Use the F statistic to determine whether the observed relationship between the dependent and independent variables occurs by chance. |
6 |
df The degrees of freedom. Use the degrees of freedom to help you find F-critical values in a statistical table. Compare the values you find in the table to the F statistic returned by LINEST to determine a confidence level for the model. For information about how df is calculated, see Notes below. |
7 |
ssreg The regression sum of squares. |
8 |
ssreg The residual sum of squares. For information about how ssreg and ssresid are calculated, see Notes below. |
Notes
-
The equation for the line is −
y = mx + b
or
y = m1x1 + m2x2 + ... + b
-
If there are multiple ranges of x-values, where the dependent y-values are a function of the independent x-values, then −
The m-values are coefficients corresponding to each x-value, and b is a constant value.
Note that y, x, and m can be vectors.
The array that the LINEST Function returns is {mn, mn-1 m1, b}.
LINEST can also return additional regression statistics
-
You can describe any straight line with the slope and the y-intercept −
-
Slope(m) −
To find the slope of a line, often written as m, take two points on the line, (x1,y1) and (x2,y2). The slope is equal to
(2 - y1)/(2 - x1).
-
Y-intercept(b) −
The y-intercept of a line, often written as b, is the value of y at the point where the line crosses the y-axis.
-
The equation of a straight line is y = mx + b. Once you know the values of m and b, you can calculate any point on the line by plugging the y- or x-value into that equation. You can also use the TREND Function.
-
When you have only one independent x-variable, you can obtain the slope and yintercept values directly by using the following formulas −
-
Slope −
=INDEX (LINEST (known_y's,known_x's),1)
-
Y-intercept −
=INDEX (LINEST (known_y's,known_x's),2)
-
The accuracy of the line calculated by the LINEST Function depends on the degree of scatter in your data. The more linear the data, the more accurate the LINEST model.
-
LINEST uses the method of least squares for determining the best fit for the data. When you have only one independent x-variable, the calculations for m and b are based on the following formulas −
$$m=\frac{\sum \left ( x-\bar{x} \right )\left ( y-\bar{y} \right )}{\sum \left ( x- \bar{x}\right )^2}$$
Where x and y are sample means. i.e.
x = AVERAGE (known x's)
y = AVERAGE (known_y's)
The line and curve-fitting Functions LINEST and LOGEST can calculate the best straight line or exponential curve that fits your data. However, you have to decide which of the two results best fits your data. You can calculate TREND (known_y's,known_x's) for a straight line, or GROWTH(known_y's, known_x's) for an exponential curve. These Functions, without the known_x's argument omitted, return an array of y-values predicted along that line or curve at your actual data points. You can then compare the predicted values with the actual values. You may want to chart them both for a visual comparison.
In regression analysis, Excel calculates for each point the squared difference between the y-value estimated for that point and its actual y-value. The sum of these squared differences is called the residual sum of squares, ssresid. Excel then calculates the total sum of squares, sstotal. When the const argument = TRUE or is omitted, the total sum of squares is the sum of the squared differences between the actual y-values and the average of the y-values.
When the const argument = FALSE, the total sum of squares is the sum of the squares of the actual y-values (without subtracting the average y-value from each individual y-value). Then regression sum of squares, ssreg, can be found from: ssreg = sstotal - ssresid. The smaller the residual sum of squares is, compared with the total sum of squares, the larger the value of the coefficient of determination, r2, which is an indicator of how well the equation resulting from the regression analysis explains the relationship among the variables. The value of r2 equals ssreg/sstotal.
In some cases, one or more of the X columns (assume that Ys and Xs are in columns) may have no additional predictive value in the presence of the other X columns. i.e., eliminating one or more X columns might lead to predicted Y values that are equally accurate. In that case these redundant X columns should be omitted from the regression model. This phenomenon is called collinearity because any redundant X column can be expressed as a sum of multiples of the non-redundant X columns.
The LINEST Function checks for collinearity and removes any redundant X columns from the regression model when it identifies them. Removed X columns can be recognized in LINEST output as having 0 coefficients in addition to 0 se values. If one or more columns are removed as redundant, df is affected because df depends on the number of X columns actually used for predictive purposes.
If df is changed because redundant X columns are removed, values of sey and F are also affected. Collinearity should be relatively rare in practice. However, one case where it is more likely to arise is when some X columns contain only 0 and 1 values as indicators of whether a subject in an experiment is or is not a member of a particular group. If const = TRUE or is omitted, the LINEST function effectively inserts an additional X column of all 1 values to model the intercept
-
The value of df is calculated as follows, when there are k columns of known_xs and no X columns are removed from the model due to collinearity −
If const = TRUE or is omitted, df = n k 1
If const = FALSE, df = n k
In both cases, each X column that was removed due to collinearity increases the value of df by 1.
When entering an array constant (such as known_x's) as an argument, use commas to separate values that are contained in the same row and semicolons to separate rows. Separator characters may be different depending on your regional settings.
Note that the y-values predicted by the regression equation may not be valid if they are outside the range of the y-values you used to determine the equation.
The underlying algorithm used in the LINEST function is different than the underlying algorithm used in the SLOPE and INTERCEPT functions. The difference between these algorithms can lead to different results when data is undetermined and collinear.
-
In addition to using LOGEST to calculate statistics for other regression types, you can use LINEST to calculate a range of other regression types by entering functions of the x and y variables as the x and y series for LINEST. For example, the following formula −
=LINEST (yvalues, xvalues^COLUMN($A:$C))
Works when you have a single column of y-values and a single column of x-values to calculate the cubic (polynomial of order 3) approximation of the −
y = m1*x + m2*x^2 + m3*x*3 + b
You can adjust this formula to calculate other types of regression, but in some cases it requires the adjustment of the output values and other statistics.
The F-test value that is returned by the LINEST Function differs from the F-test value that is returned by the FTEST Function. LINEST returns the F statistic, whereas FTEST returns the probability.
If the array of known_x's is not the same length as the array of known_y's, LINEST returns the #REF! error value.
If any of the values in the supplied known_x's or known_y's arrays are not numeric (this may include text representations of numbers, as the LINEST Function does not recognize these as numbers), LINEST returns the #VALUE! error value.
If either of the const or stats arguments cannot be evaluated to TRUE or FALSE, LINEST returns the #VALUE! error value.
Applicability
Excel 2007, Excel 2010, Excel 2013, Excel 2016
Example
