Averages, spreads, and relationships

POL 211 · Week 3

Juan F. Tellez

University of California, Davis

October 13, 2026

Last week: an estimate is wrong for two reasons

\[ \text{Estimate} = \text{Estimand} + \text{Bias} + \text{Noise} \]

Bias

Systematic: it shows up in every run of the process

Confounding (income makes democracy look peaceful) and bad measurement

Noise

Random: it changes from sample to sample

More data shrinks it. More (of the same) data never shrinks bias

Last week: we dealt with confounding by comparing within groups

The democracy gap in civil war shrank once we compared democracies and non-democracies with similar incomes

Country-years, 1945–1999; income groups are thirds by GDP per capita. Data: Fearon and Laitin (2003), via the juanr package

That was our first look at “controlling for” something. We’ll look again today

Today

  1. The mean: why we keep comparing averages
  2. Spread: the variance and the standard deviation
  3. Relationships: correlation, and how the average of \(Y\) moves with \(X\)

Plus: a 10-minute break

Why the mean?

We keep comparing averages. Why averages?

Callback rates. Civil war rates. Divorce rates in made-up states. Every estimate so far has been a difference in means

What we really want is to compare the typical unit in each group: is the typical treated unit better or worse off than the typical untreated one?

Why should the mean be our stand-in for “typical”? Why not the mode, or the median? Why not the minimum or maximum?

The median callback is zero for both groups

Three summaries of callbacks by name. Data: Bertrand and Mullainathan (2004), via Imai and Williams (2022)
Name on résumé Mean Median Most common value (mode)
African American-sounding 0.064 0 0
White-sounding 0.097 0 0

Medians, modes, max, min don’t allow comparison for binary outcomes

A 0/1 outcome is the extreme case. But the question is general: what makes a number “typical”?

The mean adds everything up and divides by \(n\)

\[ \sum_{i=1}^{n} Y_i = Y_1 + Y_2 + \cdots + Y_n \]

Read it as: “the sum of \(Y_i\), for \(i\) from 1 to \(n\)”

The mean is that sum, divided by \(n\):

\[ \bar{Y} = \frac{1}{n} \sum_{i=1}^{n} Y_i \]

Three Senate races with 1, 2, and 6 million votes cast (made-up numbers): \(\sum Y_i = 9\), so \(\bar{Y} = 9/3 = 3\)

A weighted average lets some units count more than others

The ordinary mean gives every unit the same say. A weighted average gives unit \(i\) a weight \(w_i\):

\[ \bar{Y}_w = \frac{\sum_{i=1}^{n} w_i Y_i}{\sum_{i=1}^{n} w_i} \]

Three races with 1, 2, and 6 million votes, but count the third race twice (weights 1, 1, 2):

\[ \bar{Y}_w = \frac{1 \times 1 + 1 \times 2 + 2 \times 6}{1 + 1 + 2} = \frac{15}{4} = 3.75 \qquad \text{vs. the ordinary mean, } 3 \]

What happens when every \(w_i\) = 1?

Sampling weights: underrepresented groups count more

A town is half under 40, half over 40. Our poll of 100 people reached 20 under 40 and 80 over 40

A made-up poll that reached too few young people. Made-up numbers
Group Share of the town Share of the poll Support Weight = town share / poll share
Under 40 50% 20% 70% \(0.5 / 0.2 =\) 2.5
Over 40 50% 80% 40% \(0.5 / 0.8 =\) 0.625

Unweighted: \(\frac{20 \times 70 + 80 \times 40}{100} =\) 46%, too close to what older people think

Weighted: \(\frac{20 \times 2.5 \times 70 + 80 \times 0.625 \times 40}{20 \times 2.5 + 80 \times 0.625} = \frac{3500 + 2000}{100} =\) 55%, the answer the whole town would give

In R: weighted.mean(support, w = weight). Every serious poll does this

So what makes the mean the best “typical” value?

Write every race’s number of votes on a slip of paper, put the slips in a box, shake it, and draw one. What single number is your best guess for the slip you’ll draw? (Gailmard 2014)

Call your guess \(g\). Whatever you pick, you’ll usually be off. For slip \(i\), the miss is \(Y_i - g\)

Which guess counts as “best” depends on how we summarize misses

If we score each miss by its square, \((Y_i - g)^2\), the guess with the smallest average miss turns out to be the mean of Y → \(\bar{Y}\)

