Built and fact-checked by the DocNectar team — see our editorial standards
Key Features
Instant Calculation
Get accurate results in real time with our optimized algorithm.
Mobile Friendly
Fully responsive design. Works on all devices & screen sizes.
Privacy Focused
Your data stays on your device. We don't store any inputs.
100% Free
No hidden costs. This tool is completely free forever.
Linear regression finds the straight line that best fits a scattered set of data points — minimizing the total squared distance between the line and every point — giving both a predictive equation and a measure of how well that line actually fits the data.
This calculator finds the least-squares regression line and R² for your x,y data.
How it works
Enter your x values and y values as comma-separated lists (with matching counts). The calculator applies the least-squares formulas to find the slope and intercept of the best-fit line, then computes R² to measure how well that line fits the data.
- Enter x values (comma-separated).
- Enter y values (comma-separated).
- Click Calculate to see your results.
Examples
5 data points
For x = 1,2,3,4,5 and y = 2,4,5,4,5, the best-fit line is y = 0.6x + 2.2, with an R² of 0.6 — meaning the line explains 60% of the variation in y.
Who should use it
- Finding a best-fit line and prediction equation for a statistics or data science course.
- Quantifying how strongly two variables are linearly related in a small data set.
Industry applications
- Statistics and data science education
- Business analytics and forecasting
Advantages
- Computes the full regression equation, not just a correlation strength number.
- Reports R² alongside the equation to show how well the line actually fits.
Limitations
- Assumes a linear relationship — doesn't detect or fit curved (polynomial, exponential, etc.) relationships.
Common mistakes to avoid
- Using linear regression on data with an obviously non-linear (curved) pattern, where a straight-line fit will systematically misrepresent the relationship.
- Confusing R² (goodness of fit) with the slope (rate of change) — a strong R² doesn't tell you whether the relationship is large or small in practical terms, just how well it fits a straight line.
Best practices
- Plot your data (even roughly) before trusting a linear regression result — R² can be misleadingly high even when the true relationship is curved, if the curve happens to be gentle over your specific data range.
Tips
- Once you have the regression equation, you can predict a y value for any new x by simply substituting it in — but be cautious about predicting far outside the range of your original data (extrapolation), where the linear relationship may no longer hold.