Linear Regression Calculator

Linear Regression is evaluated from X Values, Y Values and Predict Y at x =. The calculation reports Slope, Y-Intercept and R^2.

Results

Thanks — we’ve logged this for review.

About the Linear Regression Calculator

Linear Regression is treated here as a quantitative relation between X Values, Y Values and Predict Y at x = and Slope, Y-Intercept, R^2 and Predicted Y at given x.

The calculator uses a multi formula configuration. Each reported value is read as a direct evaluation of the stored rules with the declared field formats and units.

Formula basis:
m = (n x Sigmaxy - Sigmax x Sigmay) / (n x Sigmax^2 - (Sigmax)^2)
b = ȳ - m x x̄
ŷ = mx + b

Interpret the outputs in the order shown by the result fields. Optional inputs affect only the outputs that depend on those variables.

Formula & How It Works

The calculation applies the following relations exactly as recorded in the metadata:

m = (n x Sigmaxy - Sigmax x Sigmay) / (n x Sigmax^2 - (Sigmax)^2)
b = ȳ - m x x̄
ŷ = mx + b

Each output field is produced by substituting the supplied inputs into the relevant relation and then applying the declared rounding or text format.

Worked Examples

Example 1: Hours Studied vs. Exam Score

Inputs

x_data: 1, 2, 3, 4, 5, 6, 7, 8 y_data: 50, 55, 60, 65, 70, 75, 80, 85 x_predict: 9
Slope: 5. Y-Intercept: 45. R^2: 1. Predicted Y at given x: 90. Pearson r: 1

With X Values = 1, 2, 3, 4, 5, 6, 7, 8, Y Values = 50, 55, 60, 65, 70, 75, 80, 85 and Predict Y at x = = 9 as the stated inputs, the result is Slope = 5, Y-Intercept = 45 and R^2 = 1. Each value corresponds to the declared output fields.

Example 2: House Size vs. Price

Inputs

x_data: 1000, 1200, 1400, 1600, 1800, 2000, 2200 y_data: 180000, 210000, 235000, 260000, 290000, 315000, 345000 x_predict: 2500
Slope: 135.714286. Y-Intercept: 45,000. R^2: 0.999308. Predicted Y at given x: 384,285.7143. Pearson r: 0.999654

With X Values = 1000, 1200, 1400, 1600, 1800, 2000, 2200, Y Values = 180000, 210000, 235000, 260000, 290000, 315000, 345000 and Predict Y at x = = 2,500 as the stated inputs, the result is Slope = 135.714286, Y-Intercept = 45,000 and R^2 = 0.999308. Each value corresponds to the declared output fields.

Example 3: Ad Spend vs. Revenue

Inputs

x_data: 500, 1000, 1500, 2000, 2500, 3000 y_data: 5000, 9500, 13000, 17500, 21000, 26000 x_predict: 3500
Slope: 8.228571. Y-Intercept: 933.333333. R^2: 0.997963. Predicted Y at given x: 29,733.3333. Pearson r: 0.998981

With X Values = 500, 1000, 1500, 2000, 2500, 3000, Y Values = 5000, 9500, 13000, 17500, 21000, 26000 and Predict Y at x = = 3,500 as the stated inputs, the result is Slope = 8.228571, Y-Intercept = 933.333333 and R^2 = 0.997963. Each value corresponds to the declared output fields.

Example 4: Temperature vs. Ice Cream Sales

Inputs

x_data: 65, 70, 75, 80, 85, 90, 95 y_data: 120, 145, 170, 200, 235, 270, 310 x_predict: 100
Slope: 6.321429. Y-Intercept: -298.571429. R^2: 0.992178. Predicted Y at given x: 333.5714. Pearson r: 0.996081

With X Values = 65, 70, 75, 80, 85, 90, 95, Y Values = 120, 145, 170, 200, 235, 270, 310 and Predict Y at x = = 100 as the stated inputs, the result is Slope = 6.321429, Y-Intercept = -298.571429 and R^2 = 0.992178. Each value corresponds to the declared output fields.

Common Use Cases

  • Find best-fit line through scatter plot data
  • Predict sales based on advertising spend
  • Model weight as function of height
  • Forecast demand from historical data