632 words
3 min read
Visual companion
Python
Type and operator map
Python Week 1: the first filter for runtime behavior
View
Revision summary
What this note is really saying
Short form
# Statistics I · Week 4 — Association and correlation Two variables together: **tables** for categorical pairs, **scatterplots** and **$r$** for numerical pairs. Association is not causation.

Statistics I · Week 4 — Association and correlation
Two variables together: tables for categorical pairs, scatterplots and r for numerical pairs. Association is not causation.
Week map
Two variables → contingency table → marginal totals → scatterplot features → correlation r → strength vs direction → limitations of r.
Contingency table notation
- Contingency table → cross-classified counts → rows = one variable, columns = another.
- Cell → count in one row category AND one column category.
- Marginal total → row or column sum → not joint.
- Joint → specific pair; marginal → one variable alone.
Mini-table (transport × gender, counts):
| Bus | Train | Total | |
|---|---|---|---|
| F | 30 | 20 | 50 |
| M | 25 | 25 | 50 |
| Total | 55 | 45 | 100 |
Cell (F, Train) = 20. Marginal female total = 50.
Scatterplot language
For numerical x and y:
- Direction → positive (upward), negative (downward), none.
- Form → linear, curved, clusters.
- Strength → tight cloud vs scattered.
- Outliers → points off main pattern.
Mini-description: “positive, roughly linear, moderate strength, one high outlier.”
Correlation r
- r → Pearson correlation coefficient → measures linear association.
- Range −1≤r≤1.
- r≈1 → tight increasing line.
- r≈−1 → tight decreasing line.
- r≈0 → weak linear pattern (curved pattern may still exist).
Trap: r is not steepness of slope — standardized measure of linear fit strength/direction.
Properties (linear world):
- Sign of r matches slope of best-fit line.
- r unchanged if you add constant to all x or scale x by positive constant (linear transform).
Association vs causation
Pattern may be due to:
- Direct cause
- Confounding third variable
- Coincidence
Ice cream sales and drowning correlate — weather confounds both.
Pattern families
Easy — Read contingency cell
- Identify joint count.
- Compute marginal from table.
- Percent of total in one cell: cell/n.
Medium — Describe scatter
- State direction, form, strength in words.
- Match sign of r to scatter direction.
- Spot outlier effect on r.
Hard — Interpret r and limits
- Near ±1 vs near 0 interpretation.
- Strong nonlinear pattern with r near 0.
- Do not infer causation from r.
- Categorical coded as numbers — r may mislead.
Worked mini-examples
Example 1 — Cell percent.
From table above: percent female bus riders = 30/100 = 30% of all, or 30/50 = 60% of females.
Example 2 — Scatter words.
Points rise left to right tightly → positive, linear, strong.
Example 3 — r sign.
r=−0.82 → strong negative linear association.
Example 4 — Nonlinear trap.
Parabolic cloud around 0 → r might be near 0 though y clearly depends on x.
Example 5 — Outlier.
Most points tight positive line; one far low point pulls r down.
Traps
- Causation from correlation.
- r for categorical disguised as numbers (zip codes).
- Confusing strength with steep slope.
- Ignoring outliers dominating r.
- Contingency cell vs marginal confusion.
Diagnostic (try yourself)
-
In a 2×3 contingency table, what does a single cell count represent?
-
Describe in words a scatterplot that is negative, linear, and weak.
-
If r=0.15 between study hours and exam score, is linear association strong or weak? Does high score cause more hours?
-
Table: exercise (Low/High) × health (Poor/Good). Low-Poor cell = 40, total n=200. What percent of all cases are Low and Poor?
-
A U-shaped scatter has r≈0. Can y still depend on x? Explain briefly.