Week 2
Lecture 1: One variable at a time (bar charts, histograms, boxplots, mean, median, SD)
Lecture 2: Relationships between two variables (scatterplots, correlation, regression)
2⃣ Scatterplots
Show relationship between two quantitative variables
X-axis: explanatory (independent) variable
Y-axis: response (dependent) variable
Each point = one individual’s data
3⃣ Explanatory vs. Response Variables
Response: outcome measured
Explanatory: variable that influences or explains the response
4⃣ Interpreting Scatterplots
Form: linear, curved, clusters, no pattern
Direction: positive, negative, none
Strength: tightness of pattern
Outliers: points that break the pattern
5⃣ Categorical Variables in Scatterplots
Use color or shape to show categories
Simpson’s Paradox: trend reverses when data is grouped vs. aggregated
6⃣ Correlation (r)
Measures strength & direction of linear relationship
Range: −1 to +1
r > 0 → positive
r < 0 → negative
r = 0 → no linear relationship
Unitless, sensitive to outliers
Does not imply causation
7⃣ Regression Line (Least Squares)
Predicts y from x
Equation: ŷ = b₀ + b₁x
b₁ = slope
b₀ = y-intercept
Minimizes squared vertical distances (residuals)
8⃣ Coefficient of Determination (r²)
r² = % of variation in y explained by x
r² = 1 → perfect prediction
r² = 0 → no predictive power
Example: r² = 0.76 → 76% of y explained by x
9⃣ Residuals
Residual = observed y − predicted ŷ
Residual plot: checks for patterns
Random scatter → good fit
Curved or funnel shape → bad fit
🔟 Outliers vs. Influential Points
Outlier: unusual y-value
Influential: unusual x-value that shifts regression line
1⃣1⃣ Cautions with Regression & Correlation
Always plot data first
Don’t extrapolate beyond data range
Correlation ≠ causation
Averages inflate r and r²
Lurking variables can distort relationships
1⃣2⃣ Simpson’s Paradox
Trend in aggregated data reverses when data is split into groups
Example: Airline delays by city vs. overall
1⃣3⃣ Two-Way Tables (Categorical Data)
Rows: one variable
Columns: another variable
Marginal distribution: totals for one variable
Conditional distribution: distribution of one variable given a value of the other
Use row %, column %, or total % depending on context