STATISTICAL REGRESSION
Linear Regression Calculator
Fit a straight line to paired X and Y observations using ordinary least squares. Inspect the equation, graph, R-squared, RMSE and residuals before exporting your results.
YOUR DATA
Enter paired observations
Paste or upload two or more numeric columns. Use a comma, tab or semicolon between columns and a period as the decimal mark. The first non-empty line is treated as a header by default. The tool accepts up to 5,000 observations.
The file is read locally by your browser; it is not sent to this website.
YOUR RESULTS
Linear fit
Observed values and fitted line
Each point is one input observation.
Residuals by observation
Residual = observed Y − predicted Y. Positive values fall above the fitted line.
| Row | Observed Y | Predicted Y | Residual |
|---|
How to use this calculator
- Paste paired X and Y values, or load the sample data.
- Choose which columns represent X and Y. The tool reports invalid rows instead of silently dropping them.
- Calculate the line, then review its equation, plot, R², RMSE and residuals.
- Download the result summary as JSON for your own notes.
Formula and calculation method
The calculator fits ŷ = a + bx using ordinary least squares, where b = Σ((x − x̄)(y − ȳ)) / Σ((x − x̄)²) and a = ȳ − bx̄. It then calculates R² as 1 − SSE/SST and RMSE as the square root of SSE divided by the number of observations.
R² describes fit to these observations. It does not prove that X causes Y or that the model will predict new data accurately.
Assumptions and limitations
- Each X value must be finite, and at least two complete paired observations are required.
- All X values cannot be identical; otherwise a slope cannot be estimated.
- R² is shown as undefined when every observed Y value is identical, because total variation is zero.
- Ordinary least squares describes the best straight-line fit under squared-error loss; it does not test statistical significance or validate assumptions such as independence.
- Numeric values use a period as the decimal mark; commas, tabs or semicolons separate columns.
- The current input limit is 5,000 observations and 5 MB per file. Larger inputs are rejected with a message; they are not partially calculated.
- RMSE is measured in the same units as Y and is sensitive to large errors and outliers.
Worked example
Use the example button to load study hours and exam scores. The plotted observations and fitted line let you see how the calculator turns paired data into a trend. Your own input remains in the page only while it is open; it is not saved to an account.
Return to all tool areas