Let’s see why →

A guess misses each slip by some amount

Back to three races with 1, 2, and 6 million votes. Say we guess 4 million for whichever slip we draw

One guess for three made-up races, and how far it misses each one
Race Votes cast, \(Y_i\) Guess, \(g\) Miss, \(Y_i - g\)
A 1 4 \(-3\)
B 2 4 \(-2\)
C 6 4 \(+2\)

We want one number that says how bad this guess is overall. What should it be?

Misses cancel out, so we square them

Two guesses for three made-up races
Guess \(g\) Votes cast, \(Y_i\) Misses, \(Y_i - g\) Sum of the misses Squared misses Sum of the squares
4 \(1, 2, 6\) \(-3, -2, +2\) \(-3\) \(9, 4, 4\) 17
3 \(1, 2, 6\) \(-2, -1, +3\) \(0\) \(4, 1, 9\) 14

Adding raw misses fails: a guess of 3 misses every race, yet its misses sum to zero

Squaring fixes it: squares are never negative, so misses can’t cancel (what’s an alternative to squaring?)

Mean squared error is a mean of errors that were squared

We score guesses using the mean squared error (MSE)

\[ \text{MSE}(g) = \frac{1}{n} \sum_{i=1}^{n} (Y_i - g)^2 \]

Step Piece Read it as
1 \(Y_i - g\) How far the guess misses slip \(i\)
2 \((\ldots)^2\) Square that miss
3 \(\sum_{i=1}^{n}\) Add up the squared misses for all \(n\) slips
4 \(\frac{1}{n}\) Divide by \(n\): the average squared miss

it’s a sum of \(n\) things divided by \(n\), a mean, so the name says exactly what it is

Try every guess: the mean sits at the bottom of the MSE curve

MSE at eight guesses. Data: 1, 2, and 6 million votes (made-up)
Guess \(g\) MSE(\(g\))
0 13.67
1 8.67
2 5.67
3 4.67
4 5.67
5 8.67
6 13.67
7 20.67

The curve is a bowl with one bottom, at 3: the mean. Every other guess does worse

Finding the bottom of a curve is everywhere in quant methods

Might feel like over-kill for motivating the average, but MSE shows up everywhere:

Where finding the lowest (or highest) point of a curve shows up
Where The curve We look for its…
Today MSE of a single guess Bottom: the mean
Later today MSE of every possible straight line Bottom: the regression line (“least squares”)
Week 8 An estimator’s MSE = bias2 + variance Bottom: the best tradeoff between bias and noise
POL 212 MSE of lines with many variables Bottom, found with calculus and matrices
POL 213 The likelihood of the data Top: maximum likelihood
Machine learning Prediction error Bottom, by walking downhill step by step

Property 1: misses from the mean always add up to zero

\[ \sum_{i=1}^{n} (Y_i - \bar{Y}) = 0 \]

For 1, 2, and 6, the misses from the mean (3) are \(-2\), \(-1\), and \(+3\). They add up to zero


So what?

The mean is the balance point of the data: misses above it exactly cancel misses below it

Property 2: multiply every value by \(k\), and the mean is multiplied by \(k\)

\[ \text{If } X_i = k \times Y_i \text{ for every unit, then } \bar{X} = k \times \bar{Y} \]

resume |>
  group_by(race) |>
  summarize(as_share = mean(call),             # callback as a 0/1
            as_percent_k_y = mean(100 * call), # mean of k * Y
            as_percent_k_ybar = mean(call) * 100)     # k * Y_bar
# A tibble: 2 × 4
  race  as_share as_percent_k_y as_percent_k_ybar
  <chr>    <dbl>          <dbl>             <dbl>
1 black   0.0645           6.45              6.45
2 white   0.0965           9.65              9.65

So what?

Units follow the data. The résumé gap is 0.032 as a share or 3.2 as percentage points: the same finding. Dollars to euros, shares to percents, thousands to millions: means (and differences in means) rescale by the same factor

Property 3: add \(k\) to every value, and the mean moves by \(k\), but differences don’t

\[ \text{If } X_i = Y_i + k \text{ for every unit, then } \bar{X} = \bar{Y} + k \]

Why: adding \(k\) to all \(n\) values adds \(n \times k\) to the sum; dividing by \(n\) leaves \(k\)

