🎓 Statistics & Data • Correlation & Regression
100% Client-Side Privacy
Linear Regression Calculator (ŷ = mx + b)
Calculates the ordinary least squares (OLS) linear regression line ŷ = mx + b with interactive value prediction.
Bivariate Linear Modeling Suite
Linear Regression, Correlation & Residuals
Fit ordinary least-squares regression lines, calculate Pearson and Spearman coefficients, examine residuals, and make predictions.
Independent Variable X (Explanatory)7 values
Dependent Variable Y (Response)7 values
Presets:
Ordinary Least Squares Regression Equation
ŷ = 2.225x - 0.4571
Correlation:Very Strong Positive(r = 0.9968)
Pearson r0.9968
R² Explained99.37%
Slope (m)2.225
Sample Covariance10.3833
Fitted Scatter Plot & Residual Errors
Observed Data Point (x_i, y_i) Regression Line ŷ = mx + b Residual (y - ŷ) Predicted Point (x_p, ŷ_p)
Interactive Linear PredictorEvaluate ŷ = 2.225 · (x) - 0.4571
⟹ŷ = 17.3429
Model Diagnostics & Sum of Squares Table
Spearman Rank (r_s)1
Residual Std Error (s_e)0.4194
Slope t-Statistic28.07 (df = 5)
Sum of Squared Errors (SSE)0.8796
Regression SS (SSR)138.6175
Total SS (SST)139.4971
Step-by-Step Mathematical Derivations
1. Dataset Summary Totals:
- N = 7, Mean X (x̄) = 4, Mean Y (ȳ) = 8.4429
- ΣX = 28, ΣY = 59.1, ΣX² = 140, ΣY² = 638.47, ΣXY = 298.7
2. Sum of Squares:
- SS_xx = ΣX² - (ΣX)² / N = 140 - (28)² / 7 = 28
- SS_yy = ΣY² - (ΣY)² / N = 638.47 - (59.1)² / 7 = 139.4971
- SS_xy = ΣXY - (ΣX · ΣY) / N = 298.7 - (28 · 59.1) / 7 = 62.3
3. Slope & Intercept Calculation:
- Slope m = SS_xy / SS_xx = 62.3 / 28 = 2.225
- Intercept b = ȳ - m · x̄ = 8.4429 - (2.225 · 4) = -0.4571
4. Pearson Correlation & R²:
- r = SS_xy / √(SS_xx · SS_yy) = 62.3 / √(28 · 139.4971) = 0.9968
- R² = r² = (0.9968)² = 0.9937 (99.37% of variance explained)
What is Simple Linear Regression?
Simple linear regression fits a straight line minimizing the sum of squared vertical differences (residuals) between data points and the line.
Formula & Step-by-Step Calculation
m = [ nΣxy - ΣxΣy ] / [ nΣx² - (Σx)² ], b = ȳ - mx̄
Ordinary Least Squares (OLS) closed-form solution.
Worked Step-by-Step Examples
Example 1
Fit line for X: (1, 2, 3) and Y: (3, 5, 7). Predict for x = 5.
Solution: ŷ = 2x + 1; At x = 5, ŷ = 11.00
• Slope m = 2.0; Intercept b = 1.0; ŷ = 2(5) + 1 = 11.00
Common Real-World & Academic Use Cases
- ✓ Predicting house prices from square footage
- ✓ Medical dosage response calibration
- ✓ Predictive machine learning baseline
How to Use the Linear Regression Calculator (ŷ = mx + b)
1
Enter Data Pairs
Input X and Y lists.
2
Predict Values
Enter any X value to get predicted ŷ.
Frequently Asked Questions
Q: Can linear regression handle non-linear data?
Simple linear regression assumes a straight line; non-linear trends require polynomial or logarithmic transformations.