Chapter 12 · 50 minutes

Last updated November 11, 2026

Simple Linear Regression for Numerical Outcomes

Opening scenario

A financial analyst at Riverbend Health System is preparing the budget assumptions for next year’s inpatient units. The chief financial officer asks a specific question: when an inpatient stay lasts one day longer, how much higher are its charges, on average? Everyone at the meeting expects longer stays to carry higher charges, but a budget needs a figure in dollars, and the expectation alone does not supply one.

Table 1 lists five stays from the hospital’s discharge file. The first four rise in an orderly way, by roughly $2,000 for each added day. The fifth, a 5.7-day cardiology stay that included time in the intensive care unit (ICU), carries charges of almost $125,000, several times what its length alone would suggest.

Table 1: Five inpatient stays chosen to show the range of the data: four that sit close to the overall pattern and one far above it. Total charges are the hospital’s billed charges in U.S. dollars, not the cost of providing the care. Source: datasets/DS4_inpatient_clean.csv, stays admitted January 2024 to December 2025.
Stay Service line Length of stay (days) Total charges
IPD006443 Obstetrics 2.0 $10,398.00
IPD005873 Medicine 4.6 $15,967.01
IPD001939 Surgery 7.0 $21,206.39
IPD007584 Medicine 12.0 $30,974.13
IPD005645 Cardiology (with ICU care) 5.7 $124,953.57

Chapter 10 measured how closely two numerical measures move together with the correlation coefficient, written r and also called Pearson’s r, a number from −1 to 1. This chapter fits the straight line that summarizes that movement, reads its slope as dollars per day, and checks how well the line describes stays like the fifth one. The walkthrough answers the analyst’s question. Whether shortening stays would reduce charges by the same amount is a different question; the Real World box at the end of the chapter returns to it, and Chapter 13 develops the tools to approach it.

By the end of this chapter, you will be able to:

  • Describe the direction, form, strength, and unusual points of a relationship from a scatterplot before fitting a line.
  • Fit a least-squares line in Excel with a chart trendline and with the SLOPE, INTERCEPT, and RSQ functions, and write its equation in the units of the data.
  • Interpret the slope and the intercept in plain language, including when the intercept has no practical meaning.
  • Calculate predicted values and residuals, and use a residual plot to judge whether a straight line describes the data adequately.
  • Interpret R-squared as the share of variation the line accounts for, and relate it to the correlation coefficient from Chapter 10.
  • Recognize the limits of a regression line: extrapolation, influential points, and the difference between association and cause.

Key concepts

A regression line turns “these two measures rise together” into a statement with units: how much one measure changes, on average, for each one-unit difference in another. This section develops simple linear regression in five steps:

  • look, reading the scatterplot before fitting anything,
  • fit, finding the least-squares line and its intercept and slope,
  • read, stating the slope and the intercept in the units of the data and using the line to predict,
  • check, judging the fit with residuals, a residual plot, and R-squared,
  • limits, recognizing extrapolation, influential points, and the difference between association and cause.

The examples use four files. The DS prefix numbers the book’s operational teaching datasets from the fictional Riverbend Health System, and the PH prefix numbers its public health datasets. This chapter uses DS4 (inpatient stays), PH1 (county public health measures), DS7 (a population health registry), and DS9 (a small wellness screening file).

About the teaching data. Every dataset in this book is synthetic, as Chapter 5 explained, so none contains protected health information. Four points matter for this chapter:

  • DS4 records charges, not costs. A hospital’s charges are the amounts it bills, and they generally differ from the resources the care consumes. Researchers who need cost estimates convert charges with hospital cost-to-charge ratios, such as those the Healthcare Cost and Utilization Project publishes (Agency for Healthcare Research and Quality [AHRQ], 2026). This chapter therefore speaks of charges throughout.
  • PH1 is not a release from the Centers for Disease Control and Prevention (CDC). It pairs real county names with synthetic estimates modeled on the CDC’s Population Level Analysis and Community Estimates (PLACES) program (Centers for Disease Control and Prevention [CDC], 2025). Its values describe no actual county.
  • DS7 is a synthetic registry of 10,000 adult patients as of December 31, 2025, with one row per patient.
  • Some synthetic values sit at fixed limits. The data generators cap certain measures, so rows of points line up at those limits in the scatterplots: 108 registry patients have a systolic blood pressure of exactly 88 millimeters of mercury, and 11 and 9 counties have diagnosed diabetes rates of exactly 4 and 24 percent. These limits are features of the teaching data, not clinical findings.

Look before you fit: the scatterplot

The response variable is the measure a regression line describes or predicts; it goes on the vertical axis and is written y. The explanatory variable is the measure used to describe or predict it; it goes on the horizontal axis and is written x. The response variable is also called the dependent variable, because its values are modeled as depending on the other measure. The explanatory variable is also called the independent variable.

Different fields use different names for the same two roles, so Figure 1 lists the pairs you are likely to meet, alongside one stay read from a scatterplot. This book uses response and explanatory variable, which describe the roles without implying that one measure causes the other. The name “dependent” describes how the model is set up, not a proven cause.

Figure 1: The anatomy of a scatterplot. Each point is one stay: stay IPD003667, highlighted, sits at x = 8 days of stay and y = $43,670 in total charges. The table names the two roles: the response variable (also called the dependent variable or outcome) on the vertical axis, written y, and the explanatory variable (also called the independent variable or predictor) on the horizontal axis, written x. Statistics texts and the documentation for Excel’s Analysis ToolPak use “dependent” and “independent” (Microsoft, n.d.-f); this book uses “response” and “explanatory.” Source: datasets/DS4_inpatient_clean.csv, a selection of stays.

The question decides which measure plays which role. The analyst asks how charges change with length of stay, so total charges are the response and length of stay is the explanatory variable. Reversing the roles would answer a different question, how length of stay changes with charges, and would produce a different line.

Looking comes first because a fitted line and its summary numbers describe only the straight-line part of a relationship. In a well-known demonstration, the statistician Francis Anscombe constructed four small datasets that produce the same fitted line and the same R-squared, the measure of fit this chapter defines below (Anscombe, 1973). Figure 2 plots them. Only the first is described adequately by a straight line. The second is a curve, the third is a tight line with one stray point, and in the fourth a single point sets the slope.

Figure 2: Anscombe’s four datasets of 11 points each. All four produce the same least-squares line, y = 3.00 + 0.50x, and the same R-squared of 0.67, yet only dataset A follows a straight-line pattern. Source: Anscombe (1973).

Chapter 11 introduced the scatterplot as the chart for a relationship between two numerical measures. Before you fit a line, read four features of the plot (Diez et al., 2019), shown in Figure 3:

  • Direction. Do the points rise from left to right (positive) or fall (negative)?
  • Form. Do they follow a roughly straight path, or do they bend?
  • Strength. Do they cluster tightly around a path, or scatter loosely?
  • Unusual points. Do any points sit far from the rest?
Figure 3: The four features to read in a scatterplot before fitting a line: direction (positive or negative), form (roughly straight or curved), strength (tight or loose clustering), and unusual points separated from the rest. Source: concept schematic with simulated data.

When the form bends. A bend means the relationship changes speed partway along. On a straight line, each one-unit step in the explanatory variable adds the same amount to the response. On a bend, the amount per step changes: early steps may add a large amount and later steps very little, or the reverse.

As an illustration, not drawn from the teaching data, the first small dose of a pain medication may lower a pain score sharply, while each further increase lowers it less, until the points level off. A straight line can describe only one constant amount per step, so for a bend it overpredicts in one region and underpredicts in another, and r understates how closely the measures are related. The residual plot section returns to how to detect a bend and what to do about it.

