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.
Interpreting the slope, intercept, and R-squared
The slope is the working heart of the model: it is the predicted change in the outcome for every one-unit rise in the predictor, stated in the real units of each variable. A slope of 2.5 on a model of exam score against hours studied says the model expects 2.5 more marks per extra hour. The intercept is the predicted outcome when the predictor is zero, which is only meaningful when a value of zero actually falls inside your data; for a predictor like age or income it is often just a mathematical anchor rather than a real-world prediction.
R-squared reports the share of the outcome's variance the line explains, from 0 to 1, so 0.40 means the predictor accounts for 40 percent of the variation. Resist judging a model by r-squared alone. A high value can hide a violated assumption, and what counts as good is entirely field-dependent: 0.3 is a strong result in human behaviour research and disappointing in a physics laboratory. Always pair r-squared with the slope, its significance, and the wider context, and remember that explaining variance is not the same as proving cause, a point our note on the correlation and causation distinction makes in full.
Linear regression assumptions you must check
A fitted line is only trustworthy when its assumptions hold, and the t value beside the slope assumes all of them. The relationship must be genuinely linear; the residuals must be independent of one another, which time-ordered data often breaks; their spread must stay roughly constant across the range of the predictor, a condition called homoscedasticity; and they should be approximately normally distributed. A residual-versus-fitted plot exposes curvature and a fanning spread at a glance, while a normal probability plot checks the distribution of the errors.
Two further problems deserve a look. Influential outliers can tilt the whole line, so inspect any point with a large residual or high leverage before trusting the fit, and in multiple models multicollinearity between predictors inflates the standard errors and destabilises the coefficients. Confirm the residuals are well-behaved with a formal normality check on the errors, and read our full walkthrough of the linear regression assumptions for the diagnostic plots and the fixes when one is violated.
Simple vs multiple linear regression
Simple linear regression uses a single predictor, which is rarely enough for a real research question. Multiple linear regression adds two or more predictors to the same equation, and the payoff is interpretive: each coefficient now measures the effect of its predictor while holding the others constant. That lets you separate the contribution of, say, study hours from prior attainment instead of blending them, and it lets you control for confounders that a simple model would let masquerade as the effect of interest.
Moving to multiple predictors changes how you read the output. Quote the adjusted r-squared rather than the raw value, because the plain r-squared can only rise as predictors are added, while the adjusted figure penalises predictors that earn their place. Watch for multicollinearity among the predictors, since highly correlated inputs make individual coefficients unstable and hard to interpret. The same least-squares logic and the same regression assumptions still apply; there are simply more relationships to check before the model can be trusted.
Linear vs logistic regression
The deciding factor is the type of outcome. Linear regression predicts a continuous outcome such as a score, a price, or a measurement, and its slope reads as a change in units. When the outcome is categorical, typically a yes or no event like passed or failed, a straight line is the wrong tool, because it can predict impossible probabilities below zero or above one. Logistic regression solves this by modelling the log-odds of the event, keeping every prediction inside the valid 0-to-1 range.
The interpretation shifts accordingly. A logistic model reports odds ratios rather than slopes, where a value above one means the predictor raises the odds of the outcome and a value below one means it lowers them. If your dependent variable is binary, switch methods rather than forcing a linear fit, and use the effect size converter to put an odds ratio on a familiar scale. Our guide to making sense of logistic regression output covers reading those odds ratios and their confidence intervals in detail.
Reporting regression results in APA style
APA style expects the overall model and the individual predictors to be reported in a fixed order. State the model fit first with its F test, for example F(1, 48) = 22.13, p < .001, followed by the r-squared as the share of variance explained. Then report each predictor's unstandardised slope b, its standard error, the standardised beta, and the exact p-value, so a reader can see both the raw effect in real units and the comparable standardised effect. Round coefficients to two decimals and give exact p-values to three.
For a multiple regression, a results table is far clearer than prose: one row per predictor with the coefficient, standard error, beta, and significance, plus the model fit summarised beneath it. Write a short paragraph above the table interpreting the meaningful predictors in plain language rather than restating every number. Our walkthrough of writing statistics into an APA results section and our results formatting tool turn the raw output into the exact sentences and tables your committee expects.
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.