Polynomial regression

Polynomial regression for curved relationships

When a relationship curves but you do not have a mechanistic equation for it, a polynomial is a pragmatic fit. Magic Stat estimates polynomials up to degree 6, with the coefficient table, the R², the F test and prediction intervals that let you judge whether the curve is justified.

The honest part

A polynomial fits curvature. It does not explain it.

Polynomial regression adds powers of the predictor — x, x², x³ and so on — and fits them by least squares. It is still a linear model: linear in the coefficients, which is why the usual coefficient table, confidence intervals and F test apply. What it buys is curvature: a single-peaked response, a U-shape, a saturating trend.

The trap is degree. A higher degree will always fit the sample a little better, and past a point it is fitting noise. Magic Stat lets you go from degree 2 to degree 6, but the honest advice, printed in no uncertain terms, is to start low and only add a term when the data justify it.

Polynomials also extrapolate badly. Outside the range of the observed predictor, powers can swing to values that have no basis in the data. If your relationship has a mechanism, nonlinear regression usually gives a more defensible model than a high-degree polynomial.

What it does

What Magic Stat gives you for polynomial regression

How it works

Choose the degree, watch the fit

  1. Load the data. the predictor and the outcome as columns.
  2. Choose Polynomial Regression. Statistics → Polynomial Regression.
  3. Select X and Y. one X gives a simple polynomial; several give one model with a polynomial block per predictor.
  4. Set the degree. start at 2 and increase only when the data call for it.
  5. Export. the fitted curve and the coefficient table go into the figure and the report.
Options

The settings, in the dialog

Polynomial degree: 2 to 6, set with a spin box.

Several predictors: each predictor contributes its own polynomial block (y ~ x1 + x1² + x2 + x2² + …) in a single model — not one curve per predictor.

Frequently asked

Polynomial regression questions, answered honestly

How do I choose the degree?

Start at 2. Add a higher power only when it captures a feature the lower-degree fit visibly misses and the extra term is worth its loss of degrees of freedom. Chasing the highest R² is a reliable way to overfit.

Is polynomial regression a nonlinear model?

No. The curve is nonlinear in the predictor, but the model is linear in the coefficients, which is why ordinary least-squares inference — the t tests, the F test, the intervals — applies directly.

Can I extrapolate beyond my data?

You should not. High powers diverge outside the observed range of the predictor, so a prediction there is an artefact of the equation, not a finding. Keep interpretation inside the data range.

Polynomial or nonlinear regression?

If a mechanistic equation describes the process — Michaelis–Menten, exponential, logistic — nonlinear regression gives a model whose parameters mean something. Use a polynomial when you want a flexible curve and have no mechanism to propose.

Is my data uploaded somewhere?

No. The analysis runs locally. The only automatic signal is an anonymous installation counter with no data in it.

Linear regression → Nonlinear regression → GAM analysis →