R-Squared Calculator

How Much of the Variance Does the Model Actually Explain?

R² compares a model's predictions against the simplest possible baseline — always predicting the mean — and reports what fraction of the actual variance the model accounts for. An R² of 1 means the predictions match the data perfectly; an R² of 0 means the model does no better than just guessing the average every time; negative values mean the model does worse than that baseline.

The Formula

R² = 1 − (SS_res / SS_tot)

SS_res is the sum of squared differences between actual and predicted values (residual error); SS_tot is the sum of squared differences between actual values and their mean (total variance). R² expresses residual error as a fraction of total variance and subtracts it from 1.

Where This Matters

  • Regression model evaluation — the standard headline metric for how well a linear or nonlinear regression fits observed data.
  • Feature selection — comparing R² before and after adding a variable to judge whether it meaningfully improves fit.
  • Forecast quality checks — a low or negative R² is a signal that a forecasting model isn't capturing the underlying pattern.

Worked Example

R² for actual = [3, 5, 7, 9], predicted = [2.8, 5.1, 6.9, 9.2]
QuantityValue
SS_res (Σ(actual−predicted)²)0.10
SS_tot (Σ(actual−mean)²)20.00
0.995

R² = 1 − (0.10 / 20.00) = 0.995, meaning 99.5% of the variance in the actual values is explained by the predictions.

How to Use This Calculator

  1. Enter the Actual values as a comma-separated list.
  2. Enter the Predicted values as a comma-separated list of the same length.
  3. Select Calculate to get R² and the underlying sum-of-squares breakdown.

Related Calculations

See the raw error magnitude behind the same predictions with the Mean Squared Error Calculator, or check classification performance instead with the Confusion Matrix Calculator.