R-Squared Calculator

R² is the share of the variation in y that a model explains: 1 − SSres ÷ SStot. Fit a line to x and y, or paste a model’s predictions next to the actual values.

Also called: Coefficient of determination calculator · R² calculator

  • Last updated
  • Formula tested against reference values

Your numbers

Data

Result

R²
—

Calculating…

Adjusted R²
—
Residual sum of squares (SSres)
—
Total sum of squares (SStot)
—
F statistic
—
p-value of the F test
—
Fitted line
—
Observations (n)
—

How to use this calculator

  1. Enter or choose data.
  2. The r² updates as you type. Use Copy result or Share to keep it.

Method

R² = 1 − SSres ÷ SStot; adjusted R² = 1 − (1 − R²)(n − 1) ÷ (n − k − 1); F = (SStot − SSres) ÷ (SSres ÷ (n − 2)) on 1 and n − 2 df

SSres
Σ(actual − fitted)²
SStot
Σ(actual − mean)²
n
observations
k
number of predictors (1 for a straight line)

Worked example

  1. The least-squares line is ŷ = 2.2 + 0.6x, leaving SSres = 2.4; SStot = Σ(y − 4)² = 6.
  2. R² = 1 − 2.4 ÷ 6 = 0.6.
  3. Adjusted R² = 1 − 0.4 × 4 ÷ 3 = 0.4667; F = 3.6 ÷ 0.8 = 4.5 on 1 and 3 df (p = 0.124).

The straight line explains 60% of the variation in y (adjusted R² 0.47), but the F test is not significant with only five points.

What the result means

R² says how much of the spread the model accounts for, not whether the model is right: a curved relation can have a high R² for a straight line and still be badly specified. Adjusted R² penalises extra predictors. With predictions from another model, a negative R² means the model is worse than predicting the mean every time.

Assumptions and limits

  • Fit mode uses ordinary least squares with an intercept; the F test assumes independent, normal, constant-variance residuals.
  • Predictions mode uses R² = 1 − SSres ÷ SStot for any model, so it can be negative.
  • The F test is not computed for supplied predictions, because their degrees of freedom depend on how the model was fitted.
  • R² on the data used to fit a model overstates how well it predicts new data.

Questions

Is R² the same as r squared?

For a straight line fitted by least squares with an intercept, yes: R² equals the square of Pearson’s r. For other models it is not.

What is a good R²?

It depends on the field. Physical measurements often exceed 0.95, while models of human behaviour may be useful at 0.2.