Coefficient of determination (source code)

= Coefficient of determination
{title2=$R^2$}
{wiki}

= R squared
{c}
{synonym}

In an <ordinary least squares> regression with an intercept and a nonconstant response, $R^2=1-\mathrm{RSS}/\sum_i(Y_i-\overline Y)^2$. It measures the fitted proportion of sample variation relative to an intercept-only baseline. It increases when regressors are added, even if those regressors are unhelpful for prediction. A high value does not establish the assumptions of a <normal linear model> or rule out a systematic <regression residual> pattern.

For the five-point example in <linear regression>, the total centered <sum of squares> is $10.8$ and the <residual sum of squares> is $0.8$, so $R^2=25/27\approx0.926$. This summarizes the fitted reduction in squared error. It does not record the order or shape of the <regression residuals>, which are worth examining in a <residual-versus-fitted plot>.

Here is a fully constructed illustration. Use $x=(-2,-1,0,1,2)$ and the same fitted line $3+x$ for both datasets. Add respectively the residual vectors
$$
r_{\rm curve}=0.2(2,-1,-2,-1,2),\qquad
r_{\rm alt}=0.2\sqrt{\frac75}(1,-2,0,2,-1).
$$
Both sum to zero, both have zero <inner product> with $x$, and both have squared <norm> $0.56$. Their <ordinary least squares> fit is therefore exactly the same line, with the same $R^2=10/(10+0.56)=125/132\approx0.947$. But the first residual is $0.2(x^2-2)$, a systematic quadratic shape, while the second changes direction across the predictor values. These examples show directly which information the scalar $R^2$ discards; neither constructed pattern proves a random-error model.

\Image[/regression-residual-patterns.png]
{title=Two constructed datasets share a fitted line and R squared but have different residual shapes}