Why Summarize Fit With a Proportion?
A regression model produces fitted values for the observed outcomes. The residual sum of squares describes the squared differences between those outcomes and their fitted values, while the total sum of squares describes how much the outcomes vary around their sample mean. A useful fit summary compares these two amounts: what proportion of the sample’s total outcome variation is accounted for by the fitted values?
R-squared, written \(R^2\), answers this descriptive question for a least-squares regression model that includes an intercept. It is built from the sums-of-squares decomposition: total variation around the sample mean is divided between variation in the fitted values and residual variation. R-squared reports the fitted-values share as a proportion, often expressed as a percentage.
Definition and Conditions
Suppose the data consist of \(n\) observations on a quantitative outcome. Let \(y_i\) be the observed outcome for observation \(i\), \(\hat{y}_i\) its fitted value, and \(\bar{y}\) the sample mean of the observed outcomes. The residual for observation \(i\) is \(e_i=y_i-\hat{y}_i\). The sums of squares are:
Here, \(SST\) is the total sum of squares, \(SSR\) is the regression sum of squares, and \(SSE\) is the residual sum of squares. Each is measured in the square of the outcome’s units. For an intercept model fitted by least squares, the sums-of-squares decomposition is \(SST=SSR+SSE\).
The conditions matter. There must be a nonconstant outcome in the sample, so \(SST>0\), and the fitted values must come from least squares with an intercept for this standard decomposition and interpretation to apply. The calculation is descriptive: it does not require normally distributed errors or other probability-model assumptions. Those assumptions may matter for inference about a regression model, but they are not needed to calculate this fit summary.
Why the Formula Works
For each observation, the difference from the sample mean can be written as the difference between its fitted value and the sample mean, plus its residual: \(y_i-\bar{y}=(\hat{y}_i-\bar{y})+e_i\). Squaring and summing gives a cross-product term. In least squares with an intercept, that term is zero.
To see why, write the fitted values as \(\hat{\mathbf{y}}=X\hat{\boldsymbol{\beta}}\), where \(X\) is the model’s design matrix and \(\hat{\boldsymbol{\beta}}\) is its least-squares coefficient vector. The least-squares normal equations give \(X^\mathsf{T}\mathbf{e}=0\). Consequently, \(\hat{\mathbf{y}}^\mathsf{T}\mathbf{e}=\hat{\boldsymbol{\beta}}^\mathsf{T}X^\mathsf{T}\mathbf{e}=0\). Because the model includes an intercept, the same normal equations give \(\sum_i e_i=0\). Therefore:
Now expand the squared differences from the mean. The cross-product vanishes by the result above, leaving the decomposition:
Dividing this identity by \(SST\), which is positive, gives \(1=SSR/SST+SSE/SST\). Rearranging yields both forms of the R-squared formula. In this setting, both sums of squares in the ratio are nonnegative, so \(0\leq R^2\leq1\). R-squared is dimensionless: changing the outcome from one unit to another multiplies both \(SSR\) and \(SST\) by the same squared conversion factor, leaving their ratio unchanged.
Worked Example: Calculating R-Squared From Sums of Squares
In a hypothetical regression of quiz scores on hours of study, a model with an intercept is fitted to 10 students. Suppose \(SST=60\) score-points squared and \(SSE=18\) score-points squared. Calculate R-squared and interpret it.
First use the decomposition to find the regression sum of squares:
Then divide by the total sum of squares:
Equivalently, \(R^2=1-18/60=0.700\). In this sample, 70.0% of the variation in quiz scores around the sample mean is accounted for by the fitted values from the regression model. The remaining 30.0% is residual variation, since \(18/60=0.300\). This description does not mean study hours caused 70.0% of the differences in scores.
Worked Example: Calculating R-Squared From Observed and Fitted Values
In a hypothetical sample of four days, a least-squares model with an intercept predicts the number of service requests received from a predictor. The observed request counts are \(2,4,5,9\); the fitted values are \(1.7,3.9,6.1,8.3\). Find R-squared from the observations and fitted values. The outcome is not constant, and the fitted values come from an intercept model, so the decomposition applies.
The mean observed count is \(\bar{y}=(2+4+5+9)/4=5\). The total sum of squares is:
The residuals are \(0.3,0.1,-1.1,0.7\) requests. Therefore:
The decomposition gives \(SSR=26-1.80=24.2\) requests squared. Thus:
In this four-day sample, approximately 93.1% of the variation in observed request counts around their mean is accounted for by the fitted values. This high proportion summarizes the fit to these observations; by itself, it does not show how well the model will predict on other days.
Worked Example: The Same R-Squared Can Accompany Different Residual Sizes
Consider two hypothetical intercept-model fits, each based on five observations of an outcome measured in minutes. Fit A has \(SST=50\) minutes squared and \(SSE=10\) minutes squared. Fit B has \(SST=500\) minutes squared and \(SSE=100\) minutes squared. Calculate and compare the R-squared values.
For Fit A:
For Fit B:
Both fits account for 80.0% of their samples’ outcome variation, and each leaves 20.0% as residual variation. However, Fit A’s average squared residual is \(SSE/n=10/5=2\) minutes squared, while Fit B’s is \(100/5=20\) minutes squared. Their R-squared values match because the total variation and residual variation are both ten times as large for Fit B. The statistic gives a relative summary, not the residual size in the outcome’s original units.
Interpreting R-Squared Carefully
The interpretation should identify both the sample and the outcome. A useful sentence is: “In this sample, \(R^2\) times 100% of the variation in [outcome] around its sample mean is accounted for by the fitted values from [model].” For example, an R-squared of \(0.70\) means 70% by this definition, not that 70% of individual outcomes are predicted correctly.
The phrase “accounted for” describes the sums-of-squares partition. It does not establish that predictors caused the outcomes, nor does it promise that the fitted model will work well for new observations. R-squared also depends on how much the outcome varies in the sample, so the same value can accompany different residual sizes, as the previous example showed.
R-squared is a summary, not a complete assessment of a regression. It does not, on its own, reveal whether the model’s assumptions are reasonable, whether individual predictions are close, whether important patterns remain in the residuals, or whether the predictors have a causal interpretation. Those questions require other information and checks. A high value is not proof of a suitable model, and a modest value does not by itself settle whether the model is useful for its purpose.
Common Mistakes
- Reversing the sums of squares. Using \(SSE/SST\) as R-squared reports the residual fraction, not the accounted-for fraction. For an intercept model, use \(R^2=1-SSE/SST\), or \(SSR/SST\).
- Calling R-squared the percentage of observations predicted correctly. It is a proportion of sums of squared deviations, not a count or percentage of correct predictions.
- Giving a causal interpretation. A large R-squared does not show that a predictor caused the observed outcome differences. Say “accounted for by the fitted values,” not “caused by the predictors.”
- Assuming a high R-squared guarantees good predictions. It summarizes relative fit to the sample outcomes. Check the residuals and consider the model’s purpose and the prediction setting as well.
- Using the usual interpretation when its conditions do not hold. The definition here relies on an intercept and least-squares fitting, with \(SST>0\). Do not assume the same decomposition or range without those conditions.
Check Your Understanding
Answer each question using the intercept-model definition of R-squared.
- A model has \(SST=80\) and \(SSE=24\). Calculate \(SSR\) and \(R^2\), and state the interpretation in context if the outcome is measured in kilograms.
- In a sample, \(SSR=36\) and \(SST=45\). What proportion of the sample’s outcome variation remains in the residuals?
- Why must \(SST>0\) for the usual R-squared formula to be defined?
- Two models have the same R-squared but different \(SSE\) values. Does that mean their residuals have the same size in the outcome’s units? Explain.
- A report says, “R-squared is 0.65, so the predictors caused 65% of the outcome differences.” What is wrong with this interpretation?