To practice reading these features, use datasets/DS9_wellness_screening.csv, a file of 100 adults seen at an annual wellness screening. Its columns, which include age, body mass index (BMI), steps per day, resting heart rate, blood pressure, stress, sleep, and fatigue, were designed so that different pairs show different kinds of relationship. Figure 4 plots nine pairs, from a strong positive relationship to no relationship at all. Two panels carry the lesson of this section: exercise and resting heart rate have a strong r of −0.72 but follow a curve that levels off, and sleep and fatigue have an r near 0 yet a clear U shape.

The file is built for practice: its 100 rows were generated so that particular pairs of columns show strong, moderate, weak, and absent relationships, curved patterns, and one outlier and one high-leverage point. The first 14 columns supply the examples in this chapter’s figures; the last six, height_cm to vitamin_d (columns O to T), supply new pairs for Practice C and the exercises and appear in no figure. Real data seldom show such clear patterns.

Figure 4: Nine pairs of columns in the wellness screening file, each labeled with its kind of relationship and its correlation r: strong positive (BMI and waist, 0.93), strong negative (steps and sedentary hours, −0.83), curved negative (exercise and resting heart rate, −0.72), moderate positive (age and systolic blood pressure, 0.50), moderate negative (BMI and steps, −0.47), U shape (sleep and fatigue, −0.04), weak positive (stress and fasting glucose, 0.23), weak negative (steps and resting heart rate, −0.21), and no relationship (birth month and systolic blood pressure, 0.05). Axis labels give units where the measure has one. Birth months are spread slightly sideways so the points do not overlap. Source: datasets/DS9_wellness_screening.csv, 100 synthetic adults.

Draw the scatterplot before you fit or report a line. Two datasets can share the same equation and the same R-squared while having entirely different shapes, and only the plot shows the difference.

The line: intercept and slope

Simple linear regression describes a numerical response variable with a straight line in one explanatory variable. The line is set by two numbers. The intercept is the predicted value of the response when the explanatory variable equals zero. The slope is the change in the predicted response for each one-unit increase in the explanatory variable.

In words, the line reads:

predicted response = intercept + slope × explanatory variable

Statistics texts write the same line with symbols, as y-hat = b0 + b1 × x. Here y-hat (written as a y with a small hat over it) stands for the predicted value of the response, b0 (“b-zero”) is the intercept, and b1 (“b-one”) is the slope. This chapter uses the words and gives the symbols only for reference.

For the 8,500 Riverbend stays, the line that the walkthrough fits is:

predicted charges = $6,344.31 + $2,131.62 × length of stay in days

Figure 5 draws this line. The intercept is where the line meets the vertical axis, at zero days. The slope is the rise of the line for a run of one day: moving from 6 to 7 days, predicted charges rise by $2,131.62. Because the line is straight, the rise is the same for every added day, whether the stay grows from 1 to 2 days or from 9 to 10.

Figure 5: The anatomy of the line fitted to 8,500 inpatient stays: predicted charges = $6,344.31 + $2,131.62 × days. The intercept, $6,344.31, is the predicted charge at zero days, outside the observed lengths of stay, which start at 0.6 days (shaded); the slope, $2,131.62, is the rise for each additional day. For stay IPD003667, at 8 days, the predicted value is $23,397 and the actual charge $43,670, a residual of +$20,273. A selection of other stays is shown. Source: line fitted to datasets/DS4_inpatient_clean.csv, stays admitted January 2024 to December 2025.

Table 2 collects the terms this chapter uses, with their symbols, their meaning in the charges example, and the Excel function that calculates each one.

Table 2: Terms, symbols, and Excel functions for simple linear regression, with their values in the charges example. Source: line fitted to datasets/DS4_inpatient_clean.csv, 8,500 stays admitted January 2024 to December 2025.
Term Symbol In the charges example In Excel
Response variable y Total charges, in dollars First argument of SLOPE; second column selected for a scatterplot
Explanatory variable x Length of stay, in days Second argument of SLOPE; first column selected for a scatterplot
Intercept b0 $6,344.31, the predicted charge at 0 days INTERCEPT
Slope b1 $2,131.62 more per additional day SLOPE
Predicted value y-hat The line’s charge for a given length of stay FORECAST.LINEAR
Residual y − y-hat Actual charges minus predicted charges A subtraction formula
Correlation coefficient r 0.467: a moderate positive straight-line relationship CORREL
R-squared (coefficient of determination) R² 0.218: the line accounts for 21.8 percent of the variation in charges RSQ

Residuals and least squares

Many lines could be drawn through the cloud of stays. Regression chooses one by measuring how far each stay sits from the line.

A residual is the difference between an observed value of the response and the value the line predicts for it: residual = actual − predicted. The least-squares line is the line that makes the sum of the squared residuals as small as possible.

A stay above the line has a positive residual, because it was charged more than the line predicts. A stay below the line has a negative residual. Figure 6 marks three stays of exactly 8 days from the inpatient file. The line predicts $23,397 for any 8-day stay, so each stay’s residual is its charge minus $23,397:

  • IPD003667 was charged $43,670, a residual of +$20,273.
  • IPD000649 was charged $24,252, a residual of +$855; the line describes this stay closely.
  • IPD003944 was charged $10,296, a residual of −$13,102.
Figure 6: Three 8-day stays share one predicted charge, $23,397, but differ in their residuals: +$20,273, +$855, and −$13,102. Positive residuals sit above the prediction and negative residuals below it. Charges and residuals are rounded to the nearest dollar. Source: datasets/DS4_inpatient_clean.csv, stays admitted January 2024 to December 2025.

The residuals are squared before they are added for two reasons. Without squaring, positive and negative residuals would cancel, and many poorly fitting lines would score as well as a close-fitting one. Squaring also gives large misses more than proportional weight, which is why a few very large charges can pull the line toward them, a point this section returns to under influential points (Diez et al., 2019; National Institute of Standards and Technology [NIST], 2012). One consequence of the least-squares method is that the residuals of the fitted line always average zero; the walkthrough uses that property as a check.

Figure 7 shows the rule at work on four illustrative points. A candidate line misses the points by −1, −2, −1, and +2, so its squared residuals add to 10. The least-squares line misses by +1, −1, −1, and +1, a sum of 4, and no other straight line produces a smaller sum.

Figure 7: Two lines fitted to the same four illustrative points. The candidate line, predicted y = x + 5, has a sum of squared residuals of 10; the least-squares line, predicted y = 2x + 2, has a sum of 4, the smallest possible. Source: concept schematic with illustrative data.

Excel’s SLOPE (Microsoft, n.d.-e), INTERCEPT (Microsoft, n.d.-c), and RSQ (Microsoft, n.d.-d) functions, the chart trendline, and the Analysis ToolPak’s Regression tool (Microsoft, n.d.-f) all calculate the same least-squares line.

With the inpatient file converted to a Table named Inpatient: =SLOPE(Inpatient[total_charges_usd], Inpatient[length_of_stay_days]) returns about 2131.62. =INTERCEPT(Inpatient[total_charges_usd], Inpatient[length_of_stay_days]) returns about 6344.31. =RSQ(Inpatient[total_charges_usd], Inpatient[length_of_stay_days]) returns about 0.218. Each function takes the response column first and the explanatory column second.

Excel’s regression functions list the response before the explanatory variable, which is the reverse of the x-then-y order in which the line is usually described. If you swap the two ranges, SLOPE returns about 0.0001, the slope of days on charges, without any error message. When a slope looks implausibly small or large, check the order of the arguments first.

Figure 8 sets the two orders side by side: the scatterplot takes length of stay first, as X, while the functions take charges first, as Y. The roles of the two columns are the same in both; only the order in which Excel asks for them differs.

Figure 8: How the two columns map to the scatterplot and to the regression functions. In the chart, length of stay (column F) is X on the horizontal axis and total charges (column W) is Y on the vertical axis; in SLOPE, INTERCEPT, and RSQ, the Y column comes first and the X column second. Source: datasets/DS4_inpatient_clean.csv and the Chapter 12 walkthrough.

