From Summary Statistics to a Fitted Line
A scatterplot and a list of paired observations are not always available. Sometimes a report gives only the number of observations, the means and standard deviations of the predictor and response, and their correlation. Those summaries contain enough information to calculate the least-squares slope and intercept—provided they describe the same paired observations and are mathematically compatible.
This calculation is useful when a line must be reconstructed from a statistical summary, or when checking a reported regression result. It also shows how the direction and strength of the linear association, together with the variables’ scales, determine the slope. The calculation does not by itself establish that a straight-line model is suitable for a particular scientific question.
The slope is measured in response units per predictor unit: \(s_y/s_x\) has those units, while \(r\) has no units. The intercept is in response units. It is the line’s value at \(x=0\), though that value may not have a useful practical interpretation if zero is outside the relevant range of predictor values.
Why the Formula Works
The earlier material on the slope formula from centered data gives the least-squares slope as the sum of cross-products divided by the sum of squared deviations of the predictor. To connect that result to summary statistics, define \(S_{xx}=\sum_{i=1}^{n}(x_i-\bar{x})^2\) and \(S_{xy}=\sum_{i=1}^{n}(x_i-\bar{x})(y_i-\bar{y})\). Then \(b_1=S_{xy}/S_{xx}\).
For sample standard deviations and sample correlation, the corresponding definitions are \(s_x^2=S_{xx}/(n-1)\), \(s_y^2=S_{yy}/(n-1)\), and \(r=S_{xy}/\sqrt{S_{xx}S_{yy}}\), where \(S_{yy}=\sum_{i=1}^{n}(y_i-\bar{y})^2\). When both variables vary, these definitions yield the formula below.
Substitute these expressions into the centered-data slope formula. The common factor \(n-1\) cancels, leaving the slope in terms of \(r\), \(s_x\), and \(s_y\). The intercept then follows because the least-squares line passes through \((\bar{x},\bar{y})\).
This is a short derivation of the summary-statistic formula: it is the centered-data slope rewritten using the standard definitions of sample standard deviation and correlation. The sample size cancels, so \(n\) does not appear explicitly in the final two calculations. It still matters as a compatibility check: the means, standard deviations, and correlation must all refer to the same \(n\) paired observations.
A Careful Calculation Routine
Before calculating, confirm that the summaries concern the same paired sample and use consistent units and sample-statistic definitions. For a valid correlation, the reported value must satisfy \(-1\leq r\leq 1\), and both standard deviations must be positive. Once these conditions hold, calculate the slope first and use it to calculate the intercept.
Verify that \(\bar{x}, \bar{y}, s_x, s_y,\) and \(r\) describe the same paired observations, that \(s_x>0\), \(s_y>0\), and \(-1\leq r\leq1\).
Use \(b_1=r(s_y/s_x)\), keeping track of which standard deviation belongs to the response and which belongs to the predictor.
Substitute the slope and both means into \(b_0=\bar{y}-b_1\bar{x}\).
Write \(\hat{y}=b_0+b_1x\), identify the predictor and response, and label the slope and intercept with their appropriate units.
Worked Example: A Positive Association
In a hypothetical sample of 24 plants, let \(x\) be weekly sunlight exposure in hours and \(y\) be plant height in centimetres. Suppose the summaries are \(\bar{x}=10\) hours, \(s_x=2\) hours, \(\bar{y}=50\) cm, \(s_y=8\) cm, and \(r=0.75\), all calculated from the same 24 plants. Both standard deviations are positive, and \(|0.75|\leq1\), so the summaries meet the basic mathematical checks.
First calculate the slope:
Then calculate the intercept:
The fitted line is \(\hat{y}=20+3x\), where \(x\) is sunlight exposure in hours and \(\hat{y}\) is fitted height in centimetres. The calculated slope is positive, consistent with the positive reported correlation. The intercept is \(20\) cm; it describes the fitted line at zero hours, without asserting that this is a meaningful or observed plant height in the setting.
Worked Example: A Negative Association
For a hypothetical group of 30 commuters, let \(x\) be a one-way commute distance in kilometres and \(y\) be average travel speed in kilometres per hour. Suppose \(\bar{x}=12\) km, \(s_x=4\) km, \(\bar{y}=60\) km per hour, \(s_y=10\) km per hour, and \(r=-0.40\), all from the same 30 commuters. Both variables vary, and the correlation is within its allowable range.
The slope calculation is
The units can be read as kilometres per hour of fitted travel speed for each additional kilometre of commute distance. Now calculate the intercept:
Thus the fitted line is \(\hat{y}=72-1.0x\), with \(x\) in kilometres and \(\hat{y}\) in kilometres per hour. The negative sign in the slope matches the negative correlation. This is a calculation from hypothetical summaries, not evidence that distance causes a change in travel speed.
Checking Whether Summaries Are Compatible
A calculation can be carried out mechanically even when its inputs do not describe a possible sample. The correlation bound is a necessary check: because correlation is a standardized measure of linear association, it must lie between \(-1\) and \(1\), inclusive. Also, the summaries must use the same observations. A mean from one sample combined with a standard deviation or correlation from another does not produce the least-squares line for either sample.
The checks do not prove that every set of reported summaries is correct. In the absence of raw data, one cannot independently verify that the summaries were computed from the stated observations. But one can identify clear contradictions, such as a correlation outside its allowable range, a zero predictor standard deviation paired with a claimed ordinary slope calculation, or summaries explicitly based on different samples.
Worked Example: An Impossible Reported Correlation
A hypothetical report gives \(n=18\), \(\bar{x}=5\), \(s_x=2\), \(\bar{y}=20\), \(s_y=3\), and \(r=1.04\), claiming that all summaries describe the same paired observations. The standard deviations are positive, but the correlation fails the necessary condition:
If the slope formula is applied mechanically, it gives
That arithmetic does not make \(1.56\) a valid least-squares slope for the claimed sample. The given correlation is impossible for paired observations, so the summaries are incompatible as stated and the fitted line cannot be accepted as calculated from them. The appropriate conclusion is to check the source, definitions, or transcription of the summaries—not to report the resulting line.
What Rounding Can and Cannot Explain
Published summaries are often rounded. Rounding can cause small discrepancies when a reader checks calculations, especially if the correlation is close to \(1\) or \(-1\). For instance, a value displayed as \(1.00\) could stand for a value slightly below \(1\); it does not necessarily mean the underlying correlation is exactly \(1\). But rounding should not be used to excuse a substantial violation such as \(r=1.04\). When inputs are rounded, treat the resulting slope and intercept as approximate and report sensible precision rather than implying exactness.
The displayed means also determine the intercept. If a mean is rounded, then the intercept calculated from it is approximate even when the slope calculation is otherwise valid. Carry enough digits through intermediate steps to limit avoidable rounding error, and round the final coefficients to a precision appropriate for the summaries and measurement units.
Common Mistakes and Why the Checks Matter
- Reversing the standard deviations. The response standard deviation goes in the numerator and the predictor standard deviation goes in the denominator: \(b_1=r(s_y/s_x)\). Reversing them generally gives the wrong slope and the wrong units.
- Using the wrong mean in the intercept formula. The intercept is \(b_0=\bar{y}-b_1\bar{x}\), not \(\bar{x}-b_1\bar{y}\). The line is anchored to the point whose horizontal coordinate is the predictor mean and whose vertical coordinate is the response mean.
- Treating an impossible correlation as usable. A calculation with \(r=1.04\) may produce a number, but that number cannot be the slope from the claimed valid summaries. Check compatibility before reporting a line.
- Mixing units or samples. The means, standard deviations, and correlation must describe the same paired observations. Combining summaries from different groups or using a predictor standard deviation in different units changes or invalidates the calculation.
- Assuming the intercept must be practically meaningful. The formula always returns an intercept when the calculation is defined, but \(x=0\) may not be observed or relevant. A computable coefficient is not automatically a useful prediction in every context.
Check Your Understanding
Try these questions before checking the formulas above.
- A hypothetical sample has \(\bar{x}=8\), \(s_x=2\), \(\bar{y}=30\), \(s_y=6\), and \(r=0.50\). Calculate the least-squares slope and intercept.
- If \(r\) is negative while both standard deviations are positive, what must be true about the sign of the fitted slope? Explain using the slope formula.
- A report gives \(s_x=0\) and a numerical value for \(r\). Why can that value not be used to calculate the slope by the summary-statistic formula?
- A report gives \(r=-1.02\). What compatibility check fails, and what should be concluded about a line calculated from those summaries?
- Why must the sample means, standard deviations, and correlation all be based on the same paired observations?