statcompute

Regression & correlation

R-Squared Calculator

The share of the variation in y that the model explains — and the adjustment for how many predictors it took.

Also called coefficient of determination calculator, R2 calculator, adjusted R squared calculator.

Updated August 2026Runs in your browser — nothing is uploadedVerified against R
One value per line, or separated by commas, tabs or spaces. A header row is ignored.
One value per line, or separated by commas, tabs or spaces. A header row is ignored.

The calculation runs in your browser, so this box needs JavaScript. The formula, the worked example and the interpretation below do not.

01

How to read this result

R² is the proportion of variance explained. Total variation in y is the sum of squared deviations from ȳ; the model accounts for some of it and leaves the rest as residual. R² is the first divided by the total, so it runs from 0 to 1.

It never falls when you add a predictor — even a column of random numbers raises it slightly. That is why adjusted R² exists: it charges a penalty per predictor, can decrease, and is the version to compare models with.

A high R² does not mean the model is right. A curved relationship fitted with a straight line can produce R² above 0.95 while being systematically wrong at both ends. The residual plot is the check that R² cannot provide.

A low R² does not mean the model is useless. In fields where outcomes are genuinely noisy — individual human behaviour, market returns — an R² of 0.1 with a well-estimated slope can be an important finding. R² measures noise as much as it measures the model.

02

The formula

R2=1SSresSStot=1(yiy^i)2(yiy¯)2
SSres
the residual sum of squares — what the model does not explain
SStot
the total sum of squares — variation around the mean of y

Adjusted for the number of predictors

R2adj=1(1R2)n1nk1
k
the number of predictors
n
the sample size

Unlike R², this can fall when a predictor earns less than its cost in degrees of freedom.

03

Worked example

R² for the advertising line

The linear regression example: ten months of spend against sales, fitted with y = 0.30 + 2.015x.

  1. Total variation in y around its mean of 11.38.
    SS_tot = 335.656
  2. Variation left over after the line.
    SS_res = 0.8385
  3. The model accounts for the difference.
    SS_reg = 335.656 − 0.8385 = 334.818
  4. R² is the explained share.
    334.818 / 335.656 = 0.99750
  5. Adjusted for one predictor and ten observations.
    1 − (1 − 0.99750) × 9/8 = 0.99719
0.99750adjusted R² 0.99719r 0.99875residual SS 0.8385

An R² of 0.9975 is the kind of number that only appears with tidy data over a wide range of x. Real observational data rarely gets close, and an R² this high on messy data is usually a sign that x and y are two measurements of the same thing.

Checked against R's summary(lm(y ~ x))$r.squared.

The calculator above is loaded with these numbers by the Load the worked example button.

04

Assumptions, and when to use something else

R² inherits every assumption of the model it summarises. For linear regression that means linearity, independence and constant variance; when those fail, R² is still computable and no longer means what it appears to.

Two specific traps. R² has no meaning for a model fitted without an intercept — some software reports a very high value that is not comparable. And R² computed on the same data the model was fitted to is optimistic; the honest version is out-of-sample, which needs a held-out set.

05

Questions people ask

What is the difference between R² and adjusted R²?

R² rises whenever a predictor is added, even a useless one. Adjusted R² subtracts a penalty for each predictor and can fall, which makes it the right one for comparing models with different numbers of terms.

Is R² the same as r squared?

For simple linear regression with one predictor, yes exactly. In multiple regression R² is the squared correlation between the observed and fitted values, which generalises the same idea.

Can R² be negative?

Not for an ordinary least-squares fit with an intercept — it is bounded at 0. It can go negative when a model is evaluated on data it was not fitted to, and means the model predicts worse than simply using the mean.

What R² do I need for a good model?

There is no threshold. Compare against what is typical in your field, look at whether the coefficients are sensible, and check the residual plot. A model with R² = 0.2 and a well-estimated, theoretically expected slope beats one with R² = 0.9 and a curve in its residuals.