wars |>
  group_by(oil) |>                                  # 1 = oil exporter
  summarize(polity = mean(polity2),                 # Polity runs from -10 to 10
            polity_0_to_20_ky = mean(polity2 + 10),    # mean of Y + k
            polity_0_to_20_ky_bar = mean(polity2) + 10)    # Y-Bar + k
# A tibble: 2 × 4
    oil polity polity_0_to_20_ky polity_0_to_20_ky_bar
  <dbl>  <dbl>             <dbl>                 <dbl>
1     0  0.188             10.2                  10.2 
2     1 -3.87               6.13                  6.13

So what?

Shifting a scale moves every average, but the gap between groups doesn’t budge: the \(+k\) cancels in the subtraction. Lets you scale variables to make them more interpretable

What if we dropped the sign instead of squaring?

We squared to stop misses from canceling. Another way is the absolute value, \(\lvert Y_i - g \rvert\): every miss counts by its size

\[ \text{MAE}(g) = \frac{1}{n} \sum_{i=1}^{n} \lvert Y_i - g \rvert \qquad \text{(mean absolute error)} \]

It turns out that the winner on MAE is not the mean, but the median

Let’s look at some real data to test this out

Do voters pick the candidate who looks competent?

Todorov et al. (2005) showed people the faces of two Senate candidates for one second and asked: who looks more competent?

The first 6 of 119 Senate races, 2000–2006. Data: Todorov et al. (2005), via Imai and Williams (2022)
Year State Winner Loser % picking the Democrat’s face Democrat’s % of the vote
2000 CA Feinstein Campbell 56 60.5
2000 DE Carper Roth 34 56.0
2000 FL Nelson McCollum 61 52.5
2000 GA Miller Mattingly 54 59.8
2000 HI Akaka Carroll 68 74.8
2000 IN Lugar Johnson 32 32.5

The candidate whose face looked more competent won 72% of these races

How many people vote in a typical Senate race?

119 Senate races, 2000–2006. Data: Todorov et al. (2005), via Imai and Williams (2022)

Your turn: mean vs. median, squared vs. absolute

Download face.csv into your data/ folder

face = read_csv(here("data", "face.csv")) |>
  mutate(total_votes = (d.votes + r.votes) / 1e6)   # votes cast, in millions

my_guess = 2   # try the mean, the median, and anything else

face |>
  summarize(mse = mean((total_votes - my_guess)^2),    # mean squared error
            mae = ???)   # mean absolute error
  1. Find the mean and the median of total_votes
  2. Score each one on MSE and on MAE. Which wins on which?
  3. Convince yourself that other guesses aren’t as good

The mean wins on squared error; the median wins on absolute error

Scoring two guesses for votes cast in 119 Senate races (lower is better). Data: Todorov et al. (2005), via Imai and Williams (2022)
Guess Value MSE MAE
The mean 1.89 million 3.43 1.360
The median 1.34 million 3.72 1.303

Try every guess: each score bottoms out in a different place

The mean (1.89 million) has the smallest MSE. The median (1.34 million) has the smallest MAE

Squaring pays more attention to “outliers”

Squaring means that all errors don’t count the same: large errors become especially “important”

Three races (1, 2, and 6 million votes: mean 3, median 2). Add a fourth. What happens to the mean and the median?

The cost of a miss under the two scoring rules
Miss Absolute (MAE) Squared (MSE)
1 1 1
2 2 4
4 4 16
17 17 289

A few huge states pull the mean far above the median

Squaring makes big misses count a lot, so the mean chases California and Texas. The median doesn’t care how big they are

Remember: the mean turns two group summaries into an average effect

Week 1: the average of the differences equals the difference of the averages. That’s what let us learn an average effect from two groups

Minutes to get to campus, from week 1. Made-up numbers
Bike Bus Bus \(-\) bike
You 10 20 10
Your roommate 15 15 0
Your friend 20 40 20
Average 15 25 10
Median 15 20 10

Difference of the averages: \(25 - 15 = 10\) ✓

Difference of the medians: \(20 - 15 = 5\), but the median of the differences is 10 ✗

So why the mean, and not the median?

Use the mean when you want to… Use the median when you want to…
Estimate an effect. Only averages combine: the difference of the means is the mean of the differences Describe a typical unit in skewed data: income, wealth, house prices, campaign money
Measure uncertainty. One smooth bottom to find; the central limit theorem gives its standard error (week 7) Resist outliers and data errors. A few wild values barely move it
Add things up. Mean × \(n\) = the total: votes, spending, deaths Study the middle of a distribution, not its average (median regression)

