{
  "category": "Statistical functions",
  "display_name": "LINEST",
  "entry_kind": "built_in_function",
  "eval_api": {
    "method": "POST",
    "url": "https://handbook.dnacalc.com/api/eval"
  },
  "function_id": "FUNC.LINEST",
  "implementation_state": {
    "answer_bank": null,
    "detail": "Of 3,345 recorded answers (3,345 workbook cells), 253 do not match: 208 differ by more than 16 ULP, 19 differ by at most 16 ULP, 26 differ in kind or value.",
    "dnacalc_commit": "9e1884369a678158dd82d3d74188daf986995e87",
    "in_catalogue": true,
    "state": "differs",
    "state_label": "Known larger differences",
    "summary": "Known larger differences on 253 of 3,345 recorded answers",
    "workbook_corpus": {
      "cells": 3345,
      "larger_numeric": 208,
      "last_bit": 19,
      "matched": 3092,
      "other_mismatch": 26,
      "worst_ulp": 14
    }
  },
  "implementations": [
    {
      "commit": "9e1884369a678158dd82d3d74188daf986995e87",
      "flavour": "excel-compatibility-candidate",
      "language": "Rust",
      "name": "CalcFunc",
      "own_code": [
        "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/statistics.rs#L430-L432",
        "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/ported/regression_forecast_family.rs#L1066-L1080",
        "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/ported/regression_forecast_family.rs#L1218-L1232"
      ],
      "repository": "https://github.com/DnaCalc/DnaCalc",
      "shared_code": [
        "catalogue/statistics::regression",
        "ported/excel_numeric::binary_with",
        "ported/excel_numeric::excel_x87_add",
        "ported/excel_numeric::excel_x87_sub",
        "ported/excel_numeric::excel_x87_mul",
        "ported/excel_numeric::excel_x87_div",
        "ported/excel_numeric/x87::mul",
        "ported/excel_numeric/x87::add",
        "ported/excel_numeric/x87::sub",
        "ported/excel_numeric/x87::div",
        "ported/regression_forecast_family::GramInterval::checked",
        "ported/regression_forecast_family::GramInterval::subtract",
        "ported/regression_forecast_family::GramInterval::multiply",
        "ported/regression_forecast_family::GramInterval::square",
        "ported/regression_forecast_family::GramInterval::divide_positive",
        "ported/regression_forecast_family::moment",
        "ported/regression_forecast_family::column",
        "ported/regression_forecast_family::entry",
        "ported/regression_forecast_family::factor_column",
        "ported/regression_forecast_family::unresolved_inner",
        "ported/regression_forecast_family::unresolved",
        "ported/regression_forecast_family::resolve_arg_eval",
        "ported/regression_forecast_family::optional_arg_value",
        "ported/regression_forecast_family::numeric_from_cell",
        "ported/regression_forecast_family::numeric_scalar_from_eval",
        "ported/regression_forecast_family::bool_flag_from_eval_or_default",
        "ported/regression_forecast_family::collect_numeric_vector_from_eval",
        "ported/regression_forecast_family::collect_numeric_vector_arg",
        "ported/regression_forecast_family::NumericMatrix::cell",
        "ported/regression_forecast_family::NumericMatrix::transpose",
        "ported/regression_forecast_family::collect_numeric_matrix_from_eval",
        "ported/regression_forecast_family::collect_numeric_matrix_arg",
        "ported/regression_forecast_family::sequence_predictors",
        "ported/regression_forecast_family::default_output_shape_for_known_y",
        "ported/regression_forecast_family::normalize_known_x_matrix",
        "ported/regression_forecast_family::prepare_predictor_input",
        "ported/regression_forecast_family::predictor_input_from_optional",
        "ported/regression_forecast_family::least_squares",
        "ported/regression_forecast_family::exact_product",
        "ported/regression_forecast_family::exactly_proportional",
        "ported/regression_forecast_family::linear_fit_from_data",
        "ported/regression_forecast_family::row_array",
        "ported/regression_forecast_family::one_observation_statistics",
        "ported/regression_forecast_family::statistics_block"
      ],
      "source": "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/statistics.rs#L430-L432",
      "state": "differs",
      "suite": null,
      "summary": "Known larger differences on 253 of 3,345 recorded answers"
    }
  ],
  "json_url": "https://handbook.dnacalc.com/api/functions/FUNC.LINEST.json",
  "name": "LINEST",
  "notes": [
    {
      "basis": "Gains 11 recorded answers and loses none over the 3,944 regression rows of the corpus; 35 selections from two fits were checked directly.",
      "documentation": null,
      "evidence": [
        {
          "commit": "3f3b1622003f4f349a08ee8b054163e58f8dba67",
          "locator": "line 680",
          "note": "recorded selections pinned",
          "path": "crates/calc-func/tests/f1_stats.rs",
          "repository": "DnaCalc"
        },
        {
          "commit": "130ec21b3da03276c01fb27dce70463f08f90d9a",
          "locator": "reflector_study",
          "note": "research round 22 result",
          "path": "round22-result.json",
          "repository": "DnaCalc-Research"
        },
        {
          "commit": "130ec21b3da03276c01fb27dce70463f08f90d9a",
          "locator": null,
          "note": "reflector study",
          "path": "evidence/round22/householder-all-hard.json",
          "repository": "DnaCalc-Research"
        }
      ],
      "functions": [
        "FUNC.LINEST",
        "FUNC.LOGEST"
      ],
      "inferred": null,
      "kind": "bit-matching-detail",
      "note_id": "FN-LINEST-001",
      "open": [
        "Norm, rank, mean, pivot and back-substitution policies are not identified. 48 fixed rank policies and 240 rounded Gram/LDL rank labels are contradicted by the 241 recorded degrees-of-freedom observations."
      ],
      "recorded_on": "2026-11-04",
      "repros": [
        {
          "call": "=INDEX(LINEST({-17.979;-0.126;8;-5;1.7;37;12.4;14.46;-8;24.2},{20.8,50;34,23.41;38.875,-17.7;4.863,36.9;42.1,6;-14.55,44.41;-4.57,-12.96;-9.909,2.589;47.549,42;54.9,-17.63},TRUE,TRUE),2,1)",
          "correct": null,
          "excel": {
            "bits": "0x3fc863a97e13b089",
            "display": "0.19054144531344644",
            "kind": "number"
          },
          "input_route": "formula-literal",
          "inputs": [],
          "recorded_in": "Excel 16.0.20527.20088 Current Channel, Windows 64-bit (NT 10.0.26200), x86-64, AMD Ryzen 7 4800H, en-ZA",
          "source": {
            "commit": "c9f9d354165d2c20b9455c32582ea50baac7ba73",
            "locator": "sheet dcj9k_linest_stats, row 1094, column 4",
            "note": null,
            "path": "crates/calc-func/tests/captures/catalogue/sections/dcj9k_linest_stats.capture.json",
            "repository": "DnaCalc"
          }
        }
      ],
      "schema": "efh.function-note/v1",
      "statement": "In Excel's QR route the reflector arithmetic behaves as stored precision-64 steps: v0 = x0 - alpha, v'v, each dot-product term, f = 2t/v'v, and a - f*v. With this change the row below gets Excel's last bits, where a plain binary64 reflector does not.",
      "status": "measured",
      "title": "LINEST's Householder reflector stores each step from the x87 unit"
    },
    {
      "basis": "One fit, 20 selections read through INDEX.",
      "documentation": null,
      "evidence": [
        {
          "commit": "db713147318f63906d67ce88be497b66f521951d",
          "locator": "line 725",
          "note": "recorded selections pinned",
          "path": "crates/calc-func/tests/f1_stats.rs",
          "repository": "DnaCalc"
        }
      ],
      "functions": [
        "FUNC.LINEST"
      ],
      "inferred": null,
      "kind": "quirk",
      "note_id": "FN-LINEST-002",
      "open": [],
      "recorded_on": "2026-11-04",
      "repros": [
        {
          "call": "=INDEX(LINEST({31.78;5.61;-9.09},{53.56,30.22,32;-9,-17.977,47.17;9.4,-11.83,39.39},FALSE,TRUE),2,1)",
          "correct": null,
          "excel": {
            "bits": "0x0000000000000000",
            "display": "0",
            "kind": "number"
          },
          "input_route": "formula-literal",
          "inputs": [],
          "recorded_in": "Excel 16.0.20527.20088 Current Channel, Windows 64-bit (NT 10.0.26200), x86-64, AMD Ryzen 7 4800H, en-ZA",
          "source": {
            "commit": "c9f9d354165d2c20b9455c32582ea50baac7ba73",
            "locator": "sheet dcj9k_linest_stats, row 1180, column 4",
            "note": null,
            "path": "crates/calc-func/tests/captures/catalogue/sections/dcj9k_linest_stats.capture.json",
            "repository": "DnaCalc"
          }
        },
        {
          "call": "=INDEX(LINEST({31.78;5.61;-9.09},{53.56,30.22,32;-9,-17.977,47.17;9.4,-11.83,39.39},FALSE,TRUE),3,1)",
          "correct": null,
          "excel": {
            "bits": "0x3ff0000000000000",
            "display": "1",
            "kind": "number"
          },
          "input_route": "formula-literal",
          "inputs": [],
          "recorded_in": "Excel 16.0.20527.20088 Current Channel, Windows 64-bit (NT 10.0.26200), x86-64, AMD Ryzen 7 4800H, en-ZA",
          "source": {
            "commit": "c9f9d354165d2c20b9455c32582ea50baac7ba73",
            "locator": "sheet dcj9k_linest_stats, row 1184, column 4",
            "note": null,
            "path": "crates/calc-func/tests/captures/catalogue/sections/dcj9k_linest_stats.capture.json",
            "repository": "DnaCalc"
          }
        },
        {
          "call": "=INDEX(LINEST({31.78;5.61;-9.09},{53.56,30.22,32;-9,-17.977,47.17;9.4,-11.83,39.39},FALSE,TRUE),4,1)",
          "correct": null,
          "excel": {
            "bits": null,
            "display": "#NUM!",
            "kind": "error"
          },
          "input_route": "formula-literal",
          "inputs": [],
          "recorded_in": "Excel 16.0.20527.20088 Current Channel, Windows 64-bit (NT 10.0.26200), x86-64, AMD Ryzen 7 4800H, en-ZA",
          "source": {
            "commit": "c9f9d354165d2c20b9455c32582ea50baac7ba73",
            "locator": "sheet dcj9k_linest_stats, row 1188, column 4",
            "note": null,
            "path": "crates/calc-func/tests/captures/catalogue/sections/dcj9k_linest_stats.capture.json",
            "repository": "DnaCalc"
          }
        },
        {
          "call": "=INDEX(LINEST({31.78;5.61;-9.09},{53.56,30.22,32;-9,-17.977,47.17;9.4,-11.83,39.39},FALSE,TRUE),5,1)",
          "correct": null,
          "excel": {
            "bits": "0x409190463f141206",
            "display": "1124.0686",
            "kind": "number"
          },
          "input_route": "formula-literal",
          "inputs": [],
          "recorded_in": "Excel 16.0.20527.20088 Current Channel, Windows 64-bit (NT 10.0.26200), x86-64, AMD Ryzen 7 4800H, en-ZA",
          "source": {
            "commit": "c9f9d354165d2c20b9455c32582ea50baac7ba73",
            "locator": "sheet dcj9k_linest_stats, row 1192, column 4",
            "note": null,
            "path": "crates/calc-func/tests/captures/catalogue/sections/dcj9k_linest_stats.capture.json",
            "repository": "DnaCalc"
          }
        }
      ],
      "schema": "efh.function-note/v1",
      "statement": "With three observations, three x columns and const FALSE, LINEST with stats returns standard errors of 0 and se_y of 0 rather than #DIV/0!, R^2 of 1, F of #NUM!, degrees of freedom 0, ss_resid exactly 0 and ss_reg the sum of y^2.",
      "status": "measured",
      "title": "LINEST with no residual degrees of freedom returns zeros and one #NUM!"
    }
  ],
  "schema": "efh.function-reference/v1",
  "section_order": [
    "what-it-does",
    "try-it",
    "quirks",
    "how-to-implement",
    "version-differences",
    "alternatives"
  ],
  "sections": {
    "alternatives": "\n### Relationships\n\n- **[LOGEST](FUNC.LOGEST.md)** — `LINEST` applied to `ln y`, reported multiplicatively. See\n  that page for why its statistics describe the log-scale fit.\n- **`GROWTH`** — `LOGEST` as `TREND` is to `LINEST`.\n- **[SLOPE](FUNC.SLOPE.md)** and **[INTERCEPT](FUNC.INTERCEPT.md)** — the scalar single-predictor\n  special cases. `LINEST(y, x)` returns exactly those two numbers, in that order.\n- **[RSQ](FUNC.RSQ.md)**, **[STEYX](FUNC.STEYX.md)**, **[PEARSON](FUNC.PEARSON.md)**,\n  **[FORECAST.LINEAR](FUNC.FORECAST.LINEAR.md)** — each reproduces one cell of the `LINEST`\n  block for the single-predictor case. Whether the dedicated surfaces and the `LINEST` cell\n  return identical bits is exactly the kind of question a metamorphic suite exists to answer,\n  and the Handbook has no such suite.\n- **The Analysis ToolPak Regression tool** — a separate implementation of the same statistics,\n  historically a separate code path. Comparing the two on the same data is a classic\n  self-check.\n- **Confused with:** chart trendlines, which fit on the plotted series and use their own\n  display rounding; and with `LINEST` polynomial fits, which come from passing\n  `x, x², x³, …` as separate predictor columns — the construction that makes the conditioning\n  problem below unavoidable.\n\n\n",
    "how-to-implement": "\n### Numerical notes\n\n\n`LINEST` is the function on which the accuracy of a spreadsheet's statistical lane has\nhistorically been judged, and the reason is conditioning.\n\n**The normal equations square the condition number.** Solving `XᵀXβ = Xᵀy` by forming `XᵀX`\nand factorising it costs\n\n    κ₂(XᵀX) = κ₂(X)²\n\nso a design matrix with condition number `10⁸` — entirely ordinary for a cubic polynomial fit\non unscaled data — produces a Gram matrix with condition number `10¹⁶`, which is the\nreciprocal of double precision. At that point the computed coefficients have no correct\ndigits, and the failure is silent: the routine returns numbers, not an error. This is the\nsingle most important fact on this page.\n\n**The stable alternatives.** The standard remedy, described in every numerical linear algebra\ntext, is to avoid forming `XᵀX` at all:\n\n- **Householder QR** on `X` directly: `X = QR`, solve `Rβ = Qᵀy` by back substitution. The\n  achieved accuracy scales with `κ₂(X)`, not its square. This is the default in LAPACK's\n  `dgels` and in essentially every serious statistics package.\n- **Modified Gram–Schmidt** with reorthogonalisation, cheaper and nearly as good.\n- **The singular value decomposition**, `X = UΣVᵀ`, which additionally exposes rank deficiency\n  as small singular values and lets the caller truncate them deliberately. The SVD is the\n  right tool when collinearity is expected rather than exceptional.\n\nThe canonical references are Golub and Van Loan, *Matrix Computations*, chapter 5; Björck,\n*Numerical Methods for Least Squares Problems*; Lawson and Hanson, *Solving Least Squares\nProblems*; and Higham, *Accuracy and Stability of Numerical Algorithms*, chapters 19–20 for\nthe error analysis. Numerical Recipes chapter 15 covers the applied side including the SVD\nroute.\n\n**Centring and scaling.** Even with a stable factorisation, an unscaled design matrix wastes\nprecision. Subtracting the column means (which `const = TRUE` does implicitly for the constant\nterm, but not for the predictors) and scaling columns to comparable norms can reduce `κ₂(X)`\nby many orders of magnitude at no statistical cost, because the fit is equivariant under those\ntransformations. A polynomial fit on years `1990…2020` is hopeless; the same fit on\n`year − 2005` is easy. `LINEST` gives the caller no way to request this, so the caller must do\nit in the worksheet.\n\n**The published critique record.** The NIST Statistical Reference Datasets (StRD) include\nlinear regression problems of graded difficulty — Norris (easy), Longley (the classic\nill-conditioned economic dataset from Longley 1967), Wampler, and Filip, a tenth-degree\npolynomial fit that is deliberately near the edge of double precision. McCullough and Wilson's\nsequence of papers *On the accuracy of statistical procedures in Microsoft Excel* (1999, and\nfollow-ups covering later versions) reported `LINEST` failing to return any correct digits on\nFilip in the versions they tested, and tracked what changed across releases. Morten Welinder's\nwork on Gnumeric's statistical functions covers the same territory from the reimplementer's\nside. The Handbook names these as the published literature on the family; of what Excel does\ninternally it asserts only the reflector steps of FN-LINEST-001, and it has not re-run the StRD\ndatasets itself.\n\n**A note on the statistics block.** `SSE` computed as `SST − SSR` is a cancellation waiting to\nhappen when `r²` is close to 1 — precisely the case where users care. Accumulating the\nresiduals directly, `Σ(yᵢ − ŷᵢ)²`, costs one extra pass and is unconditionally better. The\nsame applies to `r²` itself: computing it as `SSR/SST` when `SSE` is tiny loses the digits\nthat distinguish `0.999999` from `0.9999999`.\n\n\n",
    "quirks": "\n### The returned array\n\n\nThis is where most `LINEST` confusion lives, and it has two distinct parts.\n\n**Coefficient order is reversed.** With `k` predictors the first row is\n\n    { m_k , m_{k−1} , … , m₂ , m₁ , b }\n\nThe slope for the **last** predictor column comes first, and the constant is last. A reader\nwho lays the predictors out left to right and reads the result left to right gets them\nbackwards. For simple regression (`k = 1`) the row is `{m, b}` — slope then intercept — which\nis easy to remember and gives no warning about the general rule.\n\n**`stats = TRUE` adds four rows.** The full block is a `5 × (k+1)` array:\n\n| Row | Leftmost `k` columns | Rightmost column |\n|---|---|---|\n| 1 | `m_k … m₁` — the coefficients | `b` — the constant |\n| 2 | `se(m_k) … se(m₁)` — coefficient standard errors | `se(b)` |\n| 3 | `r²` — coefficient of determination | `se(y)` — standard error of the estimate |\n| 4 | `F` — the F statistic | `df` — residual degrees of freedom |\n| 5 | `SSR` — regression sum of squares | `SSE` — residual sum of squares |\n\nRows 3, 4 and 5 have only two meaningful entries each; the remaining cells of those rows are\ndocumented as `#N/A`. The layout is documented by Microsoft on the `LINEST` page.\n\nNote the arithmetic relations that must hold internally, and which make excellent metamorphic\nprobes: `r² = SSR/(SSR+SSE)`, `se(y) = √(SSE/df)`, `F = (SSR/(p−1))/(SSE/df)` when `const` is\nTRUE, and `df = n − p`.\n\nEvidence record `EV-MISC-0010` records one structural comparison against Excel that belongs\nhere rather than in a statistics table: with `const` FALSE the returned row still carries a\ntrailing constant cell set to zero rather than being shortened by one column, and multivariate\ncoefficients come back in reverse predictor order. That record is explicit that these\nobservations are structural and uncounted.\n\n\n\n### Result and edge cases\n\n\nReturns an `Array` — a spilled dynamic array in modern Excel, and historically a\nCtrl+Shift+Enter formula whose selection size decided how much of the block you saw. Selecting\ntoo small a region truncated the block silently, which is the reason so many workbooks contain\na `LINEST` that reports only its first cell.\n\n- **Exactly determined system** (`n = p`) — the fit is exact, `SSE = 0`, and `df = 0`. The\n  statistics block then divides by zero for `se(y)` and `F`; the documented result is `#N/A`\n  in those cells. The one such fit read in Excel, three observations on three x columns with\n  `const` FALSE, returns instead standard errors and `se(y)` of 0, `r²` of 1, `F` of `#NUM!`, `df`\n  of 0, `SSE` of exactly 0 and `SSR` the sum of `y²` (FN-LINEST-002).\n- **Rank-deficient `X`** — duplicated or linearly dependent predictor columns. The\n  least-squares solution is not unique. Microsoft's page documents that `LINEST` may drop\n  collinear columns and return zero coefficients for them; the Handbook has not verified what\n  the rank tolerance is, and the tolerance is the whole question, because \"collinear\" in\n  floating point is a threshold decision rather than a fact.\n- **Error values** propagate.\n\n\n\n### Errors\n\n\n| Error | Condition | Basis |\n|---|---|---|\n| `#REF!` | `known_y's` and `known_x's` have incompatible shapes | Documented by Microsoft on the `LINEST` page |\n| `#VALUE!` | An argument cannot be converted, or `const`/`stats` is not interpretable as a logical | Shared coercion rule, chapter 02 |\n| `#N/A` | The unused cells of statistics rows 3–5; also the statistics cells that require `df > 0` when `df = 0`, though FN-LINEST-002 reads 0 and `#NUM!` there in Excel | Documented layout |\n| propagated | An error value in the data | Shared coercion rule, chapter 02 |\n\n",
    "sources": "- Golub and Van Loan, *Matrix Computations*, chapter 5 — least squares by QR and SVD, and the\n  `κ₂(XᵀX) = κ₂(X)²` result.\n- Björck, *Numerical Methods for Least Squares Problems* (SIAM, 1996).\n- Lawson and Hanson, *Solving Least Squares Problems* (SIAM classic).\n- Higham, *Accuracy and Stability of Numerical Algorithms*, 2nd ed., chapters 19–20.\n- Longley, *An appraisal of least squares programs from the point of view of the user* (JASA,\n  1967) — the original ill-conditioned benchmark.\n- NIST Statistical Reference Datasets, linear regression collection (Norris, Longley, Wampler,\n  Filip) — certified values.\n- McCullough and Wilson, *On the accuracy of statistical procedures in Microsoft Excel*\n  (Computational Statistics & Data Analysis, 1999 and successors) — the StRD critique of\n  Excel's regression lane, named as published literature rather than as Handbook evidence.\n- Morten Welinder's work on Gnumeric's statistical functions — the reimplementer's record.\n- Handbook evidence record `EV-MISC-0010` (subjects `FUNC.LINEST`, `FUNC.LOGEST`; class\n  open-discrepancy; carries a reader warning against per-surface attribution).\n- Handbook [Coercion and lifting](../model/02-coercion-and-lifting.md) and\n  [The value universe](../model/01-value-universe.md).\n- Handbook projections `data/functions/FUNC.LINEST.json` (arity 1–4, `xlfLinest`,\n  `RefsVisibleInAdapter`) and `data/presence/FUNC.LINEST.json` (module\n  `regression_forecast_family.rs`, shared with `FORECAST`, `FORECAST.LINEAR`, `GROWTH`,\n  `LOGEST`, `TREND`; upstream defect stream `BUG-FUNC-028` named on the module).\n\n",
    "version-differences": "No comparison between specific Excel builds is recorded here yet. This does not establish that all builds behave alike.",
    "what-it-does": "\n`LINEST(known_y's, [known_x's], [const], [stats])` fits the multiple linear model\n\n    y = m₁x₁ + m₂x₂ + … + m_k x_k + b\n\nto the data by **ordinary least squares**, and returns the fitted coefficients — optionally\ntogether with a block of regression statistics.\n\nIn matrix form, with `y` the `n`-vector of responses and `X` the `n × p` design matrix (its\ncolumns the predictors, plus a column of ones when `const` is TRUE), least squares chooses\n\n    β̂ = argmin_β ‖ y − Xβ ‖₂²\n\nwhose stationarity condition is the **normal equations**\n\n    XᵀX β̂ = Xᵀy\n\nwith the unique solution `β̂ = (XᵀX)⁻¹Xᵀy` whenever `X` has full column rank. When `X` is rank\ndeficient — two identical predictors, or fewer observations than parameters — the minimiser is\nnot unique and the problem as posed has no answer.\n\nThe residual vector `e = y − Xβ̂` is orthogonal to the column space of `X`; that orthogonality\nis the geometric content of least squares and the source of the sums-of-squares decomposition\nreported in the statistics block:\n\n    SST = SSR + SSE,   SST = Σ(yᵢ − ȳ)²,  SSR = Σ(ŷᵢ − ȳ)²,  SSE = Σ(yᵢ − ŷᵢ)²\n\n(with `SST = Σyᵢ²` when `const` is FALSE, because the model is then not required to reproduce\nthe mean).\n\n**Domain.** Needs `n ≥ p` observations, `X` of full column rank, and — for the statistics\nblock — `n > p` so the residual degrees of freedom `df = n − p` are positive. **Range:** the\ncoefficients are real numbers of unbounded magnitude.\n\n\n\n### Arguments\n\n\n| Argument | Meaning | Default |\n|---|---|---|\n| `known_y's` | The response values. A single column, a single row, or — with multiple predictors — a vector whose orientation determines how `known_x's` is read. Required | — |\n| `known_x's` | The predictor columns (or rows). Optional | `{1, 2, …, n}` |\n| `const` | `TRUE` fits the constant `b`; `FALSE` forces `b = 0`. Optional | `TRUE` |\n| `stats` | `TRUE` returns the five-row block; `FALSE` returns the coefficient row only. Optional | `FALSE` |\n\n**The omitted `known_x's` default is a real behaviour, not a convenience.** Leaving it out\nregresses `y` against the sequence `1, 2, …, n`, which is a time index. That is often what a\nuser wants and is occasionally a silent disaster when the observations are not equally spaced.\n\n**Orientation matters.** `known_y's` and `known_x's` must have the same shape when there is\none predictor. With several predictors, each predictor occupies one column if `known_y's` is a\ncolumn, and one row if `known_y's` is a row. There is no argument that says which; the shapes\ndecide.\n\n**`const = FALSE` changes the statistics, not just the coefficient.** Forcing the line through\nthe origin changes the definition of `SST` and of `df`, so `r²` computed under `const = FALSE`\nis not comparable with the ordinary one and can behave in ways that surprise — it is not\nbounded the same way. This is a genuine and much-litigated statistical point, not an\nimplementation quirk.\n\n\n"
  },
  "signature": {
    "display": "LINEST(known_ys, [known_xs], [const], [stats])",
    "parameters": [
      {
        "description": null,
        "name": "known_ys",
        "optional": false,
        "repeats": false
      },
      {
        "description": null,
        "name": "known_xs",
        "optional": true,
        "repeats": false
      },
      {
        "description": null,
        "name": "const",
        "optional": true,
        "repeats": false
      },
      {
        "description": null,
        "name": "stats",
        "optional": true,
        "repeats": false
      }
    ],
    "trailing_repeats": false
  },
  "sources": {
    "metadata": {
      "admission": {
        "label": "implemented",
        "reason": null
      },
      "arity": {
        "max": 4,
        "min": 1
      },
      "category": "Statistical functions",
      "classification": {
        "arg_preparation_profile": "RefsVisibleInAdapter",
        "coercion_lift_profile": "Custom",
        "determinism_class": "Deterministic",
        "error_collapse_profile": "None",
        "fec_dependency_profile": "RefOnly",
        "host_interaction_class": "None",
        "kernel_signature_class": "Custom",
        "rich_value_usage": "RichBlind",
        "surface_fec_dependency_profile": "RefOnly",
        "thread_safety_class": "SafePure",
        "volatility_class": "NonVolatile"
      },
      "descriptions": {
        "long": null,
        "short": "Coefficients and statistics of the least-squares linear fit",
        "short_source": "dna-calc-own"
      },
      "docs": {
        "english_description": "Returns the parameters of a linear trend",
        "microsoft_url": "https://support.microsoft.com/en-us/office/linest-function-84d7d0d9-6e50-4101-977a-fa7abf772b6d"
      },
      "entry_kind": "built_in_function",
      "localized_family_names": null,
      "localized_names": [
        {
          "locale": "ar-SA",
          "name": "LINEST"
        },
        {
          "locale": "bg-BG",
          "name": "LINEST"
        },
        {
          "locale": "cs-CZ",
          "name": "LINREGRESE"
        },
        {
          "locale": "da-DK",
          "name": "LINREGR"
        },
        {
          "locale": "de-DE",
          "name": "LINEST"
        },
        {
          "locale": "el-GR",
          "name": "LINEST"
        },
        {
          "locale": "en-AU",
          "name": "LINEST"
        },
        {
          "locale": "en-GB",
          "name": "LINEST"
        },
        {
          "locale": "en-US",
          "name": "LINEST"
        },
        {
          "locale": "es-ES",
          "name": "ESTIMACION.LINEAL"
        },
        {
          "locale": "et-EE",
          "name": "LINEST"
        },
        {
          "locale": "fi-FI",
          "name": "LINREGR"
        },
        {
          "locale": "fr-FR",
          "name": "DROITEREG*"
        },
        {
          "locale": "he-IL",
          "name": "LINEST"
        },
        {
          "locale": "hr-HR",
          "name": "LINEST"
        },
        {
          "locale": "hu-HU",
          "name": "LIN.ILL"
        },
        {
          "locale": "id-ID",
          "name": "LINEST"
        },
        {
          "locale": "it-IT",
          "name": "LINEST"
        },
        {
          "locale": "ja-JP",
          "name": "LINEST"
        },
        {
          "locale": "ko-KR",
          "name": "LINEST"
        },
        {
          "locale": "lt-LT",
          "name": "LINEST"
        },
        {
          "locale": "lv-LV",
          "name": "LINEST"
        },
        {
          "locale": "nb-NO",
          "name": "LINEST"
        },
        {
          "locale": "nl-NL",
          "name": "LIJNSCH"
        },
        {
          "locale": "pl-PL",
          "name": "REGLINP"
        },
        {
          "locale": "pt-BR",
          "name": "LINEST"
        },
        {
          "locale": "pt-PT",
          "name": "PROJ.LIN"
        },
        {
          "locale": "ro-RO",
          "name": "LINEST"
        },
        {
          "locale": "ru-RU",
          "name": "ЛИНЕЙН"
        },
        {
          "locale": "sk-SK",
          "name": "LINEST"
        },
        {
          "locale": "sl-SI",
          "name": "LINEST"
        },
        {
          "locale": "sr-Latn-RS",
          "name": "LINEST"
        },
        {
          "locale": "sv-SE",
          "name": "REGR"
        },
        {
          "locale": "th-TH",
          "name": "LINEST"
        },
        {
          "locale": "tr-TR",
          "name": "DOT işlevi"
        },
        {
          "locale": "uk-UA",
          "name": "LINEST"
        },
        {
          "locale": "vi-VN",
          "name": "LINEST"
        },
        {
          "locale": "zh-CN",
          "name": "LINEST"
        },
        {
          "locale": "zh-HK",
          "name": "LINEST"
        },
        {
          "locale": "zh-TW",
          "name": "LINEST"
        }
      ],
      "signature": {
        "display": "LINEST(known_ys, [known_xs], [const], [stats])",
        "parameters": [
          {
            "description": null,
            "name": "known_ys",
            "optional": false,
            "repeats": false
          },
          {
            "description": null,
            "name": "known_xs",
            "optional": true,
            "repeats": false
          },
          {
            "description": null,
            "name": "const",
            "optional": true,
            "repeats": false
          },
          {
            "description": null,
            "name": "stats",
            "optional": true,
            "repeats": false
          }
        ],
        "trailing_repeats": false
      },
      "surface_name": "LINEST",
      "version_marker": null,
      "xlcall": {
        "code": "49",
        "symbol": "xlfLinest"
      }
    },
    "microsoft": "https://support.microsoft.com/en-us/office/linest-function-84d7d0d9-6e50-4101-977a-fa7abf772b6d"
  },
  "try_it": {
    "formula": "=LINEST(1)"
  },
  "url": "https://handbook.dnacalc.com/functions/LINEST.html",
  "variants": [],
  "versions": [
    {
      "behaviour": "=INDEX(LINEST({-17.979;-0.126;8;-5;1.7;37;12.4;14.46;-8;24.2},{20.8,50;34,23.41;38.875,-17.7;4.863,36.9;42.1,6;-14.55,44.41;-4.57,-12.96;-9.909,2.589;47.549,42;54.9,-17.63},TRUE,TRUE),2,1) returned 0.19054144531344644 (0x3fc863a97e13b089). =INDEX(LINEST({31.78;5.61;-9.09},{53.56,30.22,32;-9,-17.977,47.17;9.4,-11.83,39.39},FALSE,TRUE),2,1) returned 0 (0x0000000000000000). 3 further recorded controls are attached. Inputs were supplied through formula literals. These are controls from this environment, not a same-input comparison with another build.",
      "excel_build": "16.0.20527.20088",
      "observations": [
        {
          "call": "=INDEX(LINEST({-17.979;-0.126;8;-5;1.7;37;12.4;14.46;-8;24.2},{20.8,50;34,23.41;38.875,-17.7;4.863,36.9;42.1,6;-14.55,44.41;-4.57,-12.96;-9.909,2.589;47.549,42;54.9,-17.63},TRUE,TRUE),2,1)",
          "excel": {
            "bits": "0x3fc863a97e13b089",
            "display": "0.19054144531344644",
            "kind": "number"
          },
          "input_route": "formula-literal",
          "inputs": [],
          "recorded_in": "Excel 16.0.20527.20088 Current Channel, Windows 64-bit (NT 10.0.26200), x86-64, AMD Ryzen 7 4800H, en-ZA"
        },
        {
          "call": "=INDEX(LINEST({31.78;5.61;-9.09},{53.56,30.22,32;-9,-17.977,47.17;9.4,-11.83,39.39},FALSE,TRUE),2,1)",
          "excel": {
            "bits": "0x0000000000000000",
            "display": "0",
            "kind": "number"
          },
          "input_route": "formula-literal",
          "inputs": [],
          "recorded_in": "Excel 16.0.20527.20088 Current Channel, Windows 64-bit (NT 10.0.26200), x86-64, AMD Ryzen 7 4800H, en-ZA"
        },
        {
          "call": "=INDEX(LINEST({31.78;5.61;-9.09},{53.56,30.22,32;-9,-17.977,47.17;9.4,-11.83,39.39},FALSE,TRUE),3,1)",
          "excel": {
            "bits": "0x3ff0000000000000",
            "display": "1",
            "kind": "number"
          },
          "input_route": "formula-literal",
          "inputs": [],
          "recorded_in": "Excel 16.0.20527.20088 Current Channel, Windows 64-bit (NT 10.0.26200), x86-64, AMD Ryzen 7 4800H, en-ZA"
        },
        {
          "call": "=INDEX(LINEST({31.78;5.61;-9.09},{53.56,30.22,32;-9,-17.977,47.17;9.4,-11.83,39.39},FALSE,TRUE),4,1)",
          "excel": {
            "bits": null,
            "display": "#NUM!",
            "kind": "error"
          },
          "input_route": "formula-literal",
          "inputs": [],
          "recorded_in": "Excel 16.0.20527.20088 Current Channel, Windows 64-bit (NT 10.0.26200), x86-64, AMD Ryzen 7 4800H, en-ZA"
        },
        {
          "call": "=INDEX(LINEST({31.78;5.61;-9.09},{53.56,30.22,32;-9,-17.977,47.17;9.4,-11.83,39.39},FALSE,TRUE),5,1)",
          "excel": {
            "bits": "0x409190463f141206",
            "display": "1124.0686",
            "kind": "number"
          },
          "input_route": "formula-literal",
          "inputs": [],
          "recorded_in": "Excel 16.0.20527.20088 Current Channel, Windows 64-bit (NT 10.0.26200), x86-64, AMD Ryzen 7 4800H, en-ZA"
        }
      ],
      "platform": "Windows 64-bit (NT 10.0.26200), x86-64, AMD Ryzen 7 4800H, en-ZA",
      "sources": [
        "https://github.com/DnaCalc/ExcelFunctionsHandbook/blob/3345a87/content/notes/FN-LINEST-001.json",
        "https://github.com/DnaCalc/ExcelFunctionsHandbook/blob/3345a87/content/notes/FN-LINEST-002.json"
      ]
    }
  ]
}