Calculate two residuals by hand from the line predicted charges = $6,344.31 + $2,131.62 × days, using stays from Table 1.

  1. For IPD007584, a 12-day stay charged $30,974.13, calculate the predicted charge and the residual.
  2. For IPD005645, a 5.7-day stay charged $124,953.57, do the same.
  3. State in one sentence which stay the line describes well, and name one feature of the second stay, visible in the table, that the line does not take into account.

The answer key is at the end of the chapter.

Reading the slope and the intercept

A slope is read as a sentence with units: for each additional unit of the explanatory variable, the predicted response is higher (or lower) by the slope, in the response’s units. For the charges line:

  • For each additional day of stay, predicted charges are $2,131.62 higher.
  • The units are dollars per day, the response’s units divided by the explanatory variable’s units.
  • A negative slope would mean the predicted response falls as the explanatory variable rises.

A slope depends on the units of both measures. If length of stay were recorded in hours instead of days, the slope would be $2,131.62 ÷ 24, about $88.82 per hour, but the line, its predictions, r, and R-squared would not change. Always state the units with the slope.

The slope describes how charges differ, on average, between stays of different lengths. It is an average across all 8,500 stays, not a statement about any one patient: the three 8-day stays in Figure 6 share one predicted charge but differ by more than $33,000.

The intercept, $6,344.31, is the predicted charge for a stay of zero days. No stay lasts zero days, and the shortest stay in the file lasts 0.6 days, so the intercept anchors the line rather than describing any stay in the data. Read an intercept as a meaningful value only when zero is a sensible value of the explanatory variable and lies within the range of the data (Bewick et al., 2003). Practice B shows an intercept that fails both tests.

Prediction and extrapolation

A predicted value is the value of the response that the line gives for a chosen value of the explanatory variable. Extrapolation is using the line to predict for values of the explanatory variable outside the range of the data used to fit it.

To predict charges for a 3-day stay, substitute 3 into the line: $6,344.31 + $2,131.62 × 3 = $12,739.17. Excel’s FORECAST.LINEAR function does the same calculation from the data, without your typing the slope and intercept (Microsoft, n.d.-b). It takes the new x value first, then the response column, then the explanatory column.

=FORECAST.LINEAR(3, Inpatient[total_charges_usd], Inpatient[length_of_stay_days]) returns about 12739.18, the predicted charge for a 3-day stay. The one-cent difference from the hand calculation comes from rounding the slope and intercept to two decimals.

A prediction is only as reliable as the data behind it. The Riverbend stays run from 0.6 to 37.9 days, and the line has been checked against stays only within that range. Beyond it, nothing in the data shows whether charges keep rising in a straight line, level off, or rise faster. Figure 9 extends the line to 60 days, where it predicts $134,241.73 for a stay longer than any in the file. The arithmetic is correct, but the data give no support for it (Bewick et al., 2003; Diez et al., 2019).

Figure 9: Predicted charges from the line within the observed lengths of stay, 0.6 to 37.9 days (shaded), and beyond them (dashed). The 3-day prediction, $12,739.18, lies within the data; the 60-day prediction, $134,241.73, is an extrapolation beyond the longest observed stay. Source: line fitted to datasets/DS4_inpatient_clean.csv, 8,500 stays admitted January 2024 to December 2025.

When you report a regression line, state the range of the explanatory variable it was fitted on, and predict only within that range.

Checking the fit: residual plots

A line can be the best straight line for the data and still describe the data poorly. The residuals show where the line departs from the data.

A residual plot is a scatterplot of the residuals against the predicted values, with a horizontal reference line at zero. Non-constant spread is a pattern in which the residuals scatter farther from zero in one part of the plot than in another.

A residual plot moves each point to new coordinates. Figure 10 follows stay IPD003667 from the scatterplot to the residual plot: its horizontal position becomes its predicted charge, $23,397, and its vertical position becomes its residual, $43,670 − $23,397 = +$20,273. The line itself becomes the horizontal reference line at zero.

Figure 10: One stay followed from the scatterplot to the residual plot. In the scatterplot, stay IPD003667 sits at 8 days and $43,670; in the residual plot, it sits at its predicted charge, $23,397, and its residual, +$20,273. Two other stays from the inpatient file are shown for reference. Source: datasets/DS4_inpatient_clean.csv, stays admitted January 2024 to December 2025.

If a straight line describes the data adequately, the residuals form a band of roughly even width around zero, with no pattern. Any visible structure means the line is missing something (NIST, 2012; Vu & Harrington, 2020). Figure 11 shows the four patterns to recognize:

  • A random band of even width: the straight line is adequate.
  • A curve: the relationship bends, as described under Look before you fit. The line runs above the points in one region and below them in another, and its single slope describes no part of the data well. Describe the relationship separately within ranges where it is roughly straight, consider a transformation such as the logarithm in the Going Deeper box, or note that a curved model is needed.
  • A fan that widens to one side: non-constant spread, so the line’s predictions are less precise in that region.
  • One distant point: a case to investigate before trusting the line.
Figure 11: Four patterns in a residual plot, each with residuals plotted against predicted values and a reference line at zero: a patternless band, a curved pattern, a fan, and one unusual residual. Source: concept schematic with simulated data.

Figure 12 is the residual plot for the charges line. It is a fan. Split the 8,500 stays into roughly equal thirds by predicted charge, and the standard deviation (SD) of the residuals, a measure of how widely the residuals vary within each group (Chapter 9), grows from $9,614 in the lowest third to $11,749 in the middle third and $19,004 in the highest. The line’s predictions are therefore much less precise for long stays than for short ones. The plot also shows that the residuals are asymmetric: the largest residual is +$143,954, but no residual falls below −$38,437, because charges have a floor and a long upper tail, the right skew that Chapter 9 described for durations.

Figure 12: Residuals from the charges line plotted against predicted charges for all 8,500 stays, with dotted dividers marking roughly equal thirds of the predicted values. The SD of the residuals rises from $9,614 in the lowest third to $11,749 in the middle third and $19,004 in the highest, a fan pattern of non-constant spread. The SD uses STDEV.S. Source: datasets/DS4_inpatient_clean.csv, stays admitted January 2024 to December 2025.

A fan does not invalidate the slope. The line still summarizes the average increase per day. It does mean that a single statement of the line’s typical error would overstate its precision for short stays and understate it for long ones. The fan matters more for statistical inference than for the slope itself: the standard errors, confidence intervals, and p-values that Chapter 13 reads from regression output assume residuals of even spread, so a fan calls for caution in reading them. The Going Deeper box describes a common remedy for a fan in skewed data.

R-squared: how much the line explains

R-squared (written R², and formally called the coefficient of determination) is the share of the variation in the response that the line accounts for, on a scale from 0 (none) to 1 (all). For a simple linear regression, it equals the square of the correlation coefficient r from Chapter 10.

To see what “share of the variation” means, measure how far each stay’s charges sit from the average charge, square those distances, and add them up. That total describes how much charges vary before any line is drawn.

Now do the same with the residuals, the distances from the line. For the Riverbend stays, the residuals leave 78.2 percent of the original total, so the line accounts for the other 21.8 percent: R² = 0.218. Chapter 10 reported a correlation of 0.467 between the same two measures; 0.467 squared is 0.218, the same value. Figure 13 draws the comparison.

Figure 13: R-squared as a comparison of two predictions for the same 8,500 stays. Predicting the mean charge for every stay leaves the total squared variation (100 percent); predicting from length of stay leaves 78.2 percent as squared residuals, so the line accounts for 21.8 percent: R² = 1 − (sum of squared residuals ÷ total squared variation) = 0.218. Source: datasets/DS4_inpatient_clean.csv, stays admitted January 2024 to December 2025.