When the two disagree, report both: the gap tells you about skew. Running for Congress, the median candidate raised $15k; the mean, $641k. Data: Bonica (2014), via the juanr package

Let’s take a 10-minute break

Spread

Same typical income, very different spread

Median household income, 2009–2013, in 99 Iowa counties and 134 Virginia counties and independent cities. Dashed lines: each state’s average. Data: US Census Bureau, via the socviz package

The averages are close: $49k and $52k. But Iowa’s counties huddle around theirs, while Virginia’s run from $28k to $122k

To measure spread, start with each county’s distance from the average

Three Virginia counties: the poorest, one in the middle, and the richest. Data: US Census Bureau, via the socviz package
County Income State average Distance, \(Y_i - \bar{Y}\)
Martinsville city $28k $52k -24k
Surry County $47k $52k -5k
Loudoun County $122k $52k +70k

How far is each county from the average county in its state?

Average the distances? They always add up to zero (property 1 of means): the counties above cancel the ones below

So we do what we did for the MSE: square the distances, then average them

The variance is the average squared distance from the mean

\[ \text{Var}(Y) = \frac{1}{n} \sum_{i=1}^{n} (Y_i - \bar{Y})^2 \]

Step Piece Read it as
1 \(Y_i - \bar{Y}\) How far county \(i\) sits from the average
2 \((\ldots)^2\) Square that distance
3 \(\sum_{i=1}^{n}\), \(\frac{1}{n}\) Add them up and divide by \(n\): the average squared distance

Iowa: 35. Virginia: 367. In thousands of dollars, squared. What’s a squared dollar?

The standard deviation puts spread back in dollars

\[ \text{SD}(Y) = \sqrt{\text{Var}(Y)} \]

Shaded: one standard deviation on either side of each state’s average. Data: US Census Bureau, via the socviz package

A typical Iowa county sits about $5.9k from its state’s average; a typical Virginia county, about $19.1k

Your turn: build the SD by hand

face = face |>
  mutate(d_share = 100 * d.votes / (d.votes + r.votes))   # Democrat's % of the vote
  1. Use mutate() to find each race’s miss from the mean, then square it
  2. Use summarize() to average the squared misses (the variance), then take the square root with sqrt()
  3. Compare your answer to sd(d_share). It should be the same number.

R’s sd() divides by n – 1, not n

face |>
  mutate(miss = d_share - mean(d_share),       # each race's miss from the mean
         miss_sq = miss^2) |>                   # squared
  summarize(sd_by_hand = sqrt(mean(miss_sq)),  # divides by n
            sd_r = sd(d_share))                 # divides by n - 1
# A tibble: 1 × 2
  sd_by_hand  sd_r
       <dbl> <dbl>
1       14.7  14.7

With 119 races, the two barely differ. Why \(n - 1\)? Later in the course, we’ll see that \(n-1\) is necessary when we’re talking about a sample from a population

A neat result: the variance is the MSE of the mean

Compare the two formulas:

\[ \text{MSE}(g) = \frac{1}{n} \sum_{i=1}^{n} (Y_i - g)^2 \qquad\qquad \text{Var}(Y) = \frac{1}{n} \sum_{i=1}^{n} (Y_i - \bar{Y})^2 \]

The variance is the MSE with the mean plugged in as the guess: \(\text{Var}(Y) = \text{MSE}(\bar{Y})\)

So the variance is the height of the bottom of the MSE curve. For 1, 2, and 6, the curve bottomed out at 4.67: that’s their variance

Spread isn’t a separate idea from the center: it’s how well the center does as a guess

We mostly use spread to say how uncertain an estimate is

Week 1’s standard error is built from each group’s variance and size:

\[ SE = \sqrt{\frac{\text{Var}_{\text{AA}}}{n_{\text{AA}}} + \frac{\text{Var}_{\text{W}}}{n_{\text{W}}}} \]

The pieces of the standard error. Data: Bertrand and Mullainathan (2004), via Imai and Williams (2022)
Name on résumé Résumés Callback rate Variance
African American-sounding 2,435 0.064 0.0603
White-sounding 2,435 0.097 0.0872

\[ SE = \sqrt{\frac{0.0603}{2435} + \frac{0.0872}{2435}} = \mathbf{0.0078} \]

