Linear regression calculator
A correlation says two variables move together; a regression gives you the equation that predicts one from the other, with the test of whether it holds.
Simple linear regression fits the straight line that best predicts an outcome from a single predictor, by minimising the squared distance between the line and the data. Paste paired x and y columns and this calculator returns the slope, the intercept, the full regression equation, r-squared, the standard error of the estimate, and the significance test of the slope, so you can see both the model and whether to trust it.
Regression equation
y = 1.999x + 0.047
r² = 0.999; the slope is significant (p = < .001).
The slope is the predicted change in y for each one-unit increase in x, and r squared is the proportion of variance in y the model explains. Check linearity, equal-variance, and normal-residual assumptions before relying on the significance test.
How the line is fitted
Ordinary least squares chooses the slope and intercept that minimise the sum of squared residuals. The slope is the covariance of x and y divided by the variance of x, and the intercept makes the line pass through the means:
b = Σ(x - x̄)(y - ȳ) / Σ(x - x̄)², a = ȳ - b·x̄
r-squared is the share of the outcome's variance the line explains, equal to the squared correlation in the simple-regression case. The standard error of the slope comes from the residual variance divided by the spread of x, and dividing the slope by that standard error gives a t statistic with n - 2 degrees of freedom, whose two-tailed area is the p-value. The standard error of the estimate is the typical size of a residual, in the units of y.
Frequently asked questions
- What is the difference between correlation and regression?
Correlation summarises the strength and direction of a relationship in a single symmetric number, treating the two variables equally. Regression goes further by fitting an equation that predicts one variable from the other, giving a slope, an intercept, and a way to estimate outcomes for new values. Correlation answers how closely two variables move together; regression answers how much the outcome changes per unit of the predictor.
- What does the slope in a regression mean?
The slope is the predicted change in the outcome for each one-unit increase in the predictor. A slope of 2.5 means the model expects the outcome to rise by 2.5 units every time the predictor goes up by one, in whatever units each variable is measured. Its significance test, the t value and p-value reported here, asks whether that slope is reliably different from zero.
- What is a good r-squared value?
There is no universal threshold, because what counts as a good r-squared depends on the field and the question. In tightly controlled physical measurements an r-squared below 0.9 may be disappointing, while in human behaviour research an r-squared of 0.3 can be a strong result. Rather than chasing a number, judge r-squared against typical values in your area and report it alongside the slope and its confidence, not on its own.
- What assumptions does linear regression make?
Simple linear regression assumes the relationship between predictor and outcome is genuinely linear, that the residuals are independent, that their variance is roughly constant across the range of the predictor (homoscedasticity), and that they are approximately normally distributed. It is also sensitive to influential outliers. Checking these with residual plots matters before trusting the slope's significance, because a good-looking r-squared can mask a violated assumption.