Skip to content
Calcrivo

Linear Regression Calculator

Fit a least-squares line y = mx + b to paired data and report slope, intercept and R².

Inputs

Slope (m)

1.990000

Intercept (b)

0.050000

0.997305

Correlation (r)

0.998652

Step by step

  1. Values used

    X values (comma separated) = 1, 2, 3, 4, 5; Y values (comma separated) = 2.1, 3.9, 6.2, 7.8, 10.1

  2. Slope

    m = Σ(xᵢ−x̄)(yᵢ−ȳ) / Σ(xᵢ−x̄)²

  3. Intercept

    b = ȳ − m×x̄

  4. Slope (m)

    = 1.990000

  5. Intercept (b)

    = 0.050000

  6. = 0.997305

  7. Correlation (r)

    = 0.998652

How it works

Simple linear regression finds the best-fit line y = mx + b that minimises the sum of squared residuals. The slope m is the change in y per unit change in x, and R² indicates what fraction of y's variance is explained by x.

Formulas

Slope

m = Σ(xᵢ−x̄)(yᵢ−ȳ) / Σ(xᵢ−x̄)²

xᵢ,yᵢ
Data pairs
x̄,ȳ
Means

Intercept

b = ȳ − m×x̄

ȳ
Mean of Y
Mean of X
m
Slope

Frequently Asked Questions

What does R² = 1 mean?

It means all data points lie exactly on the line — x perfectly predicts y with no residual error.

Can the slope be negative?

Yes. A negative slope means y decreases as x increases, indicating a negative linear relationship.

You might also need