Week 1’s regression table. Data: Bertrand and Mullainathan (2004)
Callback (1)
African American-sounding name -0.032
(0.0078)
Intercept 0.097
(0.0055)
Résumés 4,870

Linear regression. Outcome: callback = 1 if the employer called back, 0 if not. Standard errors in parentheses.

The same number: the table’s standard error is this formula

We’ll see why we use this formula to quantify uncertainty later in the course

But spread can also be the thing we study

When would we want to compare standard deviations?

Concept It’s the spread of…
Political polarization Legislators’ ideology
Inequality Income or wealth
Ruggedness of terrain Elevation
Electoral volatility Parties’ vote shares from one election to the next

For each, the mean misses the point: two countries with the same average income can have very different inequality

Polarization: most of the spread in Congress is between the parties

Members of Congress running in 2012, 2016, and 2018, by party. Data: Bonica (2014), via the juanr package

SD of ideology in all of Congress: 0.45. Within the Democrats: 0.13. Within the Republicans: 0.17

Rugged terrain is a lot of spread in elevation

Two made-up regions with the same average elevation, about 501 meters. Simulated data

Same mean; SDs of 11 and 206 meters. Carter, Shaver, and Wright (2019) argue rugged land kept ethnic groups apart, and that this is part of why rugged countries have more civil war

Relationships

We talk about correlations all the time

Richer countries tend to be democracies

Older people are more likely to vote

Civil wars tend to break out in poor countries

None of these says every rich country is a democracy, or that being rich causes democracy. Each one says two things tend to go together

A correlation is how much two things tend to occur together

“The correlation between two features of the world is the extent to which they tend to occur together.”

— Bueno de Mesquita and Fowler (2021, 13)

When one feature occurs, the other… The two are… Example
tends to occur too positively correlated A country’s income and being a democracy
is no more or less likely uncorrelated A country’s income and the first letter of its name
tends not to occur negatively correlated A country’s income and a civil war breaking out

Two questions to ask of any correlation: which direction, and how strong?

Direction: as one goes up, does the other go up or down?

Each dot is one of 3,112 US counties. Data: US Census Bureau and county election returns, via the socviz package

Denser counties voted more Democratic in 2016; whiter counties voted less Democratic

Strength: how much does knowing one tell you about the other?

Each dot is one of 3,112 US counties. Data: US Census Bureau and county election returns, via the socviz package

Know a county’s 2012 vote and you can guess its 2016 vote closely. Know its commute, and your guess barely improves

With categories, a correlation is a gap between groups

Senate races by whose face looked more competent and who won. Data: Todorov et al. (2005), via Imai and Williams (2022)
Democrat won Republican won
Democrat looked more competent 45 17
Republican looked more competent 16 41

Knowing whose face looked more competent changes our guess about who won. That’s what it means for two variables to be related

A relationship means the average of \(Y\) changes with \(X\)

We write the average of \(Y\) among units with a given value of \(X\) as

\[ E[Y \mid X = x] \]

“The expected value of \(Y\), given that \(X\) equals \(x\)”: the conditional mean

Average vote share by whose face looked more competent. Data: Todorov et al. (2005), via Imai and Williams (2022)
Whose face looked more competent Democrat’s average % of the vote Races
Democrat looked more competent 56.5 62
Republican looked more competent 43.5 57

But competence isn’t yes/no: it takes a different value in almost every race

119 Senate races, 2000–2006. Data: Todorov et al. (2005), via Imai and Williams (2022)

Direction: positive. Strength: somewhere in between. With no groups to compare, how do we put one number on it?

Start with a simpler question: is a race above average on both?

87 of 119 races sit on the same side of both averages: above on both, or below on both. That’s “tend to occur together”

But counting treats a race just past the average like one far out. Covariance weighs each race by how far it sits from both averages

Covariance asks: do \(X\) and \(Y\) miss their averages together?

\[ \text{Cov}(X, Y) = \frac{1}{n} \sum_{i=1}^{n} (X_i - \bar{X})(Y_i - \bar{Y}) \]

Step Piece Read it as
1 \(X_i - \bar{X}\) and \(Y_i - \bar{Y}\) How far unit \(i\) sits from average on \(X\), and on \(Y\)
2 \((\ldots)(\ldots)\) Multiply the two misses
3 \(\sum_{i=1}^{n}\) Add up the products for all \(n\) units
4 \(\frac{1}{n}\) Divide by \(n\): the average product

