Fitting non-linear effects using different linear models

Association between body mass index (BMI) and systolic blood pressure, using synthetic data

How this simulation works

The scatter plot shows a synthetic sample of 100 observations. The true relationship between BMI and systolic blood pressure was set to a curve (a quadratic trend plus a sine wave), and random noise was added to each observation — so the data are genuinely non-linear, but noisy. Each time you reload the page or click New sample, a fresh random sample is drawn from the same true curve.

Choose a modelling strategy on the right and adjust its complexity. The red line is the fitted curve. The key idea: the first four approaches are still linear models fitted by ordinary least squares — linear in the coefficients — they simply use different transformations of BMI as covariates. The fifth (smoothing spline) takes a different route: maximum flexibility, tamed by a roughness penalty. Tick Show true curve to compare each fit against the truth, and watch how a very flexible model starts chasing the noise (high R², but a wiggly line that would not replicate in a new sample).

Fitted model

R²: N/A
Equation: Not Available

Model selection

(1 = linear)

Use '0' or 'log' for log(x)
(min 3)
The full equation is not displayed due to the number of terms.
Left: rough (interpolates the data)  ·  Right: smooth (straight line)

About this model