R-squared is tied to the correlation coefficient r from Chapter 10. Two properties of r carry over directly, and one is new. Recall that r runs from −1 to 1, with 0 meaning no straight-line relationship; Figure 14 reviews the scale and shows that a loose cloud and a clear U shape can both have an r of 0.

New in this chapter, the sign of r always matches the sign of the slope. And squaring r gives R-squared but removes the sign: an r of −0.8 and an r of 0.8 both give an R-squared of 0.64, so read the direction from the slope, not from R-squared.

Figure 14: How to read the correlation coefficient. Five illustrative scatterplots show r of −1, −0.6, 0, +0.6, and +1; the sign gives the direction, and values farther from 0 indicate a stronger straight-line relationship. Two further panels show that a loose cloud and a U-shaped pattern can both have an r of 0. Source: concept schematic with illustrative data.

Figure 15 shows four pairs of inpatient measures, from an R-squared near 0 to the 0.22 of the charges line, so you can connect the number to the look of the cloud. Even the strongest pair is a loose cloud: in these data, no single explanatory variable accounts for as much as a quarter of the variation in the measure it is paired with.

Figure 15: Four pairs of inpatient measures for 8,500 stays, ordered from the weakest to the strongest straight-line relationship: comorbidity count and charges (R² = 0.00), age and length of stay (R² = 0.04), comorbidity count and risk score (R² = 0.15), and length of stay and charges (R² = 0.22). Comorbidity counts are whole numbers, spread slightly sideways so the points do not overlap. Axis values are omitted because the panels use different units. Source: datasets/DS4_inpatient_clean.csv, stays admitted January 2024 to December 2025.

R-squared is often over-interpreted. Four points guide its interpretation (NIST, 2012; Schneider et al., 2010):

  • R-squared measures fit, not correctness. Anscombe’s four datasets share an R-squared of 0.67, and three of the four lines misdescribe their data.
  • A low R-squared can accompany a clear slope. Practice B fits a line with an R-squared of 0.06 to 10,000 patients. With that many patients, a slope of that size is very unlikely to arise by chance alone, and Chapter 13 shows how to test it; its positive direction also agrees with national survey data.
  • R-squared says nothing about cause. It measures how closely the points follow the line, not why.
  • R-squared describes strength; it does not rank models. Comparing R-squared across different pairs of measures, as Figure 15 does, describes which relationships follow a straight line more closely. It does not show that one model is more useful or reliable than another: an R-squared of 0.22 for charges and 0.61 for county diabetes rates describe different problems. Comparisons of how well models predict are meaningful only when they predict the same response from comparable data.

Outliers, leverage, and influential points

Chapter 8 described outliers in a single column. In regression, a point is judged by where it sits relative to the line and to the other x values.

An outlier in regression is a point with a large residual, far above or below the line. A point has high leverage when its value of the explanatory variable is far from the others. An influential point is one whose removal noticeably changes the slope or the intercept.

Figure 16 separates the three ideas with illustrative points. An outlier at a typical x value moves the line only slightly. A point with high leverage that follows the pattern leaves the line almost unchanged. A point that has high leverage and also lies off the pattern is influential: removing it tilts the line substantially.

Figure 16: Three illustrative cases, each with the line fitted with and without the highlighted point: a large residual at a typical x value, a high-leverage point that follows the pattern, and an influential point whose removal substantially changes the slope. Source: concept schematic with illustrative data.

A point with high leverage has the most power to tilt the line. In Anscombe’s dataset D (Figure 2), ten points share one x value, so the eleventh point, far to the right, alone determines the slope.

The Riverbend data contain a different case: a group of outliers that is influential together. Of the 8,500 stays, 85 have charges above $80,000, and all have large positive residuals. Their lengths of stay run from 2.8 to 33.1 days; a stay inside the observed range can still have high leverage if its length is far from the average, so the longest of these stays may also carry leverage, which would need to be checked stay by stay. As a group they sit at longer stays than most, with a median of 10.6 days against 4.7 for all stays. Their share of ICU care, 31 percent, is about 2.7 times the 11 percent for all stays.

Refit the line without those 85 stays, and the slope falls from $2,131.62 to $1,810.63 per day, a drop of about 15 percent; the intercept rises to $7,398.76, and R-squared moves from 0.218 to 0.210. Figure 17 draws both lines. Because these stays were selected for their high charges, removing them is bound to lower the slope, and their longer-than-typical stays add to the effect. The refit is a sensitivity check that shows how much the group matters, not a better line.

Figure 17: The charges line fitted to all 8,500 stays (solid, slope $2,132 per day) and refitted on the 8,415 stays charged $80,000 or less (dashed, slope $1,811 per day), a slope about 15 percent lower. The 85 excluded stays are highlighted. Source: datasets/DS4_inpatient_clean.csv, stays admitted January 2024 to December 2025.

The 85 stays are not data errors. They are valid high-charge stays in the file, and deleting them to obtain a closer-fitting line would misrepresent the hospital’s charges. Apply Chapter 8’s approach to outliers: investigate the points, decide on a documented basis, and when a small group of cases moves the slope noticeably, report the line with and without them so the reader can judge.

Association, not causation

A regression slope describes how the response differs, on average, between cases with different values of the explanatory variable. It does not show that changing the explanatory variable for a case would change its response by the slope.

Chapter 4 introduced the confounder, a third factor related to both the exposure and the outcome. In regression, the same idea is called a confounding variable: a factor related to both the explanatory variable and the response that can create or distort an association between them. Severity of illness is a likely confounder here.

Sicker patients tend to stay longer, and they also tend to receive more intensive and more expensive services, such as ICU care and procedures. Part of the $2,132 per day may therefore reflect what long stays involve rather than the added days themselves. A simple regression cannot separate the two. Chapter 13 adds further explanatory variables to the line so that their associations can be read with the others held constant (Schneider et al., 2010).

Walkthrough: build an inpatient charges model

The five steps from the start of Key concepts (look, fit, read, check, and limits) are now in place. The walkthrough applies them in order to the chief financial officer’s question.

This build answers the opening scenario. You plot charges against length of stay, fit the least-squares line twice (once with a chart trendline and once with functions), calculate a predicted charge and a residual for every stay, draw the residual plot, and use the line to predict. Figure 18 shows the finished Model sheet and the two new Table columns.

Figure 18: The finished model you build in this walkthrough. The Model sheet holds the count, slope, intercept, R-squared, correlation, average residual, and two predictions in B3:B11; the Inpatient Table gains a predicted charge in column AG and a residual in column AH, shown here for the first stay, IPD001565. Values are formatted for print; your sheet may show more decimals in the same cells. Source: datasets/DS4_inpatient_clean.csv, 8,500 stays admitted January 2024 to December 2025.

Before you start: open datasets/DS4_inpatient_clean.csv, and immediately save a working copy as an Excel workbook so the original stays untouched. Work only in the copy. These teaching files hold no real patient information; real patient data must stay in approved, secure storage, and you should make a local working copy only when you are authorized to.

Part A. Set up the data. Convert the file into a named Table so every formula can refer to its columns by name.

  1. Open datasets/DS4_inpatient_clean.csv in Excel. The file has 8,500 stays in rows 2 to 8501 and 32 columns, A to AF.
  2. Choose File > Save As, pick Excel Workbook (.xlsx), and name the file ch12_charges_model.xlsx. Work in this file from here on.
  3. Click any cell inside the data. On the Insert tab, click Table, confirm My table has headers is checked, and click OK.
  4. On the Table Design tab (named Table on macOS), set the Table Name to Inpatient.

