Home

Linear Regression

Fit a line by least squares and get slope, intercept and R².

展开更多 ▾
ŷ = a + b·x, b=Σ(x−x̄)(y−ȳ)/Σ(x−x̄)²
least-squares line fit

📖 Tutorial | Linear Regression

1. Definition
Simple linear regression fits ŷ=a+bx by least squares minimizing residual sum of squares. Slope b=Σ(x−x̄)(y−ȳ)/Σ(x−x̄)²; intercept a=ȳ−b·x̄.
2. Symbols
SymbolMeaning
bslope (regression coefficient)
aintercept
rcorrelation coefficient
R²coefficient of determination, 0~1
3. How it works
  • Compute slope b by least squares;
  • Intercept a=ȳ−b·x̄;
  • r measures linear strength;
  • R²=r² is the fraction of variance explained.
4. Steps
  1. Enter one point x,y per line;
  2. Click Calculate;
  3. Read slope, intercept, r, R²;
  4. Write the equation ŷ=a+bx.
5. Example
Example: (1,2)(2,3)(3,5)(4,6)(5,7). b=1.3, a=0.7, r≈0.991, R²≈0.983, ŷ=0.7+1.3x.
6. Pitfalls
Regression only describes a linear relation;
Extrapolate cautiously;
At least two points define a line; more points are more stable.

❓ FAQ | Linear Regression

Relation between slope and correlation?
Same sign; b=r·(sy/sx); stronger correlation gives a more reliable slope.
What does R²=0.98 mean?
About 98% of y variance is explained by the line—a very good fit.
Does regression prove causation?
No; it only models a linear relation.
Is the intercept meaningful?
Only if x=0 lies within the data range.
Can I extrapolate?
As a short-term reference, but far outside the data it is risky.