This free linear regression calculator finds the line of best fit for your data. Paste X and Y values to get the regression equation, slope, intercept, R², residuals and a live scatter plot, then predict Y for any new X.
Linear Regression Calculator
Line of best fit, slope, intercept, R² and predictions
Step-by-step solution
How to Use the Linear Regression Calculator
- Paste the X values (the predictor) and the Y values (the outcome) in matching order.
- Optional: type an X value to predict its Y.
- Press Calculate to see the equation, the graph and a table of predicted values and residuals.
Regression Formulas
ŷ = a + b·x
b (slope) = Σ(x − x̄)(y − ȳ) ÷ Σ(x − x̄)²
a (intercept) = ȳ − b·x̄
- Slope (b): how much Y changes, on average, when X goes up by 1.
- Intercept (a): the predicted Y when X is 0.
- R²: the share of the variation in Y that the line explains, from 0 to 1.
Worked Example
Weeks of practice (1 to 8) and typing speed in words per minute (52, 55, 61, 64, 66, 72, 75, 79). These figures are illustrative.
| Step | Working | Result |
|---|---|---|
| 1. Means | x̄ = 4.5, ȳ = 65.5 | |
| 2. Slope | 162 ÷ 42 | b = 3.857 |
| 3. Intercept | 65.5 − 3.857 × 4.5 | a = 48.14 |
| 4. Equation | ŷ = 48.14 + 3.857x | |
| 5. Predict week 9 | 48.14 + 3.857 × 9 | ≈ 82.9 wpm |
Tips for Good Predictions
- Check the scatter plot first. A straight line only makes sense if the points follow a straight trend.
- Be careful predicting outside your data range (extrapolation). The tool warns you when you do this.
- Look at the residuals. Large or patterned residuals suggest the line is missing something.
To measure the strength of the relationship only, use our Correlation Coefficient Calculator. Regression starts with the mean of each variable.
Frequently Asked Questions
What is a good R² value?
It depends on the field. In physics or engineering, R² above 0.9 is common. In social sciences, 0.3 can be useful. A higher R² means the line explains more of the variation, but it does not prove that X causes Y.
What is a residual?
A residual is the actual Y minus the predicted Y. Positive residuals sit above the line and negative ones below. The regression line makes the sum of squared residuals as small as possible.
Can the slope be negative?
Yes. A negative slope means Y tends to go down as X goes up, such as a car’s value falling as its age rises.
Is this the same as least squares regression?
Yes. This calculator uses ordinary least squares, the standard method for fitting a straight line to data.
More Free Tools
Variance Calculator · Standard Error Calculator · Confidence Interval Calculator · Z-Score Calculator · P-Value Calculator · Correlation Coefficient Calculator · Probability Calculator · Percentage Calculator · Grade Calculator · Flip a Coin · Random Number Generator
See every tool on our free statistics and math tools page.
This calculator is for learning and everyday use. Double-check important results, and follow your teacher’s or school’s method for graded work.