Same recipe as the variance, except we multiply two different misses instead of squaring one

Six races, before any math

Six of 119 Senate races. X: % picking the Democrat’s face (average 48). Y: Democrat’s % of the vote (average 50). Data: Todorov et al. (2005), via Imai and Williams (2022)
Race X X − X̄ Y Y − Ȳ Product
HI 2004 73 +25 78 +28
NM 2000 75 +27 62 +11
WY 2000 22 -26 23 -27
IN 2000 32 -16 33 -18
IL 2004 16 -32 72 +22
UT 2004 76 +28 30 -21

The dashed lines are the averages. They split the plot into four corners

Above average on both: the product is positive

Six of 119 Senate races. X: % picking the Democrat’s face (average 48). Y: Democrat’s % of the vote (average 50). Data: Todorov et al. (2005), via Imai and Williams (2022)
Race X X − X̄ Y Y − Ȳ Product
HI 2004 73 +25 78 +28 +698
NM 2000 75 +27 62 +11
WY 2000 22 -26 23 -27
IN 2000 32 -16 33 -18
IL 2004 16 -32 72 +22
UT 2004 76 +28 30 -21

Hawaii 2004: 25 points above average on looks, 28 above on votes. 25 × 28 ≈ +698: it pushes the covariance up

Below average on both: also positive (a minus times a minus)

Six of 119 Senate races. X: % picking the Democrat’s face (average 48). Y: Democrat’s % of the vote (average 50). Data: Todorov et al. (2005), via Imai and Williams (2022)
Race X X − X̄ Y Y − Ȳ Product
HI 2004 73 +25 78 +28 +698
NM 2000 75 +27 62 +11
WY 2000 22 -26 23 -27 +703
IN 2000 32 -16 33 -18
IL 2004 16 -32 72 +22
UT 2004 76 +28 30 -21

Wyoming 2000: -26 on looks, -27 on votes. Two negatives make a positive: +703. Low with low also pushes the covariance up

Above on one, below on the other: the product is negative

Six of 119 Senate races. X: % picking the Democrat’s face (average 48). Y: Democrat’s % of the vote (average 50). Data: Todorov et al. (2005), via Imai and Williams (2022)
Race X X − X̄ Y Y − Ȳ Product
HI 2004 73 +25 78 +28 +698
NM 2000 75 +27 62 +11
WY 2000 22 -26 23 -27 +703
IN 2000 32 -16 33 -18
IL 2004 16 -32 72 +22 -687
UT 2004 76 +28 30 -21

Illinois 2004: -32 on looks, +22 on votes: -687. A race that bucks the pattern pulls the covariance down

Add up all six: the positives outweigh the negatives

Six of 119 Senate races. X: % picking the Democrat’s face (average 48). Y: Democrat’s % of the vote (average 50). Data: Todorov et al. (2005), via Imai and Williams (2022)
Race X X − X̄ Y Y − Ȳ Product
HI 2004 73 +25 78 +28 +698
NM 2000 75 +27 62 +11 +312
WY 2000 22 -26 23 -27 +703
IN 2000 32 -16 33 -18 +287
IL 2004 16 -32 72 +22 -687
UT 2004 76 +28 30 -21 -579

Orange rectangles add, blue ones subtract. These six sum to 734; divided by 6, that’s about 122

Across all 119 races, weighted by distance, the same-side corners still win

Big dots sit far from both averages, so they count the most. The orange corners still outweigh the blue: the covariance is positive (121.8)

Covariance has awkward units, so we rescale it: correlation

The covariance here is 121.8, in “percent of raters times percentage points of the vote.” Is that big?

Divide by both standard deviations and the units cancel:

\[ r = \frac{\text{Cov}(X, Y)}{\text{SD}(X) \, \text{SD}(Y)} \]

The correlation runs from \(-1\) (a perfect line sloping down) to \(+1\) (a perfect line sloping up)

For faces and votes: r = 0.43

Your turn: guess the correlation

Write down a guess for each panel

Guess the correlation: answers

Correlations in the four panels. Simulated data
Panel Correlation in this sample
A 0.90
B -0.48
C 0.01
D 0.29

From averages to a line

The question: how does the average of \(Y\) move as \(X\) changes?

The correlation, 0.43, says faces and votes move together, and how tightly. It doesn’t say how much