Part B. Draw the scatterplot. Excel places the first selected column on the horizontal axis, so select the explanatory variable first.

  1. Click the column letter F at the top of the sheet to select length_of_stay_days. Hold Ctrl (Cmd on macOS) and click the column letter W to add total_charges_usd.
  2. Choose Insert > Charts > Scatter: on the Insert tab, click the scatter chart button (its tooltip reads Insert Scatter (X, Y) or Bubble Chart) and pick the first option, Scatter, which draws markers only. A chart with 8,500 points appears.
    • Confirm which column is on which axis. Right-click the chart and choose Select Data. On Windows, select the series and click Edit; on macOS, the fields appear in the dialog. X values should refer to the length_of_stay_days column ($F$2:$F$8501) and Y values to total_charges_usd ($W$2:$W$8501). If they are reversed, swap the two ranges and click OK.
  3. Click the chart title and type Inpatient charges and length of stay.
  4. Add axis titles. On Windows, click the Chart Elements button (+) beside the chart and check Axis Titles. On macOS, choose Chart Design > Add Chart Element > Axis Titles, then Primary Horizontal, and repeat for Primary Vertical.
  5. Click each axis title and type Length of stay (days) for the horizontal axis and Total charges (USD) for the vertical axis.
  6. Read the four features before fitting. The direction is positive, the form is roughly straight but widens to the right, the strength is moderate, and several dozen stays sit far above the rest. Your chart should resemble Figure 19.
Figure 19: Inpatient charges against length of stay for all 8,500 stays, with the least-squares line: predicted charges = $6,344 + $2,132 × days, R² = 0.22. Source: datasets/DS4_inpatient_clean.csv, stays admitted January 2024 to December 2025.

Part C. Add the trendline. A trendline fits the least-squares line without a formula (Microsoft, n.d.-a).

  1. Click any point in the chart so that all the points are selected.
  2. Open the trendline options. On Windows, click the Chart Elements button (+), point to Trendline, click its arrow, and choose More Options. On macOS, choose Chart Design > Add Chart Element > Trendline > More Trendline Options.
  3. In the Format Trendline pane, under Trendline Options, choose Linear.
  4. Near the bottom of the pane, check Display Equation on chart and Display R-squared value on chart. A label appears that reads about y = 2131.6x + 6344.3 and R² = 0.2182; Excel may show a different number of decimals. Drag the label to a clear area of the chart.

Part D. Calculate the line with functions. The functions return the same line as the trendline, but as cell values that other formulas can use.

  1. Add a worksheet with the + beside the sheet tabs, double-click the new tab, type Model, and press Enter.
  2. In A1 type Inpatient Charges and Length of Stay: Simple Linear Regression, and make it Bold, size 14.
  3. In A3 type Stays; in B3 enter =COUNT(Inpatient[length_of_stay_days]). It shows 8500.
  4. In A4 type Slope; in B4 enter
    =SLOPE(Inpatient[total_charges_usd], Inpatient[length_of_stay_days])
    It shows about 2131.62, the trendline’s 2131.6. The response column comes first.
  5. In A5 type Intercept; in B5 enter
    =INTERCEPT(Inpatient[total_charges_usd], Inpatient[length_of_stay_days])
    It shows about 6344.31.
  6. In A6 type R-squared; in B6 enter
    =RSQ(Inpatient[total_charges_usd], Inpatient[length_of_stay_days])
    It shows about 0.218, the trendline’s 0.2182.
  7. In A7 type Correlation r; in B7 enter
    =CORREL(Inpatient[length_of_stay_days], Inpatient[total_charges_usd])
    It shows about 0.467, the value from Chapter 10. In C7 enter =B7^2; it shows about 0.218, the same as B6.

Part E. Calculate predicted values and residuals. Two calculated columns, as in Chapter 8, give every stay its predicted charge and its residual.

  1. Return to the data sheet. Click AG1, the first empty cell to the right of the headers, type predicted_charges, and press Enter. The Table expands to include column AG.
  2. In AG2 enter =Model!$B$5+Model!$B$4*[@length_of_stay_days]. Excel fills the formula down all 8,500 rows. AG2 shows about 16149.78, the predicted charge for the first stay, which lasted 4.6 days. The dollar signs lock the references to the slope and intercept (Chapter 6), and [@length_of_stay_days] reads the length of stay from the same row.
  3. Click AH1, type residual, and press Enter. In AH2 enter =[@total_charges_usd]-[@predicted_charges]. AH2 shows about -7490.20: the first stay was charged $7,490 less than the line predicts.
  4. On the Model sheet, in A8 type Average residual; in B8 enter =AVERAGE(Inpatient[residual]). Excel shows a tiny number in scientific notation, such as -7.658E-11, which is zero apart from rounding.
  5. With B8 selected, choose Home > Number > Number Format > Number. It now shows 0.00, the zero average that the least-squares method guarantees. (If it shows -0.00, the minus sign comes from the tiny negative value; the average is still zero.)

Part F. Draw the residual plot.

  1. Return to the data sheet. Click the column letter AG and drag to AH to select both new columns.
  2. Choose Insert > Charts > Scatter, as in step 6. Title the chart Residuals against predicted charges, and add the axis titles Predicted charges (USD) and Residual (USD) as in steps 8 and 9. The horizontal axis crosses at zero and serves as the reference line.
    • Confirm with Select Data, as in step 6, that the X values refer to predicted_charges (column AG) and the Y values to residual (column AH).
    • The horizontal axis labels sit at zero, in the middle of the points. To move them to the bottom, right-click the horizontal axis, choose Format Axis, and under Labels set Label Position to Low.
  3. Read the pattern. The points form a fan that widens to the right, as in Figure 12: the prediction errors are larger for stays with high predicted charges.

Part G. Predict and summarize.

  1. On the Model sheet, in A9 type Predicted, 3 days; in B9 enter
    =FORECAST.LINEAR(3, Inpatient[total_charges_usd], Inpatient[length_of_stay_days])
    It shows about 12739.18.
  2. In A10 type Predicted, 6 days; in B10 enter the same formula with 6 in place of 3. It shows about 19134.05.
  3. In A11 type Difference; in B11 enter =B10-B9. It shows about 6394.87, which is three times the slope in B4, because the two stays differ by three days.
  4. In A13 type the summary sentence: Across 8,500 stays admitted January 2024 to December 2025, predicted charges rise by about $2,132 for each additional day of stay (R-squared 0.22), for stays of 0.6 to 37.9 days; this is an association, not the effect of shortening a stay.
  5. Save with Ctrl+S (Cmd+S on macOS). Your Model sheet and the new columns should resemble Figure 18.

Return now to the chief financial officer’s question. Across these 8,500 stays, charges are about $2,132 higher, on average, for each additional day. The line accounts for 22 percent of the variation in charges; the other 78 percent is not explained by length of stay alone. The residual plot shows that the line’s dollar predictions are least precise for long, expensive stays. The ICU stay in Table 1 illustrates the point: its charges sit far above anything the line predicts for a stay of its length, a gap you calculated in the Try It box.

For a budget, the line is useful as an average across many stays, and less useful as a prediction for any single stay. The slope also describes stays as they occurred, not what would happen if stays were shortened. Both limits point to the same next step: more explanatory variables, such as ICU care and surgery, which Chapter 13 adds.

Practice on your own

These exercises reuse the walkthrough’s techniques on new questions. The first is fully guided, like the walkthrough. The second provides less guidance: it names the functions and gives values to check against, but leaves you to assemble the formulas. The third gives only the task: compare three relationships in the wellness screening file and explain each in writing.

Practice A: county diabetes and obesity

Fit a line of the diagnosed diabetes rate on the obesity rate across counties, read its slope, and check its residual plot. The file holds one row for each of 3,143 counties and county equivalents, with rates stated as percentages of adults.

