Linear Regression Calculator
Line of best fit from x, y data: slope, intercept, r, R² and a scatter plot.
About this tool
Paste or type x and y values, one pair per line, separated by a comma, space or tab, so columns copied from a spreadsheet work as they are. The calculator gives the regression equation, slope with its standard error, intercept, correlation r with a plain-English strength, R², the standard error of the estimate and a prediction at any x you choose. A scatter plot shows the points and the fitted line.
How linear regression works
Simple linear regression fits the straight line ŷ = mx + b that makes the squared vertical distances from the points as small as possible, a method called least squares. The slope m is how much y changes, on average, for each one-unit increase in x. The intercept b is the predicted y when x is zero. The correlation r, from −1 to 1, measures how tightly the points follow a straight line and in which direction. R² is the share of the variation in y that the line explains. In the example of study hours against test scores, the slope is about 4.5 points per hour, R² is above 0.99, and the line predicts about 92 at 10 hours. The standard error of the estimate is the typical size of a prediction miss. Always look at the plot. A curved pattern needs a different model, a single outlier can pull the line a long way, and predicting far beyond your range of x values is unreliable. Above all, correlation is not causation: two things can move together because of a third factor. The standard deviation calculator, the z-score calculator and the chart maker help explore data further. Mean, median and mode: which average to use, and when the mean lies covers the basics of averages.
Frequently asked questions
How do I calculate a line of best fit?
Slope = Σ(x − x̄)(y − ȳ) ÷ Σ(x − x̄)², and intercept = ȳ − slope × x̄. This calculator does it from your pasted data.
What is a good R² value?
It depends on the field. Physical measurements often exceed 0.9, while social data with R² of 0.3 can still be meaningful. Always look at the plot too.
What is the difference between r and R²?
r is the correlation, between −1 and 1, showing strength and direction. R² is r squared, the share of variation in y explained by the line.
Is my data uploaded?
No. Everything runs in your browser and nothing is stored or sent.