Least Squares Regression Matrix Calculator

Fit y ≈ Xβ for 2–20 observations and up to 6 predictors. Get coefficients, fitted values, residuals, diagnostics, and matrix working; your data stays in your browser.

Enter Predictors and Response

Each row is one observation. Enter finite integers, decimals, or scientific notation; the final column is the response y.

Use one observation per line and separate values with spaces, commas, or tabs. The last value in every row is y; do not paste an intercept column when Include intercept is selected.

Regression Results

Enter valid data to calculate the least-squares fit.
Coefficients
SSE
RMSE
Design rank
Residual df
2-norm condition
Rank and numerical diagnostics appear after a successful calculation.

Fitted Values and Residuals

RowObserved yFitted ŷResidual

Advertisement

Least-Squares Matrix Steps

Calculate valid data to see the design matrix, SVD rank decision, normal-equation matrices, and fit diagnostics.

Least-Squares Formula and Method

Objective

minβ ||Xβ − y||₂²

Choose coefficients that minimize the sum of squared residuals.

Normal equations

XᵀXβ = Xᵀy

A full-rank solution satisfies these equations, but the calculator does not invert XᵀX directly.

SVD solution

β = X⁺y = VΣ⁺Uᵀy

The pseudoinverse gives the unique least-squares vector at full rank and the minimum-norm solution otherwise.

Numerical method: The calculator uses a one-sided Jacobi SVD in JavaScript double precision. Singular values at or below σ₁ · max(n,p) · 64ε are treated as zero. Enter at least as many observations as design columns (predictors plus an optional intercept), and rescale predictors when the reported condition number is very large.

How to Use the Regression Matrix Calculator

  1. Choose the observation and predictor counts. Keep Include intercept selected for an ordinary regression with a constant term.
  2. Enter each predictor row and its response, or paste a rectangular table with y last.
  3. Select Calculate regression. The SVD pseudoinverse solves the least-squares problem and determines numerical rank.
  4. Review the coefficients, predictions, residuals, goodness-of-fit statistics, condition number, and matrix steps.

Interpreting the Results

Each coefficient estimates the change in the fitted response associated with a one-unit increase in its predictor while the other predictor columns stay fixed. The intercept is the fitted response when all predictors equal zero.

SSE is the sum of squared residuals. RMSE is √(SSE/n) and uses the same units as the response. compares SSE with variation around the response mean; it is undefined when every observed response is equal and may be negative for a model fitted without an intercept.

A rank smaller than the number of design columns means some columns are linearly dependent. A large condition number signals sensitivity: small input changes can produce large coefficient changes even when fitted values look stable.

Least Squares Regression FAQs

What does least squares minimize?

It minimizes Σ(yᵢ − ŷᵢ)², the sum of squared vertical residuals between observed and fitted responses.

Should I include an intercept?

Usually yes. The option adds a column of ones automatically. Turn it off for a regression deliberately constrained through the origin or when your predictor matrix already contains the constant column you want.

Why does this calculator use SVD?

SVD solves the least-squares problem without explicitly inverting XᵀX, whose condition number is the square of the design matrix’s condition number. It also exposes numerical rank and supports a pseudoinverse solution.

What does rank deficient mean?

At least one design column can be reproduced from the others, so individual coefficients are not uniquely identifiable. The displayed vector is the Moore–Penrose minimum-norm solution; fitted values are still uniquely determined.

Can R² be negative?

Yes. A no-intercept regression can fit worse than the response mean, producing a negative centered R². With an intercept and ordinary finite data, R² is normally between zero and one apart from small rounding effects.

Is this statistical inference?

No. The page performs numerical least-squares fitting only. It does not calculate confidence intervals, p-values, causal effects, or validate assumptions such as independence, constant variance, and an appropriate model form.

Are my data private?

Yes. The page calculates locally and does not transmit or save your predictor or response values.

Calculation Notes

Last reviewed: August 5, 2026 by the Starlight Tools editorial team.

This is a numerical and educational calculator, not statistical or domain-specific advice. It reports descriptive fit measures from the supplied matrix. Conclusions still depend on data quality, sampling, model choice, and regression assumptions.

Explore more tools