County rates describe counties, not people. A slope fitted to county rates shows how diabetes rates differ between counties with different obesity rates; it does not show how one person’s diabetes risk changes with that person’s weight. Reading a group-level association as an individual one is the ecological fallacy, a term that comes from a classic study showing that correlations between group rates can differ sharply from the correlations among the individuals in those groups (Robinson, 1950).

  1. Open datasets/PH1_places_county_wide.csv, then choose File > Save As and save a copy named ch12_counties.xlsx.
  2. Click any cell inside the data, choose Insert > Table, confirm My table has headers, and click OK. On the Table Design tab, set the Table Name to Places, the name Chapter 11 used for the same file.
  3. Click the column letter G (obesity_pct) and drag to H (diagnosed_diabetes_pct). Choose Insert > Charts > Scatter.
  4. Title the chart County diagnosed diabetes and obesity, and add the axis titles Adults with obesity (%) and Adults with diagnosed diabetes (%).
  5. Read the four features: direction, form, strength, and unusual points.
  6. Add a Linear trendline with Display Equation on chart and Display R-squared value on chart, as in Part C. The label reads about y = 0.4523x - 0.4058 and R² = 0.6145.
  7. Add a worksheet named Model. In A3 type Counties; in B3 enter =COUNT(Places[obesity_pct]). It shows 3143.
  8. In A4 type Slope; in B4 enter =SLOPE(Places[diagnosed_diabetes_pct], Places[obesity_pct]). It shows about 0.4523.
  9. In A5 type Intercept; in B5 enter =INTERCEPT(Places[diagnosed_diabetes_pct], Places[obesity_pct]). It shows about -0.4058.
  10. In A6 type R-squared; in B6 enter =RSQ(Places[diagnosed_diabetes_pct], Places[obesity_pct]). It shows about 0.614.
  11. Return to the data sheet. Click T1, type predicted_diabetes, and press Enter. In T2 enter =Model!$B$5+Model!$B$4*[@obesity_pct]. T2 shows about 14.79, the predicted rate for Cleburne County, Alabama, whose obesity rate is 33.6 percent.
  12. Click U1, type residual, and press Enter. In U2 enter =[@diagnosed_diabetes_pct]-[@predicted_diabetes]. U2 shows about 2.41.
  13. On the Model sheet, in A7 type Average residual; in B7 enter =AVERAGE(Places[residual]), and format it as Number. It shows 0.00.
  14. On the data sheet, select columns T and U, choose Insert > Charts > Scatter, and title the chart Residuals against predicted diabetes rate. Name the pattern it shows, using the four patterns in Figure 11.
  15. On the Model sheet, in A8 type Predicted, 30% obesity; in B8 enter =FORECAST.LINEAR(30, Places[diagnosed_diabetes_pct], Places[obesity_pct]). It shows about 13.16.
  16. In A9 type Predicted, 40% obesity; in B9 enter the same formula with 40 in place of 30. It shows about 17.69.
  17. Write two sentences: one that interprets the slope for a 10-point difference in obesity rates, and one that states what the R-squared means. Compare your chart with Figure 20 and save.
Figure 20: County diagnosed diabetes rates against obesity rates for 3,143 counties, with the least-squares line: predicted diabetes % = −0.41 + 0.45 × obesity %, R² = 0.61. Source: datasets/PH1_places_county_wide.csv, synthetic county estimates modeled on CDC PLACES, release year 2025.

Practice B: blood pressure and age in the registry

Fit a line of systolic blood pressure on age for the patients in the registry, with less guidance. This exercise names the functions and gives you values to check against, but leaves the formulas for you to build.

Goal: a scatterplot with a fitted line, and a Model sheet that reports the count, slope, intercept, R-squared, correlation, and two predictions for the line of bp_systolic_last on age. The bp_systolic_last column holds each patient’s most recent systolic blood pressure (BP), in millimeters of mercury (mmHg).

  1. Open datasets/DS7_registry_clean.csv, save a copy named ch12_registry.xlsx, and convert the data to a Table named Registry.
  2. Draw a scatterplot of systolic blood pressure against age, with a linear trendline that displays its equation and R-squared.
    • The two columns are not next to each other: age is column G and bp_systolic_last is column V. Select them as in step 5 of the walkthrough, with age first, and confirm with Select Data that the X values refer to age, as in step 6.
  3. On a Model sheet, calculate the count, slope, intercept, R-squared, and correlation with COUNT, SLOPE, INTERCEPT, RSQ, and CORREL.
    • Remember the argument order: the response column, Registry[bp_systolic_last], comes first.
  4. Use FORECAST.LINEAR to predict systolic blood pressure at ages 40 and 70.
  5. Write two sentences: one that interprets the slope per decade of age, and one that explains what the R-squared does and does not say about age and blood pressure.
    • Check your work: the count is 10,000, the slope about 0.2046 mmHg per year (about 2.0 per decade), the intercept about 113.91, R-squared about 0.060, and the correlation about 0.245. The predictions are about 122.10 mmHg at age 40 and 128.24 at age 70. Your chart should resemble Figure 21.
    • The intercept is the predicted pressure at age 0, but the registry holds only adults aged 18 to 90, so it is an extrapolation and has no clinical meaning. The low R-squared means age accounts for about 6 percent of the variation in blood pressure; the remaining 94 percent is not explained by this line. The positive direction of the slope agrees with national survey data showing that high blood pressure becomes more common with age, although those data do not establish the size of the slope (Fryar et al., 2017).
Figure 21: Most recent systolic blood pressure against age for 10,000 registry patients, with the least-squares line: predicted systolic BP = 113.9 + 0.20 × age, R² = 0.06. Ages are whole years, spread slightly sideways so the points do not overlap. Source: datasets/DS7_registry_clean.csv, registry as of December 31, 2025.

Practice C: compare three relationships in the wellness screening file

Open datasets/DS9_wellness_screening.csv, the file of 100 adults introduced with Figure 4, and compare the following three pairs of columns. None of these pairs appears in that figure, so you discover each relationship yourself. In each pair, the first column is the response variable and the second is the explanatory variable.

  • Pair 1: body weight in kilograms (weight_kg, column P) and waist circumference in centimeters (waist_cm, column E).
  • Pair 2: high-density lipoprotein (HDL) cholesterol in milligrams per deciliter, mg/dL (hdl_cholesterol, column R), and waist circumference in centimeters (waist_cm, column E).
  • Pair 3: vitamin D level in nanograms per milliliter, ng/mL (vitamin_d, column T), and height in centimeters (height_cm, column O).

For each pair:

  1. Create a scatterplot with the explanatory variable on the horizontal axis.
  2. Add a linear trendline that displays its equation and R-squared.
  3. Calculate r with CORREL.
  4. Write one or two sentences that explain the relationship:
    • its direction (positive, negative, or no meaningful straight-line relationship),
    • its strength, using r,
    • what the slope means in the units of the data,
    • how much of the variation the line accounts for, using R-squared.

Then, for all three pairs together:

  1. Write two sentences that compare the pairs: which relationship is strongest, which is negative, and which shows no meaningful straight-line relationship.

The following model is illustrative, not drawn from the book’s datasets. An analyst fits a simple linear regression across 40 outpatient clinics, with each clinic’s average patient-experience score (0 to 100) as the response and its average wait time in minutes as the explanatory variable. The clinics’ average waits range from 10 to 55 minutes. The line is predicted score = 92.0 − 0.45 × wait minutes, with an R-squared of 0.38.

  1. Interpret the slope in one sentence, with units.
  2. Calculate the predicted score for a clinic with a 20-minute wait and for one with a 40-minute wait, and state the difference.
  3. Say whether the intercept, 92.0, describes any of the 40 clinics, and why.
  4. A manager asks for the predicted score of a clinic with a 90-minute wait. State what you would tell the manager.
  5. Explain what an R-squared of 0.38 indicates, and identify one limitation of its interpretation.

The answer key is at the end of the chapter.

