Why Correlation and R-Squared Are Connected
Correlation and R-squared both summarize how a pair of quantitative variables relate to a straight-line pattern, but they answer different questions. The sample correlation \(r\) records both the direction and strength of the linear association. R-squared describes how much of the observed variation in the response is accounted for by its fitted values in a particular regression.
For an ordinary least-squares regression of one quantitative response on one quantitative predictor, with an intercept, these summaries are linked by a precise identity: \(R^2=r^2\). The square removes the sign, so R-squared alone cannot tell whether the fitted line slopes upward or downward. The identity also has specific conditions; it is not a universal rule for every regression model.
The identity \(R^2=r^2\) applies when the fitted model is the ordinary least-squares line predicting one response from one predictor and includes an intercept, and when both variables have nonzero variation. Those conditions make the slope and correlation defined and give the response a positive total sum of squares. No normality assumption is needed for this algebraic identity. It is a relationship between the observed data summaries, not a probability statement.
The regression slope and correlation are related too: the least-squares slope is \(b_1=S_{xy}/S_{xx}\). Because \(S_{xx}\) is positive, the slope has the same sign as \(S_{xy}\), and therefore the same sign as \(r\). But \(R^2\) is nonnegative, so its value does not retain that sign.
Deriving the Identity
The key is that a least-squares line with an intercept passes through \((\bar{x},\bar{y})\). Its fitted value for observation \(i\) is \(\hat{y}_i=b_0+b_1x_i\), and the mean of all fitted values is \(\bar{y}\). Therefore, subtracting the mean fitted value gives \(\hat{y}_i-\bar{y}=b_1(x_i-\bar{x})\). The explained sum of squares is the sum of the squared differences between fitted values and \(\bar{y}\).
Here \(\mathrm{SSR}\) is the regression sum of squares, the variation in the response values represented by the fitted values relative to \(\bar{y}\). For a least-squares line with an intercept, the usual decomposition is \(\mathrm{SST}=\mathrm{SSR}+\mathrm{SSE}\). Thus \(R^2=\mathrm{SSR}/\mathrm{SST}\), and \(\mathrm{SST}=S_{yy}\). Substituting the expression for \(\mathrm{SSR}\) gives the result:
The last equality follows directly from the definition of \(r\). This derivation explains why the conditions matter. The formula for the fitted deviations uses the slope from the one-predictor least-squares line, and the equality between \(\mathrm{SST}\) and \(\mathrm{SSR}+\mathrm{SSE}\) here is for the ordinary least-squares fit with an intercept. Altering the model or removing the intercept can break the identity.
Worked Calculations
Worked Example: A Positive Association
Suppose a hypothetical exercise records hours of review, \(x\), and a short quiz score, \(y\), in points for five students. The paired observations are \((1,2),(2,3),(3,5),(4,4),(5,6)\). Find \(r\) and \(R^2\), and verify the identity.
The variables are quantitative and vary across the five pairs: the review hours range from 1 to 5, and scores are not all equal. Fit an ordinary least-squares line with an intercept. The means are \(\bar{x}=3\) hours and \(\bar{y}=4\) points. The centered sums are \(S_{xx}=(-2)^2+(-1)^2+0^2+1^2+2^2=10\), \(S_{yy}=(-2)^2+(-1)^2+1^2+0^2+2^2=10\), and \(S_{xy}=(-2)(-2)+(-1)(-1)+(0)(1)+(1)(0)+(2)(2)=9\).
Therefore, \(r=9/\sqrt{10(10)}=0.900\). The slope is \(b_1=S_{xy}/S_{xx}=9/10=0.900\) points per review hour, and the intercept is \(b_0=\bar{y}-b_1\bar{x}=4-(0.900)(3)=1.30\) points. The fitted line is \(\hat{y}=1.30+0.900x\).
For the five observations, the fitted scores are \(2.20, 3.10, 4.00, 4.90,\) and \(5.80\) points. The residuals, observed score minus fitted score, are \(-0.20,-0.10,1.00,-0.90,\) and \(0.20\) points. Hence \(\mathrm{SSE}=(-0.20)^2+(-0.10)^2+(1.00)^2+(-0.90)^2+(0.20)^2=1.90\) points squared, while \(\mathrm{SST}=S_{yy}=10\) points squared. It follows that \(R^2=1-1.90/10=0.810\), which matches \(r^2=(0.900)^2=0.810\).
In this hypothetical sample, the positive correlation indicates that greater review hours tend to accompany higher quiz scores. The R-squared value indicates that 81.0% of the observed variation in quiz scores is accounted for by the fitted line. Neither summary by itself establishes that reviewing caused the score differences.
Worked Example: The Same R-Squared With a Negative Direction
Now consider a second hypothetical data set with the same predictor values and response values \((8,7,5,6,4)\), paired in order with review hours \(x=1,2,3,4,5\). Find the correlation and R-squared. What changed compared with the preceding example?
The means are \(\bar{x}=3\) hours and \(\bar{y}=6\) points. The centered sums are \(S_{xx}=10\), \(S_{yy}=(-2)^2+1^2+(-1)^2+0^2+(-2)^2=10\), and \(S_{xy}=(-2)(2)+(-1)(1)+(0)(-1)+(1)(0)+(2)(-2)=-9\). The data have variation in both variables, and we again fit a least-squares line with an intercept.
Thus \(r=-9/\sqrt{10(10)}=-0.900\). The slope is \(b_1=-9/10=-0.900\) points per review hour, so the direction is negative. The intercept is \(b_0=6-(-0.900)(3)=8.70\) points, giving \(\hat{y}=8.70-0.900x\). The fitted scores are \(7.80,6.90,6.00,5.10,\) and \(4.20\) points. The residuals are \(0.20,0.10,-1.00,0.90,\) and \(-0.20\) points, so \(\mathrm{SSE}=1.90\) points squared and \(\mathrm{SST}=10\) points squared.
Therefore \(R^2=1-1.90/10=0.810\), while \(r^2=(-0.900)^2=0.810\). The same R-squared can accompany either a positive or negative correlation. Squaring preserves the strength represented by the magnitude of \(r\), but removes its direction.
Worked Example: Calculating From a Small Data Set
A hypothetical process log pairs operating time \(x\), in hours, with a measured output \(y\), in units, for four runs: \((0,1),(1,2),(2,2),(3,5)\). Calculate the correlation and R-squared using the centered sums, then check R-squared from residuals.
The means are \(\bar{x}=1.5\) hours and \(\bar{y}=2.5\) units. The centered \(x\) values are \(-1.5,-0.5,0.5,1.5\), and the centered \(y\) values are \(-1.5,-0.5,-0.5,2.5\). Thus \(S_{xx}=2.25+0.25+0.25+2.25=5\) hours squared, \(S_{yy}=2.25+0.25+0.25+6.25=9\) units squared, and \(S_{xy}=2.25+0.25-0.25+3.75=6\) hour-units.
The correlation is \(r=6/\sqrt{5(9)}=6/\sqrt{45}\approx0.8944\). The slope is \(b_1=6/5=1.20\) units per hour, and the intercept is \(b_0=2.5-(1.20)(1.5)=0.700\) units. The fitted values at \(x=0,1,2,3\) are \(0.700,1.90,3.10,\) and \(4.30\) units. The residuals are \(0.300,0.100,-1.10,\) and \(0.700\) units.
The residual sum of squares is \(\mathrm{SSE}=0.09+0.01+1.21+0.49=1.80\) units squared. Since \(\mathrm{SST}=S_{yy}=9\) units squared, \(R^2=1-1.80/9=0.800\). Independently, \(r^2\approx(0.8944)^2=0.800\). In this example, 80.0% of the observed variation in output across these four runs is accounted for by the fitted linear model.
What the Identity Does and Does Not Tell You
The identity is useful as a consistency check. If a simple least-squares regression with an intercept gives \(R^2=0.64\), then the sample correlation must have magnitude \(0.80\). The slope determines which sign applies: a positive slope means \(r=0.80\), while a negative slope means \(r=-0.80\). When values are rounded, small discrepancies in the last reported digit can occur.
Correlation and slope are not interchangeable. Correlation has no units and lies between \(-1\) and \(1\). The slope has response units per predictor unit, and its numerical value changes if either variable is expressed in different units. For example, converting a predictor from hours to minutes changes the slope's numerical value but does not change \(r\) or \(R^2\). R-squared, like correlation squared, is unit-free.
The identity also does not mean that R-squared describes the direction, proves causation, or guarantees that a straight-line model is suitable. It says how these two summaries relate for this particular in-sample, one-predictor least-squares fit with an intercept. Use the sign of the correlation or slope when direction matters, and interpret R-squared in the context of the response and the fitted model.
Common Mistake
A related error is to apply \(R^2=r^2\) automatically to any model called a regression. The result established here is for simple ordinary least squares with an intercept. In particular, a model with multiple predictors does not have one single predictor-response correlation whose square must equal its R-squared. Before using the identity, check that the model and data meet its stated conditions.
Check Your Understanding
Answer each question using the conditions and calculations in this tutorial.
- A simple least-squares regression with an intercept has \(r=-0.60\). What is \(R^2\), and what does the sign of \(r\) tell you?
- A fitted model has \(R^2=0.81\) and a negative slope. What is \(r\)?
- In a data set, \(S_{xx}=16\), \(S_{yy}=25\), and \(S_{xy}=12\). For a simple least-squares fit with an intercept, calculate \(r\) and \(R^2\).
- Why can changing a predictor from hours to minutes change the slope but leave \(r\) and \(R^2\) unchanged?
- Name the model condition required for the identity \(R^2=r^2\), and explain why R-squared alone cannot give the direction of a fitted line.