Regression Calculator and Correlation Calculators
Free regression calculator: get the regression equation, slope, intercept, r, R² and p-values from your data, plus correlation, quadratic and logistic tools.
Run a linear regression nowUpdated · Formulas and conventions follow our methodology
In short
A regression calculator fits an equation to paired data so you can predict y from x. For a straight line it finds the least-squares slope b = r · sᵧ / sₓ and intercept a = ȳ − b · x̄, then reports r, R² and a p-value for the slope. Correlation measures how strongly the two variables move together; regression turns that relationship into a prediction rule.
Linear regression calculator: enter your x and y data
Type or paste your (x, y) pairs and get the regression equation ŷ = b₀ + b₁x, the slope and intercept with standard errors, t-tests and p-values, r and R², the ANOVA table, residuals, a scatter plot with the fitted line, and a prediction with its interval. For curves, several predictors or a yes/no outcome, pick another regression calculator from the list below.
Results
The slope is statistically significant at α = 0.05
t = 10.811, df = 10, p = 7.74 × 10⁻⁷. Each 1-unit increase in x is associated with a change of 6.7003 in the mean of y (95% CI 5.3194 to 8.0813).
- Slope, b₁
- 6.7003
- Intercept, b₀
- 11.3169
- Correlation, r
- 0.9598
- Adjusted R²
- 0.9133
- Residual standard error, s
- 9.3361
- F statistic (1, 10)
- 116.8774
- p-value for F (and the slope)
- 7.74 × 10⁻⁷
- Number of pairs, n
- 12
Interpretation: The fitted line is ŷ = 11.3169 + 6.7003x. For every 1-unit increase in x, the predicted y rises by 6.7003. The line explains 92.12% of the variation in y, and a typical point lies about 9.3361 units from it.
Coefficients
Analysis of variance
With one predictor, F = t² for the slope: 10.811² = 116.8774.
Prediction at x = 28
Fitted values and residuals
Standardized residual = e / (s√(1 − h)), where h is the leverage of the point. Values beyond ±2 are worth a second look.
Step-by-step solution
- 1
Add up the columns
n = 12, Σx = 293, Σy = 2099Σxy = 52771, Σx² = 7381x̄ = 24.4167, ȳ = 174.9167 - 2
Compute Sxx and Sxy
Sxx = Σx² − (Σx)² / n = 7381 − (293)² / 12 = 226.9167Sxy = Σxy − (Σx)(Σy) / n = 52771 − (293 × 2099) / 12 = 1520.4167 - 3
Find the slope and intercept
b₁ = Sxy / Sxx = 1520.4167 / 226.9167 = 6.7003b₀ = ȳ − b₁x̄ = 174.9167 − (6.7003)(24.4167) = 11.3169ŷ = 11.3169 + 6.7003x - 4
Measure the scatter around the line
Residuals e = y − ŷ are listed in the residual table.
SSE = Σe² = 871.6225s = √[SSE / (n − 2)] = √(871.6225 / 10) = 9.3361 - 5
Test the slope (H₀: β₁ = 0)
SE(b₁) = s / √Sxx = 9.3361 / √226.9167 = 0.6198t = b₁ / SE(b₁) = 6.7003 / 0.6198 = 10.811, df = 10p = 2 × P(T ≥ |10.811|) = 7.74 × 10⁻⁷ - 6
Build the 95% confidence interval for the slope
t* = 2.2281 (df = 10)b₁ ± t* · SE(b₁) = 6.7003 ± 2.2281 × 0.6198 = (5.3194, 8.0813) - 7
Find R² from the sums of squares
SST = Σ(y − ȳ)² = 11058.9167, SSR = SST − SSE = 10187.2942R² = SSR / SST = 0.9212, adjusted R² = 0.9133 - 8
Predict at x = 28
ŷ = 11.3169 + 6.7003 × 28 = 198.9262Mean response: ŷ ± t* · s√[1/n + (x − x̄)² / Sxx] = 198.9262 ± 2.2281 × 3.4922 = (191.145, 206.7074)New observation: ŷ ± t* · s√[1 + 1/n + (x − x̄)² / Sxx] = 198.9262 ± 2.2281 × 9.9678 = (176.7164, 221.1359)
All 10 correlation and regression calculators
Correlation calculators
Measure the strength and direction of a relationship between two variables.
- Correlation Coefficient CalculatorPearson’s r, R², and the strength and direction of a linear relationship.
- Spearman Correlation CalculatorRank correlation ρ for monotonic relationships and ordinal data, ties handled.
- Covariance CalculatorSample and population covariance of two variables, with the product table.
- Coefficient of Determination CalculatorR² from data, from r, or from sums of squares, with the variance explained.
Linear regression calculators
Fit a straight line, or a plane with several predictors, and predict y.
- Linear Regression CalculatorLeast-squares line with slope and intercept tests, R², residuals and predictions.
- Line of Best Fit CalculatorThe least-squares trend line, its equation and a quick prediction, on a scatter plot.
- Multiple Linear Regression CalculatorRegress y on up to eight predictors with coefficients, t-tests, R² and the F-test.
Curved and logistic regression calculators
Models for curved trends, percentage growth or decay, and binary outcomes.
- Quadratic Regression CalculatorFit y = ax² + bx + c by least squares and see the vertex and R².
- Exponential Regression CalculatorFit y = a·bˣ (or a·eᵏˣ) to growth or decay data, with doubling time or half-life.
- Logistic Regression CalculatorBinary outcome models with coefficients, odds ratios, Wald tests and predicted probabilities.
Correlation calculator vs regression calculator
Correlation is symmetric and unit-free: Pearson’s r runs from −1 to 1 and measures linear association, and swapping x and y does not change it. The correlation calculator gives Pearson’s r, and the Spearman Correlation Calculator applies the same idea to ranks to capture any monotonic relationship. Covariance is the unstandardized version, measured in the units of x times the units of y, so its size is hard to judge on its own. The coefficient of determination R² is the share of the variance in y that a model explains; in simple linear regression it equals r².
Regression is not symmetric. It picks one variable as the outcome and fits the line, curve or model that predicts it best, so regressing y on x and x on y give different lines. Use a correlation calculator when you only want to describe how closely two variables move together, and a regression calculator when you want an equation, a prediction, or to know how much y changes per unit of x. A strong correlation does not by itself show that one variable causes the other.
How to use a regression calculator, step by step
- Put the predictor in x and the outcome in y. One row per observation, with each x paired with its own y. The variable you want to predict always goes in y.
- Plot the data first. A scatter plot shows whether the pattern is a straight line, a curve or no pattern at all, and whether any outlier is pulling the fit.
- Choose the model from the shape. A straight line calls for the Linear Regression Calculator, one bend for the Quadratic Regression Calculator, steady percentage growth or decay for the Exponential Regression Calculator, and a yes/no outcome for the Logistic Regression Calculator. Use the Multiple Linear Regression Calculator when two or more predictors act together.
- Read the equation and the fit. The slope is the change in predicted y for a one-unit increase in x. R² is the share of the variation in y the model explains, and the slope’s p-value tests whether the relationship could be zero in the population.
- Check the residuals, then predict. Residuals should scatter evenly around zero with no curve or funnel shape. Predict only for x values inside the range of your data.
Regression worked example: hours studied and exam score
Problem. Five students report hours studied (x) and exam score (y): (2, 58), (4, 65), (6, 70), (8, 79), (10, 83). Find the regression line, r and R², and predict the score for 7 hours of study.
- 01Means and sums of squares. Compute the means, then the sums of squared deviations and cross-products.x̄ = 6, ȳ = 71Sxx = Σ(x − x̄)² = 40, Syy = Σ(y − ȳ)² = 414, Sxy = Σ(x − x̄)(y − ȳ) = 128
- 02Slope and intercept by least squares.b = Sxy / Sxx = 128 / 40 = 3.2a = ȳ − b · x̄ = 71 − 3.2 × 6 = 51.8ŷ = 51.8 + 3.2x
- 03Correlation and R². The covariance is Sxy / (n − 1) = 32.r = Sxy / √(Sxx · Syy) = 128 / √16,560 = 0.9947R² = r² = 0.9894
- 04Test the slope. With n − 2 = 3 degrees of freedom:t = r√(n − 2) / √(1 − r²) = 16.71, p = 0.0005
- 05Predict inside the data range.ŷ(7) = 51.8 + 3.2 × 7 = 74.2
Answer. The regression equation is ŷ = 51.8 + 3.2x: each extra hour of study goes with about 3.2 more points. r = 0.995 and R² = 0.989, so the line explains about 98.9% of the variation in scores, and the slope is significant (p = 0.0005). The predicted score for 7 hours is 74.2. A prediction for 12 hours (90.2) would be an extrapolation beyond the data and should not be trusted. Enter the five pairs in the calculator above to check each value.
Which correlation or regression calculator should I use?
| If you want to… | Use |
|---|---|
| If you want the strength and direction of a straight-line relationship | |
| If your data are ranks or ordinal scores, or the relationship is monotonic but curved | |
| If you want the covariance of two variables | |
| If you want to know how much of the variation in y a model explains | |
| If you want a quick trend line and a prediction from it | |
| If you want a full simple regression with coefficient tests and residuals | |
| If you have two or more predictor variables | |
| If your data curve upward or downward with a single peak or trough | |
| If you expect y to grow or decay by a roughly constant percentage per unit of x | |
| If you want to predict a binary (yes/no, 0/1) outcome |
Which regression model fits your data?
Choose the model from the shape of the scatter plot and the type of outcome, not from the highest R². A curved model fitted to data that are really straight adds a parameter for nothing, and R² never falls when you add terms. Compare models with adjusted R² and with the residual plot.
| Model | Equation | Use it when |
|---|---|---|
| Simple linear | ŷ = b₀ + b₁x | The points follow a straight line; one predictor |
| Multiple linear | ŷ = b₀ + b₁x₁ + … + bₖxₖ | Several predictors act on the outcome together |
| Quadratic | ŷ = ax² + bx + c | The trend bends once, with a single peak or trough |
| Exponential | ŷ = a · bˣ | y grows or decays by a roughly constant percentage per unit of x |
| Logistic | ln[p / (1 − p)] = β₀ + β₁x | The outcome is binary (yes/no, pass/fail, 0/1) |
How to read regression and correlation results
The sign of r and of the slope gives the direction: positive when y tends to rise with x, negative when it falls. They always share the same sign. The size of r gives the strength of a linear relationship. A common rule of thumb treats |r| near 0.1 as weak, 0.3 as moderate and 0.5 or more as strong, though what counts as strong depends on the field.
R² tells you how much of the spread in y the model accounts for: R² = 0.64 means 64% of the variation in y is explained and 36% is left in the residuals. The p-value for the slope tests whether the true slope is zero; in simple regression it equals the p-value of the correlation test from the Pearson’s Correlation Test Calculator. A tiny p-value with a small R² means the relationship is real but weak, which is common with large samples.
Residuals are the observed minus the predicted values. If they fan out, curve or contain a single huge value, the straight-line model or its p-values are not reliable; try a transformation, a curved model, or the rank-based Spearman Correlation Calculator.
Correlation and regression formulas
| Quantity | Formula | Interpretation |
|---|---|---|
| Sample covariance | sₓᵧ = Σ(xᵢ − x̄)(yᵢ − ȳ) / (n − 1) | Sign gives the direction; size depends on the units |
| Pearson’s r | r = sₓᵧ / (sₓ · sᵧ) | Strength of linear association, from −1 to 1 |
| Spearman’s ρ | Pearson’s r computed on the ranks (average ranks for ties) | Strength of a monotonic association |
| Least-squares slope | b = r · sᵧ / sₓ | Change in predicted y for a one-unit increase in x |
| Intercept | a = ȳ − b · x̄ | Predicted y when x = 0 |
| Coefficient of determination | R² = 1 − SSE / SST | Share of the variance in y explained by the model |
| Adjusted R² | R²ₐ = 1 − (1 − R²)(n − 1) / (n − k − 1) | R² penalized for the number of predictors k |
| Test of ρ = 0 | t = r√(n − 2) / √(1 − r²), df = n − 2 | Gives the same p-value as the slope t-test |
| Exponential model | y = a · bˣ, fitted as ln y = ln a + x · ln b | b − 1 is the growth rate per unit of x |
| Logistic model | ln[p / (1 − p)] = β₀ + β₁x | e^β₁ is the odds ratio for a one-unit increase in x |
Frequently asked questions
How do I find the regression equation from data?
What is the difference between correlation and regression?
What is the difference between Pearson and Spearman correlation?
What counts as a strong correlation?
Is R² the same as r squared?
Does correlation imply causation?
When should I use logistic regression instead of linear regression?
Can I use a regression line to predict outside my data?
Looking for something else? See all calculators or search the site.