Linear Regression & Correlation Calculator
Paste one x,y pair per line to fit a least-squares line y = ax + b. You get the slope, intercept, correlation coefficient r, and R², drawn over a scatter plot. Enter an x value to predict y from the fitted line. Everything is calculated in your browser, and your data is never sent to a server. If you only need a mean or standard deviation, try the Statistics Calculator.
🔒 Runs in your browser · Your data is never sent to a server
Separate x and y with a comma, tab, or space. You can paste two columns straight from a spreadsheet. Lines that are not exactly two numbers (such as headers) are ignored.
Plugs x into the fitted line to estimate y.
Notes
- This is simple regression of y on x. Swapping x and y changes the slope and intercept (the correlation r stays the same).
- A strong correlation does not prove causation, and a single outlier can move the line a lot. Check the scatter plot.
- Predictions are unreliable outside the range of your data (extrapolation).
- Lines with more than two numbers, or with thousands separators such as 1,000, are ignored.
Glossary
Least squares
A method that chooses the line minimizing the sum of squared vertical distances (residuals) between the points and the line.
Correlation coefficient r
Measures the strength of a straight-line relationship from −1 to 1. Near 1 is a strong positive relationship, near −1 a strong negative one, and near 0 a weak linear one.
R² (coefficient of determination)
The share of the variation in y that the line explains, from 0 to 1. In simple regression it equals r squared.
FAQ
How is the regression line calculated?
It uses ordinary least squares: the line y = ax + b that minimizes the sum of squared vertical distances to the points. The slope a is Σ(x−x̄)(y−ȳ) ÷ Σ(x−x̄)², and the intercept b is ȳ − a·x̄.
What is the difference between r and R²?
r ranges from −1 to 1 and shows the strength and direction of the linear relationship. R² is r squared (0 to 1) and tells you the share of the variation in y explained by the line. An R² of 0.81 means r is 0.9 or −0.9.
Why does it say all x values or all y values are the same?
If every x is identical, the slope is undefined, so no line can be fitted. If every y is identical, the line is flat (slope 0), but r and R² are undefined because there is no variation to explain, so they are shown as not available.
Can I paste data straight from a spreadsheet?
Yes. Copy two columns from Excel or Google Sheets and paste them; they arrive tab-separated, one pair per line. Lines that are not exactly two numbers, such as a header row, are ignored.
Share this page