Modeling the logarithm of a skewed response. When a response is right-skewed, as inpatient charges are, analysts often fit the line to the natural logarithm of the response instead of the response itself (Gelman et al., 2020). The natural logarithm is a scale on which equal steps represent equal percentage changes rather than equal dollar amounts, so a stay charged $20,000 and one charged $40,000 sit the same distance apart as stays charged $40,000 and $80,000. In Excel, a calculated column with =LN([@total_charges_usd]) holds the logarithm, and SLOPE and INTERCEPT fit the line as before. For the Riverbend stays, the slope on the log scale is 0.1015. Converted with =EXP(0.1015)-1, it says that each additional day is associated with charges about 10.7 percent higher, a percentage change rather than a fixed dollar amount. The R-squared on the log scale, 0.217, measures fit to the logarithm of charges, a different response, so it cannot be compared with the 0.218 for dollars. The residual plot is the better guide: the SD of the residuals is nearly the same in each third of the predicted values, so the fan in Figure 12 largely disappears. The trade-off is interpretation: results on the logarithmic scale must be converted back to dollars before they are reported.

The Analysis ToolPak’s Regression tool. The Data > Data Analysis > Regression command, from the add-in introduced in Chapter 3, fits the same line and writes a full output table (Microsoft, n.d.-f). Its Coefficients column repeats the intercept and slope from Part D, R Square repeats B6, and the Residuals option writes the residual column from Part E. The table also reports a standard error, a p-value, and a 95 percent confidence interval for each coefficient, which apply Chapter 10’s ideas to the slope. Those columns assume residuals of even spread, so with a fan like Figure 12, read them with caution. Chapter 13 reads them when it adds more explanatory variables.

The following is an illustrative scenario, not a specific organization. A hospital’s finance committee reviews the charges line and a manager proposes a target: discharge every patient one day earlier and save about $2,132 per stay. The proposal treats the slope as the effect of an intervention. The slope compares stays of different lengths across many patients; it does not measure what one patient’s charges would be if that patient left a day sooner. Long stays tend to belong to sicker patients who also receive more intensive services, so part of the $2,132 may reflect severity rather than the added days. Charges are also not costs, so even an accurate reduction in charges would not translate dollar for dollar into savings. Discharging a patient before the patient is clinically ready could also carry its own risks, including a return to the hospital. The analyst reframes the result for the committee: “Across our stays, each additional day is associated with about $2,132 more in charges. That figure does not show what shortening a stay would save. Chapter 13’s methods, which hold severity and ICU care constant, are the next step toward that question.”

  • A scatterplot comes first: read its direction, form, strength, and unusual points, because a line and its summary numbers describe only the straight-line part of a relationship.
  • Simple linear regression fits predicted response = intercept + slope × explanatory variable by least squares, the line that makes the sum of the squared residuals as small as possible; SLOPE, INTERCEPT, RSQ, and the chart trendline all return it.
  • The slope is the change in the predicted response for each one-unit increase in the explanatory variable, read in the data’s units; the intercept is meaningful only when zero lies within the data.
  • A residual is actual minus predicted; a residual plot should show a patternless band, and a curve, a fan, or a distant point signals that a straight line does not adequately represent the pattern.
  • R-squared is the share of variation the line accounts for and equals r squared; it measures fit, not correctness or cause. Predictions beyond the data’s range are extrapolations, a few influential points can move the slope, and a slope describes an association, not the effect of changing the explanatory variable.
  1. For each of the six scatterplots in Figure 22, state the direction, form, and strength, and say whether a straight line would describe the points adequately. Name the plot with a point that would change the slope most if it were removed, and the plot whose residual plot would show a fan.
Figure 22: Six simulated scatterplots, labeled A to F, for exercise 1. Source: concept schematic with simulated data.
  1. Open datasets/DS9_wellness_screening.csv and draw four scatterplots: grip strength (grip_strength_kg, column Q) against age (age, column B); HDL cholesterol (hdl_cholesterol, column R) against weekly exercise (exercise_hours_week, column H); screen time (screen_time_hours, column S) against sleep (sleep_hours, column M); and weight (weight_kg, column P) against height (height_cm, column O). Add a linear trendline to each that displays its equation and R-squared, calculate r for each pair with CORREL, and describe each relationship by its direction, form, and strength. For which pair does a straight line misdescribe the points, and how can you tell from the scatterplot?
  2. Using the line for HDL cholesterol on waist circumference from Practice C, predicted HDL = 113.61 − 0.594 × waist in centimeters, state the change in predicted HDL cholesterol for a waist 10 centimeters larger, and explain why the intercept should not be read as the HDL cholesterol of a person with a waist of 0 centimeters. If waist were recorded in inches (1 inch = 2.54 centimeters), what would the slope be, and would R-squared change?
  3. An 8-day stay was charged $30,000. Using the walkthrough’s line, calculate the predicted charge and the residual, and state whether the line over-predicted or under-predicted this stay.
  4. Draw the residual plot for the county line in Practice A, and compare it with the residual plot for the charges line in Figure 12. For which of the two lines could you report a single typical prediction error, such as =STDEV.S of the residuals, without qualification? Explain why, using the pattern each residual plot shows.
  5. A report on clinic data gives a fitted line with a negative slope and an R-squared of 0.09, and a colleague concludes that the two measures are unrelated. Calculate r, including its sign, and write a two-sentence reply.
  6. A county health official reads the Practice A line and writes: “If our county lowers its obesity rate by 10 percentage points, its diabetes rate will fall by 4.5 points, and a county with 60 percent obesity should expect a diabetes rate of about 27 percent.” Identify three problems with this statement, drawing on extrapolation, association versus cause, and the ecological fallacy, and rewrite it as an accurate statement.

Try It (residuals by hand). For IPD007584, the predicted charge is $6,344.31 + $2,131.62 × 12 = $31,923.75, and the residual is $30,974.13 − $31,923.75 = −$949.62; the stay was charged about $950 less than predicted. For IPD005645, the predicted charge is $6,344.31 + $2,131.62 × 5.7 = $18,494.54, and the residual is $124,953.57 − $18,494.54 = +$106,459.03. The line describes the 12-day stay well, missing it by about 3 percent of its charges, and misses the cardiology stay by more than $106,000. The table shows one feature the line does not take into account: the stay included ICU care. (With unrounded coefficients, Excel gives residuals of −$949.66 and +$106,459.01.)

Try It (wait-time model). (1) For each additional minute of average wait, a clinic’s predicted patient-experience score is 0.45 points lower. (2) At 20 minutes the prediction is 92.0 − 0.45 × 20 = 83.0; at 40 minutes it is 92.0 − 0.45 × 40 = 74.0; the difference, −9.0 points, equals 20 minutes times the slope. (3) No: no clinic has a zero-minute wait, and the observed waits start at 10 minutes, so the intercept only anchors the line. (4) The line’s prediction, 92.0 − 0.45 × 90 = 51.5, is an extrapolation far beyond the longest observed wait of 55 minutes, and the data cannot show whether the straight line holds there; the analyst should decline to report it as a prediction. (5) Average wait accounts for 38 percent of the variation in clinic scores, and the other 62 percent is not explained by this line; the R-squared does not show that shorter waits would raise scores, and because the data describe clinics, it says nothing directly about individual patients.

Practice A interpretation. The scatterplot shows a positive direction, a straight form, and moderately strong clustering, with short horizontal rows of points at the 4 and 24 percent limits on the diabetes rate. The slope, about 0.45, means that a county with an obesity rate 10 percentage points higher has a predicted diagnosed diabetes rate about 4.5 points higher. The R-squared of 0.61 means obesity rates account for about 61 percent of the variation in diabetes rates across these counties.

