LINEST in ONLYOFFICE Spreadsheet Editor
Return linear-regression coefficients and a labeled statistics array, with exact small-data calculations, reversed predictor order and source-specific degeneracy cautions.
Verification status: See the evidence and test scope described in this guide. How formula examples are checked
Quick answer: For x 1,2,3,4 and y 3,5,6,9, =LINEST(B1:B4,A1:A4,TRUE,FALSE) has an independently expected coefficient row 1.9, 1: slope first, intercept second.
Availability and evidence scope
- Introduced: Original introduction release is not established by the checked sources.
- Available: Listed in current unversioned ONLYOFFICE help, checked October 18, 2026.
- Implementation inspected: Official SDKJS v10.0.0.169, commit
3679e0375a758d7dc59d31337a45461be3525ed8. The snapshot does not prove identical behavior in every installed editor. - Retired or deprecated: These sources do not establish retirement or formal deprecation.
- Testing: Numerical examples are independent mathematical expectations, and implementation discrepancies are labeled source predictions. No ONLYOFFICE application or calculation-engine execution was performed.
The examples use English function names and commas. Use your locale’s argument separator if different. Retain full precision in formulas; round only the displayed result. Nested output grids describe source-derived array contents. Native spill placement, obstruction errors, array-entry shortcuts and recalculation behavior have not been tested in the application. Reserve a separate output area and follow the array-formula entry method supported by your installed editor; do not assume a particular keyboard shortcut or automatic spill behavior.
Syntax and result shape
=LINEST(known_y, [known_x], [const], [stats])
One to four arguments are registered. Omitted known_x uses 1,2,…,N. TRUE or omitted const fits an intercept; FALSE fixes it at zero and refits the slopes. FALSE or omitted stats returns only coefficients. TRUE stats requests a five-row result containing coefficients, standard errors and summary statistics.
For K predictors, the coefficient row has K+1 columns and returns slopes in reverse predictor order, followed by the intercept: mK,…,m2,m1,b. For one predictor this is simply m,b. The statistics result is five rows by K+1 columns. Do not interpret its first value as the whole answer or assume predictor order is preserved left to right.
Step-by-step: fit a line and verify the coefficients
Enter x=1,2,3,4 in A1:A4 and y=3,5,6,9 in B1:B4. Evaluate =LINEST(B1:B4,A1:A4,TRUE,FALSE) separately from the source data. The independent expected row is 1.9,1, giving y_hat=1.9*x+1.
The means are x̄=2.5 and ȳ=5.75. Sxx, the sum of squared centered x values, is 5; Sxy, the sum of centered cross-products, is 9.5. Therefore m=Sxy/Sxx=1.9 and b=ȳ−m*x̄=1. Fitted responses are 2.9,4.8,6.7,8.6; residuals are 0.1,0.2,−0.7,0.4, with residual sum of squares 0.7.
Because x already equals 1..4, =LINEST(B1:B4) has the same coefficient expectation. Omitting x for irregular or differently spaced explanatory values would fit another model.
Read the five-row statistics result
For the same dataset, evaluate =LINEST(B1:B4,A1:A4,TRUE,TRUE). Its independent expectation is:
| Result row | First column | Second column | Meaning |
|---|---|---|---|
| 1 | 1.9 | 1 | Slope, intercept |
| 2 | 0.264575131106 | 0.724568837309 | Standard errors of slope and intercept |
| 3 | 0.962666666667 | 0.591607978310 | R², residual standard error |
| 4 | 51.571428571429 | 2 | F statistic, residual degrees of freedom |
| 5 | 18.05 | 0.7 | Regression sum of squares, residual sum of squares |
There are N=4 observations and one predictor plus an intercept, so df=2. Residual mean square is 0.7/2=0.35. The slope standard error is SQRT(0.35/5), and the intercept standard error is SQRT(0.35*(1/4+2.5^2/5)). R² is 18.05/(18.05+0.7), and F is 18.05/0.35.
For multiple predictors, row 2 follows the same reversed coefficient order. Rows 3–5 use only their first two columns; remaining positions are source-predicted #N/A placeholders. Standard errors quantify model-based uncertainty under appropriate assumptions; they are not prediction intervals, and a high R² is not evidence of causation or guaranteed forecast accuracy.
Advanced example: coefficient order with two predictors
On a fresh sheet put predictor pairs (0,0), (1,0), (0,1), (1,1) in A1:B4, and responses 1,3,4,6 in C1:C4. The model is y=1+2*x1+3*x2. =LINEST(C1:C4,A1:B4,TRUE,FALSE) has independent expectation 3,2,1. The coefficient for column B appears first, the coefficient for column A second, and the intercept last.
With responses in a column, predictor columns share the same observation rows. With responses in a row, predictors are arranged in rows with matching observation columns. Keep labels out of the selected ranges and align observations rather than simply matching total cell counts.
Returning to the first dataset, =LINEST(B1:B4,A1:A4,FALSE,FALSE) instead predicts 67/30,0, approximately 2.233333333333,0. Through-origin slope is sum(x*y)/sum(x²), not 1.9 with its intercept discarded. In stats mode the fixed intercept has an unavailable standard-error slot, and degrees of freedom follow the constrained model. Centered and uncentered goodness-of-fit interpretations should not be mixed casually.
Errors and an important degenerate-case warning
Incompatible known-x/known-y shapes predict internal bad_reference (#REF!) before the shared validator checks element types. Nonnumeric elements in otherwise compatible training matrices predict wrong_value_type (#VALUE!); text and blanks are not silently removed as paired observations. Existing whole-argument errors may propagate first.
The inspected simple-regression helper substitutes 1 when the x-square denominator is zero. With an intercept and identical x values, this can return zero slope and mean-y intercept rather than signaling that a slope is unidentified. The statistics branch also treats zero regression sum of squares as an exact-fit condition: it overwrites residual sum of squares with 0 and R² with 1, even when that interpretation is not justified by the observations. Do not rely on those statistics for constant-x or zero-slope degenerate data.
For an exact fit or zero residual degrees of freedom, the source may return #N/A for F and zero standard errors through its special branch. These outputs do not create reliable uncertainty estimates from insufficient information. Multiple-predictor QR failure or zero diagonals can cause the wrapper to return #VALUE!; near collinearity can be unstable without a clean error. Automatic robust removal of redundant predictors is not established here.
Before interpreting uncertainty statistics, inspect residual patterns, outliers, design rank, observation dependence and variance assumptions. A numeric coefficient array alone does not validate the model.
Compatibility and related functions
Recalculate representative formulas when moving a workbook between editors. Matching names do not guarantee identical argument coercion, array behavior, numerical precision or error handling. These source-derived examples do not establish automatic spill behavior or a general import/export guarantee.
Official references
- ONLYOFFICE LINEST help, checked October 18, 2026.
- Official SDKJS implementation, 2617–3169, tag v10.0.0.169 and exact commit above.