Understanding science, for all. Home About
Novadette› ∑ Mathematics› Statistics› Regression
∑ Statistics

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.

StatisticsRegressionCorrelationCurve fitting
Inputs

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.

r ≈ ±1strong linear trend
R² = 0.8model explains 80%
n ≥ d + 1points needed
adj. R²guides the choice

Live Graph

n = 8
data
fitted line or curve
residuals
prediction
Result
Enter your data above

Regression Formulas

QuantityFormula

Using the Results

Choosing the Model

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.

Example: “Two bumps”: adjusted R² stays below 0 up to degree 3 and jumps to 0.84 at degree 4.
Interpolation vs Extrapolation

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.

Example: a child’s height grows ~6 cm/year — but not at age 40.
Correlation ≠ Causation

A strong r says x and y move together. A hidden third variable can drive both.

Example: ice-cream sales and sunburns correlate — both are caused by sunshine.

Sources & Verification

References
  1. 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”.