Math
Linear Regression Calculator
Fit a least-squares line to paired (x, y) data. Returns slope, intercept, correlation r, R squared, residuals, and standard error.
Data points
Separate x and y with a comma, space, or tab. Need at least 2 points with distinct x values.
Regression equation
y = 1 × x + 1.333333
Correlation (r)
0.9165
R squared
0.84
Slope
1
Intercept
1.3333
Mean x
3.5
Mean y
4.8333
SSE
3.3333
SST
20.8333
Std. error
0.9129
Points (n)
6
Frequently Asked Questions about the Linear Regression Calculator
What is least squares regression?
Least squares finds the line that minimizes the sum of squared vertical distances between each data point and the fitted line. Squaring those gaps penalizes large misses more than small ones, which produces a unique slope and intercept for any dataset where x is not constant.
What is the difference between r and R squared?
Pearson r ranges from -1 to +1 and shows the direction and strength of the linear relationship: -1 is a perfect negative line, 0 is no linear pattern, +1 is a perfect positive line. R squared is r x r, runs from 0 to 1, and tells you the share of variance in y explained by x. An R squared of 0.81 means 81% of the variation in y is captured by the regression line.
What are residuals and why do they matter?
A residual is the gap between an observed y value and the y value the line predicts for that x. This calculator shows each one as (observed - predicted). Plotting residuals is the fastest way to judge your fit: random scatter around zero means the linear model is reasonable, while a curved pattern or a funnel that widens with x signals that a different model would serve you better.
Does a strong correlation prove causation?
No. Regression measures association, not cause. Ice cream sales and drowning rates both rise in summer but neither drives the other. A high r just means the two variables move together. Establishing causation requires a controlled experiment or a careful causal-inference design.
When should I not use linear regression?
Avoid it when your scatter plot is clearly curved, when residuals fan out as x grows (heteroscedasticity), when a few outliers are pulling the slope, or when your response variable is categorical or a count with many zeros. Polynomial, logistic, or robust regression typically handle those cases better. Also, this calculator returns no result if all your x values are identical, because the slope is undefined in that case.