Regression
Fit the least-squares line or curve through your data: a straight line, a parabola, a cubic or a polynomial of degree 4 to 6. Returns every coefficient, R² and adjusted R², turning points, every residual and a prediction for any x — and compares all degrees side by side, so you can see which model fits your data best.
What is Regression?
Regression finds the line or curve that best describes how y changes with x. “Best” means least squares: the curve that makes the sum of the squared vertical distances (the residuals) as small as possible. For a straight line, the slope β1 is the expected change in y per unit of x, the intercept β0 the predicted y at x = 0, and the correlation r how closely the points follow the line.
A polynomial of degree d can bend up to d−1 times, so curved data needs a higher degree. R² is the share of the variation in y the model explains, but it can only go up as the degree grows. Adjusted R² subtracts a penalty for every extra coefficient, so it peaks at the degree that captures the shape without chasing the noise. With enough terms a curve passes through every point, noise included: that is overfitting.
Live Graph
n = 8Regression Formulas
| Quantity | Formula |
|---|
Using the Results
Start with a straight line and look at the residuals: a curved pattern means the line is the wrong model. The comparison table lists every degree; pick the lowest one after which adjusted R² stops improving.
Predictions inside the range of your data are usually trustworthy. Far outside it, the model may break down; high-degree polynomials in particular swing near the ends and explode beyond them.
A strong r says x and y move together. A hidden third variable can drive both.
Sources & Verification
- N. R. Draper & H. Smith, Applied Regression Analysis, 3rd ed., Wiley, 1998 — Ch. 1 (Fitting a Straight Line by Least Squares) and the chapter “Models Containing Functions of the Predictors, Including Polynomial Models”.