📉 Correlation and the best-fit line

A scatter plot, a number for the strength, a line for predictions.

⭐ The one idea

Two measurements per patient → plot them → ask is there a straight-line pattern? r says how strong it is, the best-fit line lets you predict, and none of it proves cause.

📉 Scatter plots

BMI vs systolic BP (10 clinic patients)BMISystolic BP (mmHg)r = 0.98
Positive linear relationship: higher BMI, higher systolic BP. Each dot is one patient. Explanatory variable (x) = BMI; response variable (y) = BP.
Hours since dose vs serum drug levelhoursmcg/mLr = -0.99
Negative linear relationship: as hours pass, the drug level falls. r is close to −1.
Height vs HbA1c — no patternheight (cm)HbA1c (%)r = 0.04
No relationship: the dots are a cloud and r is near 0.

➕ Positive

Up and to the right. BMI & BP, age & number of medications, dose & blood level.

➖ Negative

Down and to the right. Hours since dose & drug level, exercise minutes & resting HR.

❓ None

A shapeless cloud. Height & HbA1c, shoe size & cholesterol.

📏 The correlation coefficient r

How strong is r?-1-0.500.51strong −nonestrong +The sign is the direction, thedistance from 0 is the strength.r = 0 means no straight-linepattern.
r is always between −1 and +1. It has no units and does not change if you switch cm to inches.

📊 What r tells you

  • Sign → direction of the line.
  • |r| near 1 → dots hug the line.
  • |r| near 0 → no linear pattern (a U-shape can still have r ≈ 0).
  • Rough guide: |r| ≥ 0.7 strong, 0.3–0.7 moderate, < 0.3 weak.

🔢 Our examples

BMI vs BP: r = 0.98 strong positive.

Hours vs drug level: r = -0.99 strong negative.

Height vs HbA1c: r = 0.04 essentially none.

🧮 r in Desmos

corr(x₁, y₁) after typing the table — or run the regression and Desmos prints r underneath.

💡 r²

r² = 0.96 means 96% of the variation in BP is explained by the straight-line relationship with BMI. The rest is everything else.

📈 The best-fit (regression) line

✍️ ŷ = mx + b

BP̂ = 1.91·BMI + 71.3
Residual = actual − predictedBMISystolic BP (mmHg)r = 0.98
Residual = actual y − predicted ŷ. The best-fit line is the one that makes the sum of squared residuals as small as possible (least squares). Red = residuals.

🚫 No extrapolating

Our BMIs run 22 to 41. Predicting BP for BMI 60 uses the line where there are no data — don’t.

🚫 Only if r is meaningful

If r is weak, the line predicts badly no matter how neat the equation looks. Check r first.

🚫 Correlation ≠ causation

Hospitals with more nurses have more deaths — because big hospitals take sicker patients. The lurking variable (case mix) drives both. Only an experiment shows cause.

🚫 Outliers move the line

One influential point far out in x can swing the slope. Plot first, calculate second.

🧮 In Desmos: the whole workflow

1+ → table, type x₁ (BMI) and y₁ (BP) columns
2y₁ ~ m x₁ + btilde = regression
3   Desmos shows: r = 0.9822, m = 1.9106, b = 71.335
4m·30 + b= 128.7 predicted BP at BMI 30
5corr(x₁, y₁)= r on its own
⌨️ The tilde ~ is on the keyboard’s function menu, or type it directly. Use x₁ (x then Shift + − then 1 for the subscript, or click the table header) — plain x will not link to the table.

✅ Quick self-check

❓ r = −0.82 between minutes of daily walking and fasting glucose. Describe it.
Strong, negative, linear. More walking, lower glucose. It does not prove walking lowers glucose (people who walk may also eat differently).
❓ Line: weight̂ (kg) = 0.9·(age in months) + 3.4 for infants 0–12 months. Interpret 0.9 and predict at 6 months.
Slope: each month, predicted weight rises 0.9 kg. At 6 months: 0.9(6) + 3.4 = 8.8 kg. Predicting at 36 months would be extrapolation.
❓ Which r shows the strongest relationship: 0.45, −0.78, 0.12, −0.30?
−0.78 — farthest from zero. Sign does not matter for strength.
MAT 300 · built from your own course files (the statistics study guide, the Desmos guide, the formula sheet and the final-exam study questions) with nursing examples. Not a substitute for the textbook — check any number against your own notes before an exam.