Premium experiment • regression lab

STATISTICS • REGRESSION

Linear Regression

Separate the generating trend from the fitted line, inspect every residual, quantify fit error and tune deterministic noise to a target R².

● LIVE LEAST-SQUARES FITfitted line
Fitted slope—
Fitted intercept—
R²—
Correlation r—
RMSE—
Target error—

Residual diagnostics

observed − fitted by x

Fit quality is more than a line

Residual segments and the residual plot expose the errors hidden by the fitted line. Because the data generator is deterministic, changing noise isolates the effect of scatter without random rerolls.

Fast investigations

  1. Set noise to zero and verify the fitted and generating lines coincide.
  2. Increase noise and track R², RMSE and residual spread.
  3. Switch to a negative slope without changing noise.
  4. Use the R² challenge to find the noise level for a desired fit quality.

LEARN WITH THE SIMULATION

Understand Linear Regression by experimenting.

START HERE

Least-squares linear regression chooses the line that minimizes the sum of squared vertical residuals. Correlation describes linear association, while R² summarizes the fraction of variance explained by the fitted line in this simple setting.

BUILD THE IDEA

What you should understand first

  • Relate data trend to fitted slope.
  • See how noise affects correlation and R².
  • Distinguish association from exact prediction.

TRY IT YOURSELF

How does increasing random noise affect R² when the underlying trend stays the same?

  1. Choose a clear positive slope with low noise.
  2. Record the fitted line and R².
  3. Increase noise while keeping slope and intercept unchanged.
Read the visual:

More noise generally lowers the magnitude of correlation and R² because points are less tightly concentrated around the fitted line.

WHY IT WORKS 01

Relate data trend to fitted slope.

Least-squares linear regression chooses the line that minimizes the sum of squared vertical residuals. Correlation describes linear association, while R² summarizes the fraction of variance explained by the fitted line in this simple setting. Focus on the relationship between the controlled variable and the measured response rather than treating the visual change as the explanation.

WHY IT WORKS 02

See how noise affects correlation and R².

More noise generally lowers the magnitude of correlation and R² because points are less tightly concentrated around the fitted line. Use an extreme or boundary setting after the baseline trial to check whether the same reasoning still holds.

DO NOT MIX THESE UP

Common misconception

Correlation does not imply causation. R² near 1 does not guarantee the model is scientifically appropriate. Regression slope depends on the units used for x and y.

PRACTICE CHALLENGE

How does increasing random noise affect R² when the underlying trend stays the same?

  • Choose a clear positive slope with low noise.
  • Record the fitted line and R².
  • Increase noise while keeping slope and intercept unchanged.
Reveal the reasoning

More noise generally lowers the magnitude of correlation and R² because points are less tightly concentrated around the fitted line. Correlation does not imply causation. R² near 1 does not guarantee the model is scientifically appropriate. Regression slope depends on the units used for x and y.

MODEL BOUNDARIES

What this simulation assumes

Every simulation simplifies reality or a mathematical system. These are the assumptions and limits to keep in mind while interpreting the results.

Model assumptions

  • The fitted relationship is linear in the variables displayed.
  • Ordinary least-squares style error is represented by vertical residuals.
  • The sample shown is treated as the complete dataset for the fit.

Model limitations

  • Correlation does not establish causation.
  • Outliers, nonlinear structure, heteroscedasticity and dependent errors can make a simple linear fit misleading.

CONNECT IT

Where this matters

  • Calibration
  • Trend estimation
  • Data science and forecasting

WORDS THAT MATTER

Key vocabulary

Residual
Observed value minus fitted value.
Least squares
Criterion minimizing summed squared residuals.
R²
Proportion of variance explained by a fitted model.