Skip to content
Statculator

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 now

Updated · 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.

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.

Full Linear Regression Calculator page with formulas and FAQ
Paired data (x, y)
#x (predictor)y (response)Remove row
1
2
3
4
5
6
7
8
9
10
11
12
Tip: paste rows straight from a spreadsheet.

x is the explanatory variable, y the outcome you want to predict. One observation per row.

%

Used for the coefficient intervals and the prediction intervals.

Optional. Leave blank to skip the prediction.

Inference assumes a straight-line mean, independent observations, and residuals with constant spread that are roughly normal.

Results

Regression equation
ŷ = 11.3169 + 6.7003x
R²
0.9212
92.12% of the variation in y explained
Predicted y at x = 28
198.9262
95% PI 176.7164 to 221.1359

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.

Scatter plot of 12 points with fitted line120140160180200220240y1820222426283032x(18, 128)(21, 155)(24, 162)(19, 147)(27, 201)(30, 208)(25, 172)(22, 166)(29, 190)(32, 236)(20, 139)(26, 195)ŷ = 11.32 + 6.7x
Line: least-squares regression of y on x.

Coefficients

TermEstimateStd. errortp-value95% CI lower95% CI upper
Intercept (b₀)11.316915.37090.73630.4785-22.931545.5653
Slope (b₁)6.70030.619810.8117.74 × 10⁻⁷5.31948.0813

Analysis of variance

SourcedfSSMSFp-value
Regression110187.294210187.2942116.87747.74 × 10⁻⁷
Residual10871.622587.1622
Total1111058.9167

With one predictor, F = t² for the slope: 10.811² = 116.8774.

Prediction at x = 28

QuantityEstimateLowerUpper
95% CI for the mean of y198.9262191.145206.7074
95% prediction interval for one new y198.9262176.7164221.1359

Fitted values and residuals

#xyŷResidual eStandardized residual
118128131.9229-3.9229-0.49
221155152.02392.97610.3427
324162172.1249-10.1249-1.1332
419147138.62328.37681.0112
527201192.22598.77410.9977
630208212.3268-4.3268-0.525
725172178.8252-6.8252-0.7642
822166158.72427.27580.8256
929190205.6265-15.6265-1.8438
1032236225.727510.27251.3511
1120139145.3235-6.3235-0.7431
1226195185.52559.47451.0664

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. 1

    Add up the columns

    n = 12, Σx = 293, Σy = 2099
    Σxy = 52771, Σx² = 7381
    x̄ = 24.4167, ȳ = 174.9167
  2. 2

    Compute Sxx and Sxy

    Sxx = Σx² − (Σx)² / n = 7381 − (293)² / 12 = 226.9167
    Sxy = Σxy − (Σx)(Σy) / n = 52771 − (293 × 2099) / 12 = 1520.4167
  3. 3

    Find the slope and intercept

    b₁ = Sxy / Sxx = 1520.4167 / 226.9167 = 6.7003
    b₀ = ȳ − b₁x̄ = 174.9167 − (6.7003)(24.4167) = 11.3169
    ŷ = 11.3169 + 6.7003x
  4. 4

    Measure the scatter around the line

    Residuals e = y − ŷ are listed in the residual table.

    SSE = Σe² = 871.6225
    s = √[SSE / (n − 2)] = √(871.6225 / 10) = 9.3361
  5. 5

    Test the slope (H₀: β₁ = 0)

    SE(b₁) = s / √Sxx = 9.3361 / √226.9167 = 0.6198
    t = b₁ / SE(b₁) = 6.7003 / 0.6198 = 10.811, df = 10
    p = 2 × P(T ≥ |10.811|) = 7.74 × 10⁻⁷
  6. 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. 7

    Find R² from the sums of squares

    SST = Σ(y − ȳ)² = 11058.9167, SSR = SST − SSE = 10187.2942
    R² = SSR / SST = 0.9212, adjusted R² = 0.9133
  8. 8

    Predict at x = 28

    ŷ = 11.3169 + 6.7003 × 28 = 198.9262
    Mean 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 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

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.

  1. 01Means and sums of squares. Compute the means, then the sums of squared deviations and cross-products.
    x̄ = 6, ȳ = 71
    Sxx = Σ(x − x̄)² = 40, Syy = Σ(y − ȳ)² = 414, Sxy = Σ(x − x̄)(y − ȳ) = 128
  2. 02Slope and intercept by least squares.
    b = Sxy / Sxx = 128 / 40 = 3.2
    a = ȳ − b · x̄ = 71 − 3.2 × 6 = 51.8
    ŷ = 51.8 + 3.2x
  3. 03Correlation and R². The covariance is Sxy / (n − 1) = 32.
    r = Sxy / √(Sxx · Syy) = 128 / √16,560 = 0.9947
    R² = r² = 0.9894
  4. 04Test the slope. With n − 2 = 3 degrees of freedom:
    t = r√(n − 2) / √(1 − r²) = 16.71, p = 0.0005
  5. 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.

