Least-Squares Formula and Method
Objective
minβ ||Xβ − y||₂²Choose coefficients that minimize the sum of squared residuals.
Normal equations
XᵀXβ = XᵀyA full-rank solution satisfies these equations, but the calculator does not invert XᵀX directly.
SVD solution
β = X⁺y = VΣ⁺UᵀyThe pseudoinverse gives the unique least-squares vector at full rank and the minimum-norm solution otherwise.
σ₁ · 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
- Choose the observation and predictor counts. Keep Include intercept selected for an ordinary regression with a constant term.
- Enter each predictor row and its response, or paste a rectangular table with
ylast. - Select Calculate regression. The SVD pseudoinverse solves the least-squares problem and determines numerical rank.
- 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. R² 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.
