About the R-Squared Calculator
This R-squared calculator finds the coefficient of determination (R²) — the share of the variation in an outcome that a model explains — together with adjusted R², the correlation coefficient and the sums of squares behind them. It works three ways: paste paired x and y data to fit a straight line and score it; paste observed and predicted values from any model (a spreadsheet forecast, a machine-learning model, a multiple regression); or simply enter R², the sample size and the number of predictors to get adjusted R².
Students use it to check regression homework, analysts to compare how well competing models fit, and researchers to report adjusted R² when a model has several predictors. The observed-vs-predicted mode uses the general definition R² = 1 − SS_res ÷ SS_tot, so it can be negative when a model predicts worse than simply using the mean.
Adjusted R² penalizes extra predictors: adding a useless variable always nudges R² up, but adjusted R² only rises if the new variable improves the fit more than chance would. Use it when comparing models with different numbers of predictors.
With the default inputs, the r² (coefficient of determination) is 0.998839. Change any value above to recalculate instantly.
How to use the r-squared calculator
- 1Choose whether you have x–y data, observed and predicted values, or a reported R².
- 2Paste the values in matching order, one list per box.
- 3For predictions from a multiple regression, enter the number of predictors k.
- 4Read R² and adjusted R²; the chart compares actual and fitted values.
Formula and method
SS_tot = Σ(yᵢ − ȳ)² measures the total variation of the observed values around their mean, and SS_res = Σ(yᵢ − ŷᵢ)² measures what is left unexplained by the model’s predictions ŷᵢ. R² is the fraction of variation explained. For a simple least-squares line with an intercept, R² equals the square of Pearson’s correlation r, and always lies between 0 and 1.
Adjusted R² rescales the unexplained share by the degrees of freedom: (n − 1) for the total and (n − k − 1) for the residuals, where k is the number of predictors. It can fall when a weak predictor is added, which makes it more honest for comparing models of different sizes. In x–y mode the calculator fits y = a + bx by ordinary least squares, so k = 1.
- yᵢ
- Observed value
- ŷᵢ
- Predicted (fitted) value
- ȳ
- Mean of the observed values
- n
- Number of observations
- k
- Number of predictors (excluding the intercept)
Worked examples
Linear fit to eight data points
Least squares gives y ≈ 0.0357 + 1.9976x. The residual sum of squares is just 0.195 against a total of 167.8, so R² = 1 − 0.195 ÷ 167.8 = 0.9988 — the line explains 99.88% of the variation. With n = 8 and one predictor, adjusted R² is 0.9986.
Scoring a model’s predictions
The observed values 3, 5, 7, 9, 11 vary by 40 around their mean of 7. The predictions miss by 0.2, 0.3, 0.1, 0.4 and 0.4, a residual sum of squares of 0.46, so R² = 1 − 0.46 ÷ 40 = 0.9885 and adjusted R² (n = 5, k = 1) is 0.9847.
Adjusted R² for a four-predictor regression
A regression with 4 predictors on 50 observations reports R² = 0.85. Adjusted R² = 1 − 0.15 × 49 ÷ 45 = 0.8367, a modest penalty because the sample is large relative to the number of predictors.
Frequently asked questions
What does R-squared tell you?+
R² is the proportion of the variance in the dependent variable that the model explains. An R² of 0.75 means 75% of the variation in y is accounted for by the predictors and 25% is left in the residuals. It does not say whether the model is causal or correctly specified.
What is a good R-squared value?+
It depends on the field. Physical and engineering relationships often give R² above 0.9, while models of human behaviour, finance or medicine are frequently useful with R² of 0.1 to 0.4. Judge the model by residual plots, prediction error and whether coefficients make sense, not R² alone.
What is the difference between R-squared and adjusted R-squared?+
R² never decreases when you add a predictor, even a random one. Adjusted R² divides each sum of squares by its degrees of freedom, so it only increases when a new predictor improves the fit more than expected by chance. Use adjusted R² to compare models with different numbers of predictors.
Is R-squared the same as the correlation coefficient squared?+
For a simple linear regression with one predictor and an intercept, yes: R² = r². For multiple regression, R² equals the square of the correlation between the observed and fitted values, and it is not tied to any single predictor’s correlation.
Can R-squared be negative?+
Using R² = 1 − SS_res ÷ SS_tot, R² is negative when predictions are worse than just predicting the mean — for example, a model evaluated on new data, or a regression forced through the origin. Ordinary least squares with an intercept, evaluated on its own data, always gives R² between 0 and 1.