The residual plot shows a band of roughly even width with no curve or fan; the SD of the residuals is about 2.2 to 2.3 points in each third of the predicted values. The intercept, -0.41, would be a negative diabetes rate at zero obesity, which is impossible and also outside the observed obesity rates of 15 to 52 percent: an extrapolation. These are synthetic county rates, and the association describes counties, not individuals.

Practice B interpretation. Each additional year of age is associated with a predicted systolic pressure about 0.20 mmHg higher, or about 2 mmHg per decade. Age accounts for about 6 percent of the variation in blood pressure. The remaining 94 percent is not explained by this line; it may reflect other patient characteristics, measurement variation, or chance. A low R-squared does not mean the slope is absent or unimportant.

Practice C interpretation. Check values: weight on waist, slope 1.649, intercept -76.00, R-squared 0.706, r 0.840; HDL cholesterol on waist, slope -0.594, intercept 113.61, R-squared 0.262, r -0.512; vitamin D on height, slope -0.032, intercept 36.22, R-squared 0.001, r -0.024. Example sentences, which yours need not match word for word:

  • Weight and waist: “Across 100 adults, body weight is higher by about 1.65 kilograms for each additional centimeter of waist circumference; r is 0.84, a strong positive relationship, and the line accounts for about 71 percent of the variation in weight.”
  • HDL cholesterol and waist: “Across 100 adults, HDL cholesterol is lower by about 0.59 mg/dL for each additional centimeter of waist circumference; r is −0.51, a moderate negative relationship, and the line accounts for about 26 percent of the variation in HDL cholesterol.”
  • Vitamin D and height: “Across 100 adults, vitamin D level shows no meaningful straight-line relationship with height; r is −0.02, and the line accounts for less than 1 percent of the variation.”

Comparison: weight and waist is the strongest relationship; HDL cholesterol and waist is the negative one, of moderate strength; and height has no meaningful straight-line relationship with vitamin D, so its slope of −0.03 ng/mL per centimeter should not be interpreted. In the first two scatterplots, one participant (WS035) sits far to the right of the others, a high-leverage point worth noting. All three are associations in synthetic data, not causes.

Exercises.

  1. A: positive, straight, strong; a line is adequate. B: negative, roughly straight, weak; a line is adequate but explains little. C: a curve that rises and then falls, so a straight line misdescribes it even though the points follow a clear pattern. D: no direction and no pattern; a line would show a slope near zero. E: positive and roughly straight, but the spread widens to the right, so its residual plot would show a fan. F: positive, straight, and strong, except for one point far to the right and below the pattern; that high-leverage point would change the slope most if removed, as in Anscombe’s dataset D.
  2. Grip strength and age: predicted grip = 45.10 − 0.111 × age, R² = 0.142, r = −0.377. The r suggests a moderate negative relationship, but the scatterplot shows a curve: grip strength rises from the twenties to a peak around age 45 and then falls, so the straight line misdescribes the points at both ends. HDL cholesterol and exercise: predicted HDL = 51.88 + 1.981 × exercise hours, R² = 0.164, r = 0.405: moderate and positive. Screen time and sleep: predicted screen time = 8.34 − 0.364 × sleep hours, R² = 0.063, r = −0.252: weak and negative. Weight and height: predicted weight = −84.57 + 0.968 × height, R² = 0.174, r = 0.417: moderate and positive; the negative intercept is an extrapolation to a height of 0 centimeters and has no meaning. Excel may display the trendline coefficients with different rounding.
  3. A waist 10 centimeters larger is associated with predicted HDL cholesterol about 5.9 mg/dL lower (10 × −0.594). The intercept, 113.6 mg/dL, is the prediction for a waist of 0 centimeters, far outside the observed waists of 79 to 133 centimeters, so it is an extrapolation with no meaning. In inches, the slope would be −0.594 × 2.54, about −1.51 mg/dL per inch; R-squared would stay at 0.262, because it does not depend on the units.
  4. The predicted charge is $6,344.31 + $2,131.62 × 8 = $23,397.27 (Excel: $23,397.30). The residual is $30,000 − $23,397.27 = +$6,602.73. The residual is positive, so the line under-predicted this stay.
  5. The county residual plot shows a band of roughly even width, with residual SDs of about 2.3, 2.2, and 2.3 points in the three thirds of predicted values, so one overall figure, about 2.25 points, describes its typical error fairly at every level. The charges residual plot is a fan, with residual SDs rising from about $9,614 to $19,004, so a single overall figure would overstate the line’s precision for long stays and understate it for short ones; it needs to be stated by range.
  6. r is the square root of 0.09, which is 0.30, and it takes the sign of the slope, so r = −0.30. Reply: “An R-squared of 0.09 means the line accounts for about 9 percent of the variation, so 91 percent is not explained by this line. An r of −0.30 is still a weak negative relationship, so the measures are associated, though not strongly.”
  7. Three problems: (1) a 60 percent obesity rate lies outside the observed range of 15 to 52 percent, so the 27 percent prediction is an extrapolation; (2) the slope compares counties with different obesity rates and does not show what would happen if one county’s rate changed, which is a causal claim; and (3) because these are county rates, the line says nothing about individual people, the ecological fallacy. An accurate statement: “Across these counties, those with obesity rates 10 percentage points higher have diagnosed diabetes rates about 4.5 points higher, on average, within the observed range of 15 to 52 percent. This association does not show how a change in one county’s obesity rate would change its diabetes rate.”
Coefficient of determination
The formal name for R-squared, the share of the variation in the response that a fitted line accounts for.
Confounding variable
A third factor, related to both the explanatory variable and the response, that can create or distort an association between them.
Correlation coefficient (r)
A measure of the strength and direction of the straight-line relationship between two numerical variables, also called Pearson’s r, on a scale from −1 to 1, where 0 means no straight-line relationship.
Dependent variable
Another name for the response variable: the measure a regression line describes or predicts, plotted on the vertical axis.
Ecological fallacy
The error of reading an association observed between groups, such as counties, as if it held for the individuals within them.
Explanatory variable
The measure used to describe or predict the response in a regression, plotted on the horizontal axis; also called the independent variable or predictor.
Extrapolation
The use of a fitted line to predict for values of the explanatory variable outside the range of the data used to fit it.
Independent variable
Another name for the explanatory variable: the measure used to describe or predict the response, plotted on the horizontal axis.
Influential point
A point whose removal noticeably changes the slope or the intercept of a fitted line.
Intercept
The predicted value of the response when the explanatory variable equals zero.
Least-squares line
The line that makes the sum of the squared residuals as small as possible.
Leverage
The potential of a point to tilt a fitted line, high when its value of the explanatory variable is far from the others.
Non-constant spread
A residual pattern in which the residuals scatter farther from zero in one part of the plot than in another.
Outlier (in regression)
A point with a large residual, far above or below the fitted line.
Predicted value
The value of the response that a fitted line gives for a chosen value of the explanatory variable.
R-squared
The share of the variation in the response that a fitted line accounts for, from 0 to 1; in simple linear regression, the square of the correlation coefficient.
Residual
The difference between an observed value of the response and the value the line predicts for it.
Residual plot
A scatterplot of residuals against predicted values, with a reference line at zero, used to judge whether a line describes the data adequately.
Response variable
The measure a regression line describes or predicts, plotted on the vertical axis; also called the dependent variable or outcome.
Simple linear regression
A model that describes a numerical response variable with a straight line in one explanatory variable.
Slope
The change in the predicted response for each one-unit increase in the explanatory variable.
Cite this chapter
@incollection{sher2026ch12,
  author = {Sher, Hoshiar J.},
  title = {Simple Linear Regression for Numerical Outcomes},
  booktitle = {Introduction to Healthcare Data Analytics Using Excel},
  year = {2026},
  doi = {10.5281/zenodo.23327956},
  url = {https://yar177.github.io/intro-to-HDA-site/ch12.html}
}