Skip to content

feat(HF-221): add LINEST regression function - #1769

Open
Tobiadefami wants to merge 3 commits into
developfrom
feature/hf-221-linest
Open

feat(HF-221): add LINEST regression function#1769
Tobiadefami wants to merge 3 commits into
developfrom
feature/hf-221-linest

Conversation

@Tobiadefami

@Tobiadefami Tobiadefami commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

Context

How did you test your changes?

Types of changes

  • Breaking change (a fix or a feature because of which an existing functionality doesn't work as expected anymore)
  • New feature or improvement (a non-breaking change that adds functionality)
  • Bug fix (a non-breaking change that fixes an issue)
  • Additional language file, or a change to an existing language file (translations)
  • Change to the documentation

Related issues:

  1. Fixes #...

Checklist:

  • I have reviewed the guidelines about Contributing to HyperFormula and I confirm that my code follows the code style of this project.
  • I have signed the Contributor License Agreement.
  • My change is compliant with the OpenDocument standard.
  • My change is compatible with Microsoft Excel.
  • My change is compatible with Google Sheets.
  • I described my changes in the CHANGELOG.md file.
  • My changes require a documentation update.
  • My changes require a migration guide.

Note

Medium Risk
New array-returning statistical function with strict static stats sizing and numerically sensitive regression output; limited blast radius but worth careful review against Excel edge cases.

Overview
Adds LINEST for simple and multiple linear regression, with optional intercept (const) and an optional five-row statistics block (stats).

Implementation is a new RegressionPlugin plus a fitLinearRegression numerical core (pivoted Householder QR, rank handling aimed at Excel-like behavior). Result width follows predictor layout (paired, column, or row known_x); linestArraySize fixes array height/width before evaluation. Unlike Excel, stats must be a compile-time constant (e.g. TRUE() / FALSE()); cell references or computed booleans yield #VALUE!, with matching runtime checks so nested formulas cannot bypass sizing.

Docs cover LINEST limitations and Excel/Google numerical differences; changelog, function metadata, error messages, and localized function names are updated.

Reviewed by Cursor Bugbot for commit 65cb773. Bugbot is set up for automated code reviews on this repo. Configure here.

@cla-external-contractor-signup

Copy link
Copy Markdown

@Tobiadefami thanks for the pull request. No CLA step needed here — our records show you signed the Contributor License Agreement on 2026-07-31. That signature came from our previous signing form and has been carried over, so there is nothing for you to re-sign.

@qunabu

qunabu commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Task linked: HF-221 Function LINEST

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 64b6393. Configure here.

const interceptError = fitIntercept ? finiteValue(fit.interceptError) : new CellError(ErrorType.NA)
result.push([...fit.standardErrors].reverse().map(finiteValue).concat(interceptError))
result.push([finiteValue(rSquared), finiteValue(Math.sqrt(variance))])
result.push([f, fit.degreesOfFreedom])

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Degenerate LINEST stats emit zeros

Medium Severity

When residual degrees of freedom is 0 (exact interpolation, including the common two-point LINEST with stats enabled), uncomputable uncertainties are emitted as 0 and F becomes #NUM!. Excel and Sheets return #N/A for the coefficient standard errors, residual standard error, and F in that case, so a zero standard error can look like a precise fit instead of an undefined statistic.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 64b6393. Configure here.

@github-actions

github-actions Bot commented Sep 10, 2026

Copy link
Copy Markdown

Performance comparison of head (65cb773) vs base (c920375)

                                     testName |    base |    head | change
--------------------------------------------------------------------------
                                      Sheet A |  460.17 |     456 | -0.91%
                                      Sheet B |  142.74 |  141.46 | -0.90%
                                      Sheet T |  126.82 |  124.37 | -1.93%
                                Column ranges |  591.05 |  588.39 | -0.45%
                                Sorted lookup | 17100.9 | 17266.4 | +0.97%
Sheet A:  change value, add/remove row/column |   13.82 |   12.78 | -7.53%
 Sheet B: change value, add/remove row/column |  125.93 |  122.58 | -2.66%
                   Column ranges - add column |  158.53 |  152.94 | -3.53%
                Column ranges - without batch |  493.73 |  480.94 | -2.59%
                        Column ranges - batch |  124.03 |  120.57 | -2.79%

@codecov

codecov Bot commented Sep 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.38%. Comparing base (c920375) to head (65cb773).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1769      +/-   ##
===========================================
+ Coverage    97.32%   97.38%   +0.05%     
===========================================
  Files          195      197       +2     
  Lines        15739    15957     +218     
  Branches      3390     3518     +128     
===========================================
+ Hits         15318    15539     +221     
+ Misses         421      410      -11     
- Partials         0        8       +8     
Files with missing lines Coverage Δ
src/error-message.ts 100.00% <100.00%> (ø)
src/i18n/languages/csCZ.ts 100.00% <ø> (ø)
src/i18n/languages/daDK.ts 100.00% <ø> (ø)
src/i18n/languages/deDE.ts 100.00% <ø> (ø)
src/i18n/languages/enGB.ts 100.00% <ø> (ø)
src/i18n/languages/esES.ts 100.00% <ø> (ø)
src/i18n/languages/fiFI.ts 100.00% <ø> (ø)
src/i18n/languages/frFR.ts 100.00% <ø> (ø)
src/i18n/languages/huHU.ts 100.00% <ø> (ø)
src/i18n/languages/idID.ts 100.00% <ø> (ø)
... and 12 more

... and 6 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
hyperformula-docs 65cb773 Commit Preview URL

Branch Preview URL
Sep 10 2026, 07:58 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants