In statistics, the R2 value, also known as the coefficient of determination, is crucial for assessing the goodness of fit of a regression model. It quantifies how closely the data points align with the fitted regression line, indicating the percentage of the response variable variation that is explained by the model.
Formula of R2 Value Calculator
The calculation of the R-squared (R²) value is straightforward but requires careful attention to detail. Here’s how it is done:

Where:
- yi is the actual value of the dependent variable,
- ŷi is the predicted value from the regression model,
- ȳ is the mean of the actual values.
Steps to calculate R²:
- Calculate the mean of the actual values (ȳ).
- Compute the total sum of squares (TSS): sum of (yi – ȳ)².
- Compute the residual sum of squares (RSS): sum of (yi – ŷi)².
- Calculate R² using the formula: R² = 1 – (RSS / TSS).
Table of Terms
Term | Definition |
---|---|
TSS | Total Sum of Squares |
RSS | Residual Sum of Squares |
ŷi | Predicted Value |
ȳ | Mean of Actual Values |
This table serves as a quick reference to understand common terms associated with calculating R².
Example of R2 Value Calculator
Consider a dataset where the actual values (yi) of the dependent variable are [3, 4, 5, 6, 7], and the predicted values (ŷi) from the model are [2.8, 3.9, 5.1, 6.2, 6.9]. Following the steps outlined:
- Mean of actual values (ȳ) = 5
- TSS = 10
- RSS = 0.34
- R² = 0.966
This example shows a high R² value, indicating a good fit of the model to the data.
Most Common FAQs
A1: Generally, an R² value closer to 1 indicates a better model fit. However, the context and complexity of the model should also be considered.
A2: Yes, R² can be negative when the chosen model fits worse than a horizontal line