Linear Regression Calculator
Fit paired data or CSV columns, inspect residuals and estimate values with clear local exports.
This tool processes its input contents in your browser instead of sending them to a processing service. Page, asset and fixed usage-measurement requests are described on the Privacy page.
Fit an unweighted least-squares line with an intercept to paired values or CSV columns, then inspect R², residuals and a clearly labeled fitted estimate.
How to use it
- 1Paste X, Y pairs, or select two numeric CSV columns.
- 2Choose whether incomplete CSV pairs must be rejected or explicitly omitted.
- 3Fit the line and review observations, residuals and method limitations.
- 4Estimate a Y at an optional X, then export all rows and settings.
Example
- Input
- X: 1, 2, 3, 4, 5; Y: 2, 4, 5, 4, 5
- Output
- ŷ = 2.2 + 0.6X; R² = 0.6; SSE = 2.4.
A fit does not prove causation. Predictions outside the observed X range are flagged.
What happens to your data
Pairs and local CSV files are processed in browser memory. No dataset upload or persistent history; optional event labels omit numeric values, filenames and column names.
Last updated November 2026
Fit a straight line without hiding the observations behind it. This linear regression calculator accepts X–Y pairs or two selected CSV columns, then shows the slope, intercept, R², correlation and residual for every accepted pair. The plot and exported rows help you check what the line fits and what it misses.
The method is ordinary unweighted least squares with an intercept and one predictor. It provides descriptive fitted values and a clearly labeled estimate at an optional X. It does not claim causation, supply automatic scientific conclusions, or turn extrapolation into a reliable forecast.
How it works
The fitted model is ŷ = a + bX. With centered sums Sxx = Σ(X−X̄)² and Sxy = Σ(X−X̄)(Y−Ȳ), the slope is b = Sxy/Sxx and the intercept is a = Ȳ−bX̄. Accepted values first become IEEE 754 binary64 browser numbers. Each represented value is then decoded as an integer times a power of two; sums, products and regression moments are accumulated exactly with bounded integers. Slope, intercept, each fitted value, each residual and the residual sum of squares are formed from those exact moments before conversion back to browser numbers for reporting. This handles both adjacent X values with an unrepresentable midpoint and mixed-scale cancellation. Reported values are rounded browser numbers, so subtracting two rounded CSV columns can differ from the separately computed residual. This is exact accumulation of the accepted binary64 values, not exact arithmetic on every entered decimal digit. Entered decimals that cannot round-trip through the browser number’s decimal representation are rejected before fitting, so silently lost input digits do not create a false constant series. The guard does not make binary arithmetic exact; rescale the original measurements if large values conceal small differences.
A residual is observed Y minus fitted Y. Sum of squared residuals is SSE. The displayed RMSE is √(SSE/n), while residual standard deviation is √(SSE/(n−2)); those are different denominators. The latter is undefined for two pairs. R² is 1−SSE/Syy for nonconstant Y, and Pearson r is the normalized centered cross-product. Constant Y makes r and R² undefined rather than automatically proving a perfect model. Constant X prevents slope estimation and is rejected. The fit requires at least two complete pairs.
The line minimizes vertical squared residuals in the supplied units. This page does not fit a zero-intercept, weighted, robust, polynomial or multiple-predictor model. It does not infer error distributions, calculate p-values or confidence/prediction intervals, correct for measurement error, or prove that a linear model is suitable. Inspect residuals and the actual problem before interpreting fit quality. A high R² can coexist with a misleading model, unusual leverage points or a relation that will not hold for new observations. An X outside the observed range receives an extrapolation warning.
In pair mode, put X first and Y second, one pair per line, separated by a comma or whitespace. Blank lines are ignored; partial pairs and extra columns are rejected. In CSV mode, provide unique nonblank column headers, choose comma, semicolon or tab, read the columns, and select two different columns. The explicit blank-pair policy either rejects an incomplete record or omits the whole pair with a visible count. Other non-numeric selected cells always receive a record-specific error. The tool never independently filters X and Y and accidentally pairs values from different records.
Limits are 1 MiB of valid UTF-8 text, 10,000 pasted pairs, or 10,000 CSV records including the header under the shared 200-column/200,000-cell CSV guard. Each numeric token has at most 200 characters and must be a decimal or e-notation value. Nonzero magnitudes range from 1e−100 to 1e100. Inputs that overflow or underflow are rejected. A calculation outside the finite numerical range is also rejected. Local files are read into this browser tab; no account or dataset upload is needed.
The scatter preview samples at most 500 observations in original order and clips the displayed line to its plot. It is a preview, not an assurance that every unusual point is visible. The expandable table shows the first 20 rows. CSV and JSON contain all fitted rows, original record numbers and residuals; JSON additionally contains the method, computed summary, selected columns, blank policy, any current prediction and a JSON-safe exact-moment audit model. Displayed values round to 12 significant digits while exports retain computed precision. Editing observations or settings clears old results and estimates; changing the prediction X clears its old answer. Data are kept only in tab memory, not a URL or persistent history. Optional analytics receives fixed action labels and input mode, never values, column names or filenames.
Worked example: A fit with visible residual error
- Input
- (1,2), (2,4), (3,5), (4,4), (5,5)
- Result
- ŷ = 2.2 + 0.6X; R² = 0.6; SSE = 2.4; RMSE ≈ 0.692820323028
At X = 3 the fitted value is 4. The observed Y is 5, so its residual is +1. The example is descriptive, not a forecast.
Common use cases
- Check a simple calibration line and inspect every observed-versus-fitted residual.
- Compare two numeric CSV columns while retaining their original row pairing.
- Create a transparent classroom regression example with a plot and exported calculation.
- Estimate a fitted value inside an observed range while keeping extrapolation clearly labeled.
Frequently asked questions
What is the difference between RMSE and residual standard deviation?+
Here RMSE is the square root of SSE divided by n. Residual standard deviation uses n−2 because a slope and intercept were estimated. It is undefined for a two-pair fit; the page labels this explicitly.
Does a high R² prove that X causes Y?+
No. It describes how the fitted line accounts for variation in the supplied Y values under this calculation. It does not establish causation, model suitability or future accuracy.
Why is constant X rejected?+
All accepted X values are identical at browser precision, so Sxx is zero and the slope is not identifiable. Use genuinely distinct observations, and rescale at the original source if precision was lost.
Can I fit a line through zero or use observation weights?+
This page uses ordinary unweighted least squares with an estimated intercept. Zero-intercept, weighted, robust, polynomial and multiple-predictor fits are outside its scope.
Are all points shown on the scatter plot?+
Up to 500 are sampled in original order for the preview. The table shows 20. Every accepted pair, fitted value and residual is retained in CSV and JSON.
Related tools
Standard Deviation Calculator
Analyze a list or CSV column with sample/population spread, quartiles, outlier flags and exports.
CSV Data Profile
Inspect CSV column counts, empties, distinct values and duplicate rows locally; export a JSON profile.
CSV Filter
Filter CSV rows, select output columns and download a focused table without uploads.
Scientific Notation Converter
Convert exact decimals to scientific, engineering and plain notation with explicit rounding options.