If 10 more points of raters picked a candidate’s face, how much more of the vote would they get? The correlation can’t say: it has no units

But “how much” is what most applications need. With two groups, we compared two averages. Competence ratings take many values

The natural move: chop \(X\) into bins and take the average of \(Y\) in each bin

That’s a conditional mean, \(E[Y \mid X]\), one bin at a time

Bin \(X\), and take the average of \(Y\) in each bin

Orange lines: the average vote share among races in each fifth of competence ratings. Data: Todorov et al. (2005), via Imai and Williams (2022)

We could then compare \(E[Y \mid X = 1]\) vs \(E[Y \mid X = 2]\)

More bins follow the data more closely…

119 Senate races, cut into 2, 5, 10, and 30 bins of competence ratings. Data: Todorov et al. (2005), via Imai and Williams (2022)

…but bins have two problems

Too few races per bin

With 30 bins, each average rests on about 4 races. They’re very noisy

A rerun or more data of these elections would give a very different set of bins

Gaps and edges

Where we have no data, bins tell us nothing

And the cutoffs are arbitrary: move one, and the picture changes

A running average slides the bin along

Instead of fixed bins, average the races near each value of \(X\), then slide over and do it again

That’s what geom_smooth() draws if you don’t give it a method (a “LOESS” curve). Smoother, but still hard to sum up in one number

A regression line is a running average forced into a straight line

Forcing a shape (the line) fills in the gaps and smooths out some of the noise, at the cost of missing curves

The slope of the line also characterizes the relationship in term of \(X\) and \(Y\) units

Regression finds that line

Competence ratings and vote share in Senate races. Data: Todorov et al. (2005), via Imai and Williams (2022)
Democrat’s % of the vote (1)
% picking the Democrat’s face 0.33
(0.06)
Intercept 34.39
(3.30)
Races 119

Linear regression. Outcome: the Democrat’s share of the two-party vote, in percent. Standard errors in parentheses.

Read the slope: each extra point of raters picking the Democrat’s face goes with 0.33 points more of the vote

So a race where 70% of raters picked the Democrat’s face, vs. one where 30% did, goes with about 13.2 points more of the vote for the Democrat

A skeptic: do competent-looking faces win votes?

Incumbents are older, more polished, and better known. They may look more competent, and they win more votes for many other reasons

Same question as last week: what if the relationship is all a third variable, \(Z\)?

Wrapping up

Everything today was built from distances to an average

Tool Distances from…
Mean squared error A guess
Variance and SD The mean
Covariance and correlation The mean of \(X\) and the mean of \(Y\)
A regression line The line’s prediction (the conditional mean)

Next week: Exam 1, then probability

Exam 1 covers weeks 1–3 and takes the first half of class

Then we start probability: if we ran the world again, would we get the same answer?

References

Bertrand, Marianne, and Sendhil Mullainathan. 2004. “Are Emily and Greg More Employable Than Lakisha and Jamal? A Field Experiment on Labor Market Discrimination.” American Economic Review 94(4): 991–1013. doi:10.1257/0002828042002561.
Bonica, Adam. 2014. “Mapping the Ideological Marketplace.” American Journal of Political Science 58(2): 367–86. doi:10.1111/ajps.12062.
Bueno de Mesquita, Ethan, and Anthony Fowler. 2021. Thinking Clearly with Data: A Guide to Quantitative Reasoning and Analysis. Princeton, NJ: Princeton University Press.
Carter, David B., Andrew C. Shaver, and Austin L. Wright. 2019. “Places to Hide: Terrain, Ethnicity, and Civil Conflict.” Journal of Politics 81(4): 1446–65. doi:10.1086/704597.
Fearon, James D., and David D. Laitin. 2003. “Ethnicity, Insurgency, and Civil War.” American Political Science Review 97(1): 75–90.
Gailmard, Sean. 2014. Statistical Modeling and Inference for Social Science. New York: Cambridge University Press.
Imai, Kosuke, and Nora Webb Williams. 2022. Quantitative Social Science: An Introduction in Tidyverse. Princeton, NJ: Princeton University Press.
Todorov, Alexander, Anesu N. Mandisodza, Amir Goren, and Crystal C. Hall. 2005. “Inferences of Competence from Faces Predict Election Outcomes.” Science 308(5728): 1623–26. doi:10.1126/science.1110589.