ModelEquationUse it when
Simple linearŷ = b₀ + b₁xThe points follow a straight line; one predictor
Multiple linearŷ = b₀ + b₁x₁ + … + bₖxₖSeveral predictors act on the outcome together
Quadraticŷ = ax² + bx + cThe 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
Logisticln[p / (1 − p)] = β₀ + β₁xThe 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

QuantityFormulaInterpretation
Sample covariancesₓᵧ = Σ(xᵢ − x̄)(yᵢ − ȳ) / (n − 1)Sign gives the direction; size depends on the units
Pearson’s rr = 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 slopeb = r · sᵧ / sₓChange in predicted y for a one-unit increase in x
Intercepta = ȳ − b · x̄Predicted y when x = 0
Coefficient of determinationR² = 1 − SSE / SSTShare 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 ρ = 0t = r√(n − 2) / √(1 − r²), df = n − 2Gives the same p-value as the slope t-test
Exponential modely = a · bˣ, fitted as ln y = ln a + x · ln bb − 1 is the growth rate per unit of x
Logistic modelln[p / (1 − p)] = β₀ + β₁xe^β₁ is the odds ratio for a one-unit increase in x

Frequently asked questions

How do I find the regression equation from data?

Compute the means x̄ and ȳ, then the slope b = Σ(x − x̄)(y − ȳ) / Σ(x − x̄)² and the intercept a = ȳ − b · x̄. The equation is ŷ = a + bx. For the points (2, 58), (4, 65), (6, 70), (8, 79) and (10, 83), this gives ŷ = 51.8 + 3.2x. The Linear Regression Calculator does the same arithmetic and shows each step.

What is the difference between correlation and regression?

Correlation gives one number that describes how strongly two variables are associated, and it treats both variables the same way. Regression fits an equation that predicts an outcome y from one or more predictors x, so the roles of the variables matter. Use correlation to describe a relationship and regression to quantify or predict with it.

What is the difference between Pearson and Spearman correlation?

Pearson’s r measures how closely the points follow a straight line and is sensitive to outliers. Spearman’s ρ is Pearson’s r applied to the ranks, so it measures any consistently increasing or decreasing relationship and is more robust to outliers. Use Spearman for ordinal data or curved but monotonic patterns.

What counts as a strong correlation?

A common rule of thumb treats |r| around 0.1 as weak, 0.3 as moderate and 0.5 or above as strong, but what counts as strong depends on the field. In physics or engineering, r = 0.9 may be disappointing, while in social science r = 0.3 can be meaningful. Always check the scatter plot and the p-value from the Pearson’s Correlation Test Calculator.

Is R² the same as r squared?

In simple linear regression with one predictor, yes: R² equals the square of Pearson’s r. In multiple regression, R² is the square of the correlation between the observed and fitted values, and it never decreases when you add predictors. Adjusted R² corrects for the number of predictors and is better for comparing models.

Does correlation imply causation?

No. A correlation can arise because a third variable drives both, because the causal direction is reversed, or by chance in a small sample. Establishing cause usually needs a controlled experiment or a careful study design that rules out alternative explanations.

When should I use logistic regression instead of linear regression?

Use logistic regression when the outcome is binary, such as pass/fail or purchased/did not purchase. Linear regression can predict probabilities below 0 or above 1 for such outcomes, while logistic regression models the log-odds and keeps every predicted probability between 0 and 1. Its coefficients convert to odds ratios.

Can I use a regression line to predict outside my data?

Only with great caution. The fitted line describes the relationship over the range of x values you observed; beyond that range the true relationship may bend or level off. Predicting inside the range is interpolation and is usually safe; predicting outside it is extrapolation, and the prediction interval widens quickly as x moves away from x̄.

Looking for something else? See all calculators or search the site.