BA 3316 · Regression, Days 1–5

Your questions, answered

After Day 5 you wrote down the questions you're most stuck on. Here they are, in the order we covered things.

I read all of them. We don't have class time to go back over all of them, so the answers live here. Each answer starts with your question, then gives a short explanation, a new example and a quick check you can try.

If you still want to go over some, come to office hours.

Start here

Connecting regression concepts

You asked

"Can you do a quick rundown of all the days into one? Like how do all the lessons of regression go together? Connect them?"

"In terms of practice or studying, I feel as if everything jumbles together. How do I keep things separate?"

Let's follow one estimate, Card's return to school, through the unit. Each day left a problem. The orange "But…" boxes highlight the hanging problem to solve.

Three words to keep in mind

Estimand (β1)
The number we want: the true return to a year of school in the process that sets wages for the population we're studying, not just the men in this sample.
Estimator(cov(x, y) / var(x))
The recipe that turns a sample into a number. In this unit, OLS.
Estimate (β1)
What the estimator gave in Card's sample: 0.052.
estimate = estimand + bias + sampling error

Our estimate can miss the estimand for two reasons, and the unit deals with each one. Below, a bias label marks the steps about bias, and a sampling error label marks the steps about sampling error.

Mixing up the symbols? See Hats, Greek letters, and where the variables go.

Day 1
What is one more year of school worth?
ToolStart with averages. One way to estimate E(wage | school), the CEF, is the average wage at each year of school: 18 numbers. If we use regression, we can instead estimate the CEF as a line of best fit, with just 2 numbers. OLS picks the line with the smallest squared misses, and each man's miss is his residual.β1 = cov(x, y) / var(x)
Estimateβ1 = 0.052: with log wages, each additional year of schooling is associated with about 5.2% greater wages

But… men with more school can differ in other ways too: less work experience, or more likely to live in a city. And these things likely affect wages too. So 5.2% mixes the relationship between wages and school with the relationship between wages and experience (and everything else).

Days 1–2
What if we compare men who are alike except for years in school?
ToolHold things constant. Exact matches will often leave most groups empty, so instead add controls to the regression. FWL shows what that does: it compares each man's schooling to what's typical for men like him.
In REach control is one more variable after the ~ (the "tilde"). This code:lm(lwage ~ educ + exper, data = card)is this model:lwage = β0 + β1 educ + β2 exper + u
Estimate0.052 → 0.093 holding just experience constant; 0.052 → 0.075 with all of Card's controls (experience, experience², race, the South, living in a city, and where he lived in 1966)
Watch outR² is the share of the differences in wages that the x's explain. It's low (0.10 for school alone), but that doesn't make the slope (β1) wrong: R² is about fit, not bias. It won't be central to causality.
bias: handles omitted variable bias (OVB) for the variables we included

But… we can only hold constant what's in the data. Ability isn't, and some men misreport their schooling.

Day 3
Which way could it still be off?
Formulaβ1=β1+(z → y)×(z with x)slope without zslope with z0.052=0.093+0.041×(−1.01)The bottom row puts in the numbers for experience. The tilde marks the estimate that leaves z out.
ToolTwo thumbs are just the signs of that last piece. Thumb 1: does z raise or lower wages? Thumb 2: does z move with school? Same signs: β1 is too big. Different signs: β1 is too small. Experience is (+)(−), which is why holding it constant raised the estimate of β1.
Estimateability: (+)(+), so 5.2% is probably too high. Day 5's table backs this up: adding IQ (including it in the regression) moves β1 from 0.076 to 0.070.
NoiseRandom noise in schooling pulls β1, our estimate of the payoff to a year of school, toward zero. That's a bias, called attenuation. We discussed this back when we talked about classical measurement error.Random noise in log wages doesn't bias β1 (it doesn't change it on average). It makes β1 bounce more from sample to sample: less precise (a greater standard error).
bias

But… even with no bias at all, a different sample of young men would give us a different number for the estimated return to schooling. How big is that bounce?

Days 3–4
How much would β1 bounce from sample to sample?
ToolThe standard error (SE) measures the bounce: how spread out β1 would be across many samples. We only ever see one sample, so we can never know the true SE. We estimate it, and every SE you see is an estimated SE.Use robust SEs, which don't assume wages are equally spread out at every level of school.Then build a 95% confidence interval: β1 ± 1.96 × SE.
Testt = (β1 − hypothesized value) / SE, for any value.Against 0 (no return to education): (0.052 − 0) / 0.0029 ≈ 18.Against 0.10 (a 10% return to education): (0.052 − 0.10) / 0.0029 ≈ −16.6.Both |t| > 1.96, so both are rejected.
EstimateSE 0.0029, 95% confidence interval 4.6% to 5.8%
Without the right estimated SEs, we can land on the wrong conclusions.
sampling error

But… knowing the estimate is distinguishable from zero (or another null hypothesis) doesn't tell us whether the estimate is big enough to matter.

Day 4
Is it real, and is it big?
RealStatistically significant: the interval excludes 0, or whatever null hypothesis you specified.
BigEconomically significant: the whole interval is past the smallest effect that would matter.
What counts as "big" is subjective and specific to the question. No formula picks the line for what counts as big, so say where you drew it and why. Here we used 2%, about a cost-of-living raise: if a year of school raised pay by less than that, it probably wouldn't be worth a year out of work.
SizeRead sizes right: percent vs. percentage points.
Estimate4.6% to 5.8% vs. a 2% line: real and big. And 5.2% → 7.5% is up 2.3 percentage points.

But… not every x is "years." What if x is a group (college or not), or the slope is different for different people?

Day 5
What does a coefficient mean when x is a group?
DummyA dummy is 1 for one group and 0 for the other, and its coefficient is the difference in the two groups' averages. High-school grads average 6.249 in log wages and college grads 6.385, so the regression is lwage = 6.249 + 0.136 college. The intercept is the high-school grads' average, and college grads earn about 13.6% more.
Base groupWith three groups, use two dummies and leave one group out. Each dummy's coefficient is measured from the group left out: high-school grads 0.267 and college grads 0.435 above men with less than 12 years. So high-school grads earn about 26.7% more than men with less than 12 years of school, and college grads earn about 43.5% more.
Hold constantAdd experience to the regression:lwage = 5.807 + 0.044 exper + 0.321 collegeThe college gap jumps from 0.136 to 0.321. That's Day 2's idea, and Day 3's thumbs say why: experience raises wages (+), and college grads have less of it (−), so leaving it out pulled the initial estimate of the gap down.
InteractionAdd experience × college:lwage = 5.913 + 0.034 exper + 0.054 college
   + 0.038 (exper × college)
This lets the slope on experience differ by group: a year of experience goes with 3.4% higher wages for high-school grads and 7.2% for college grads. The interaction's coefficient, 0.038, is the difference between those slopes: 0.034 + 0.038 = 0.072.
Squared termAdd experience²:lwage = 4.469 + 0.093 educ
   + 0.090 exper − 0.0025 exper²
This lets the slope change with the value of x. The slope on experience is 0.090 − 2 × 0.0025 × exper: the first year of experience goes with about 9.0% higher wages, but at 10 years one more year goes with about 4.0%.

First, the parts of a regression table

Before reading a table, know what each piece is. Each blue square letter matches an entry in the guide underneath.

OLS estimates of the returns to schoolingA
Outcome: log hourly wageB
(1)C(2)(3)
All menMen with IQ scoresDAdd IQ
EducationE0.075F0.0760.070
(0.004)G(0.005)(0.005)
SMSA (lives in a city)0.1360.1250.123
(0.019)(0.023)(0.023)
IQH0.0025
(0.0008)
ConstantI4.7394.6754.501
(0.075)(0.100)(0.114)
NJ3,0102,0612,061
R²K0.300.230.24

Robust standard errors in parentheses. Controls include experience, experience², race, South, and 1966 region and SMSA indicators. Columns (2) and (3) use the men with IQ scores.L

ATitleWhat question the table answers. Here: what a year of school is worth.
BOutcome (dependent variable, y)What every coefficient is about. Here it's log wage, so 100 × coefficient is about a percent.
CColumn numberEach column is one regression. Here are the three, where "controls" means Card's controls listed in the notes (L):(1) all 3,010 menlwage = β0 + β1 educ + β2 smsa + controls + u(2) 2,061 men with IQlwage = β0 + β1 educ + β2 smsa + controls + u(3) the same 2,061 menlwage = β0 + β1 educ + β2 smsa + β3 IQ + controls + u
DColumn labelWhat's different about that regression: its sample or its x's. (2) keeps only men with IQ scores; (3) also adds IQ.
ERow labelOne x in the regression (an explanatory variable). Education is years of school; SMSA is a dummy, 1 if he lives in a city.
FCoefficient (β)How y moves with that x, holding the other x's in that column constant. 0.075: one more year of school goes with about 7.5% higher wages.
GStandard error (estimated)In parentheses, right under its coefficient: our estimate of how much the coefficient would bounce from sample to sample. t = 0.075 / 0.004 ≈ 19; 95% CI 0.075 ± 1.96 × 0.004.
HBlank cellThat x isn't in that regression. IQ is blank in (1) and (2).
IConstant (intercept, β0)The predicted y when every x is 0. Here that's a man with no school, no experience and an IQ of 0, so it's not meaningful on its own.
JNHow many people the regression used. It drops from 3,010 to 2,061 because only some men have IQ scores.
KR²The share of the differences in y that the x's explain. About fit, not bias.
LNotesDetails you need that don't fit in the cells. Which SEs (robust), controls that are in the regression but not shown, and the sample.
Turning a coefficient into a sentence (outcome in logs)

Holding the other x's constant, one more unit of x goes with about 100 × coefficient% higher or lower y.

Education, column (1): Holding Card's controls constant, one more year of school goes with about 7.5% higher wages.

For a dummy, compare the two groups: SMSA, column (1): holding the rest constant, men who live in a city earn about 13.6% more than men who don't.

More on reading tables: Reading a regression table (Question 4), under Day 5.

Some tables also add stars (*, **, ***) to flag statistical significance. Ours don't: compute t from the coefficient and its SE.

Everything at once: reading one table

Day 5's IQ table uses every day. Read it in this order; each number in a black circle matches a question below.

(1) all men(2) men with IQ scores2(3) add IQ
educ0.0750.076→0.07015
(0.004)(0.005)(0.005)4
smsa (lives in a city)0.1360.1250.123
(0.019)(0.023)(0.023)
IQ0.00253
(0.0008)
N3,0102,0612,061

Dependent variable: log wage. Card's Table 2 controls in every column. Robust standard errors in parentheses.

1What does the number mean? Holding IQ and Card's controls constant, a year of school goes with about 7.0% higher wages (100 × 0.070). Days 1 & 5
2What changed between columns? Columns (2) and (3) use the same 2,061 men, and (3) adds IQ. So compare (2) with (3), not (1) with (3). Day 2
3Why did the coefficient move that way? It fell from 0.076 to 0.070. IQ raises wages (+, its coefficient is 0.0025) and moves with school (+). Same signs, so column (2) was biased up. Day 3
4What's in the parentheses, and is it significant? The estimated robust SE of 0.070. t = 0.070 / 0.005 = 14, more than 1.96, so it's statistically significant. Days 3 & 4
5Is it big enough to matter? 95% confidence interval: 0.070 ± 1.96 × 0.005 = 6.0% to 8.0%. All of it is above our 2% line, so it's big. Day 4
Start here

Hats, Greek letters, and where the variables go

You asked

"How do I keep things separate and remember the letters, order, etc.?"

"How to do the substitutions, like doing the ^ or not ^, and when to use certain Greek letters for the equations?"

"How to know where the different variables fit into the equation based on a word question?"

The cast of characters

You seeRead it asExample
ythe outcome: what we're explaininglog wage
x (or x1, when we have a multivariate regression)the variable we care aboutyears of school
zsomething left out of the regressionability
β0, β1 (no hat)the true intercept and slope. We never see them.the estimand
β1 (hat)our estimate of β1, computed from the sample0.052
uthe leftover: everything else that affects yluck in the job search, a generous boss, …
ŷthe line's prediction$17 for 12 years
y − ŷ (or û)the residual: actual outcome minus predicted outcome value20 − 17 = 3
SEhow much β would bounce from sample to sample0.0029
t(estimate − hypothesized value of the estimand) / SE0.052 / 0.0029 ≈ 18

Four rules

  1. A hat means "computed from our sample." No hat means the true number we're after.
  2. Writing the model, before any data: no hats, and include u.
    y = β0 + β1x + u
  3. Plugging in numbers from output: put on hats, and drop u, because the fitted line gives predictions.
    ŷ = 5.807 + 0.044 exper + 0.321 college
  4. Greek letters are name tags. β, δ, α and γ each mean "some unknown number (coefficient) that multiplies this variable." Day 5 used δ for the dummies only to tell them apart. What matters is which variable a letter multiplies. The order of the terms doesn't matter either, though in different cases there will be a normal way to do it.

From a word question to an equation

  1. What are we explaining? That's y, on the left.
  2. "The effect of…", "the return to…", "how much does ___ go with…" names the main x. Its coefficient is the answer.
  3. "Holding ___ constant", "controlling for ___", "among people with the same ___" names more x's, typically potential confounders we want to be sure to include.
  4. "Differs between groups" means a dummy. "Does the effect of x differ between groups?" means an interaction (x × dummy).
  5. Asked in percent? Use log y as the outcome, and read 100 × coefficient as a percent.

Check yourself. "In percent, how much higher are home prices for each extra bedroom, holding square footage constant?" Write down the regression model.

Show answer
log(price) = β0 + β1 bedrooms + β2 sqft + u

The answer is 100 × β1 percent.

Check yourself. "Does an extra hour of sleep go with a higher GPA among students who work the same number of hours?" Write down the regression model.

Show answer
GPA = β0 + β1 sleep + β2 workhours + u

Look at β1.

Check yourself. "Is the return to experience different for women than for men?" Write down the regression model.

Show answer
log(wage) = β0 + β1 exper + β2 female + β3 (exper × female) + u

β3 is how much the experience slope differs for women.

Day 1 · Oct 8

What is one more year of school worth?

↑ Where this fits in the big picture

What a residual means

You asked

"Going back over residuals. Less the actual calculation, more what it means / how it translates to an equation."

A residual answers one question about one person: how far is this person above or below what the line predicts for someone like them? Click a worker from Day 1 to read their residual as a sentence.

In an equation, every data point splits into the line's guess plus the miss: y = ŷ + residual. For worker B, 20 = 17 + 3.

The model has the same split: y = β0 + β1x + u. There, u is the true leftover: everything besides school that sets this man's wage. We never see u, so the residual is our sample's stand-in for it (that's why it's sometimes written û).

Residuals show up all through the unit. OLS picks the line with the smallest sum of squared residuals (Day 1). FWL works with "residualized" schooling (Day 2). Robust standard errors use the residuals' spread (Day 4).

Check yourself. A worker with 14 years of school earns $26 an hour. What is the residual, and what does it say?

Show answer

The line predicts −19 + 3 × 14 = $23. The residual is 26 − 23 = +3: this worker earns $3 an hour more than the line expects for 14 years of school.

See it move: Beat the computer

MSE: what the line is trying to do

You asked

"LMSE? On my notes, don't know what it means :/"

The handout's term is MSE, mean squared error. (The L is probably from "least," as in least squares.) It's the score from Day 1's first game: you guess, you lose the square of your miss, and the MSE is your average loss.

New example

Three men earn $10, $12 and $20 an hour. Pick one guess of their hourly wage, the same number for all three.

$8$17$22

Squaring makes every miss count and big misses count more, and the guess that keeps the MSE smallest is the average. OLS does the same thing with a line instead of one number: it picks the line with the least squared error. That's all "least squares" means.

Check yourself. If the three wages were $10, $12 and $50, what guess gives the smallest MSE?

Show answer

The average, $24. One big wage pulls the best guess a long way, because its miss gets squared.

Holding things constant, and the empty groups

You asked

"Day 1, Question 5: What does it mean to hold things constant in regression, and how does that solve the empty groups problem? What is FWL?"

Holding experience constant means comparing men who have the same experience, so a schooling difference isn't mixed up with an experience difference.

The direct way is matching: sort men into groups that match on everything else, then compare schooling within each group. With Card's controls that takes 3,456 groups for 3,010 men, and only 686 of the groups have anyone in them. There's nobody to compare with.

Regression doesn't need exact matches. Instead it assumes a shape. In our case, we often assume each control shifts wages by a set amount (for example, living in the South shifts log wages by the same amount at every level of schooling). Then it estimates each shift from all the men at once, so every man helps estimate every coefficient.

That eases the empty-groups problem; it doesn't make it go away. Two separate problems are left:

  1. The shape can be wrong. If wages don't really shift by a set amount for each control, the adjustment is off.
  2. The data still get spread thinner. Each extra control that moves with schooling takes away some of the variation in schooling we learn from, so the estimate can get less precise (a bigger SE).
New example

To see what an extra bedroom adds to a home's price, you'd want houses that match on size, neighborhood and age. Most of those combinations have zero or one house. A regression instead assumes each extra 100 square feet adds the same amount everywhere, each extra year of age changes the price by the same amount everywhere, and each neighborhood has its own fixed shift. Then it estimates those from every house:

price = β0 + β1 bedrooms + β2 size + β3 age
   + δ1 nbhd1 + δ2 nbhd2 + … + u

size is in 100s of square feet, and each nbhd is a dummy for one neighborhood. β1 compares homes with the same size, age and neighborhood.

FWL is how regression does the holding constant. It's the first answer under Day 2.

Check yourself. Why can't we just compare men with exactly the same experience, region, race and city?

Show answer

Most of those groups are empty or hold one man, so for most men there's nobody with a different amount of school to compare with.

Day 2 · Oct 13

What does it mean to hold something constant?

↑ Where this fits in the big picture

FWL: what does it even look like?

You asked

"Frisch–Waugh–Lovell Theorem explanation / question. What does that even look like? IDK! Help me please :("

"What is FWL?"

"Can you explain heteroskedasticity and FWL again and how they relate to regressions / why are they important?"

FWL says the coefficient on x1 in a regression with controls is the slope you get in two steps:

  1. Regress x1 on the controls, and keep the residuals. That line's prediction is the x1 that's typical for people with the same controls. The residual, r1 = x1 − (that prediction), is what's left: how much more or less x1 this person has than is typical for people like them. Whatever the controls can predict has been taken out of r1.
  2. Regress y on r1. That's a simple regression with one x, like Day 1. Its slope is exactly β1 from the regression with controls.

So FWL means we can write β1 from a multivariate regression with the Day 1 slope formula, using r1 in place of x:

β1 = cov(r1, y) / var(r1)

In one sentence: controlling for z means comparing x1 to its typical value for people with the same z.

New example: do ads hurt sales?

A coffee shop records six weeks of ad spending and sales (both in hundreds of dollars). It advertises more in winter, because winter is slow.

weekseasonadsseason avg adsr = ads − avgsalessales − 35r × (sales − 35)r²
1summer12−1405−51
2summer22044900
3summer3214611111
4winter56−124−11111
5winter66026−900
6winter76130−5−51
sum??

Check yourself. Fill in the two sums, then compute the slope the way we did on Day 2: Σ r(sales − 35) / Σ r².

Show answer

Σ r(sales − 35) = −5 + 0 + 11 + 11 + 0 − 5 = 12. Σ r² = 4. Slope = 12 / 4 = 3. That's cov(r1, sales) / var(r1) from above, with r as r1 (the n − 1s cancel). Within a season, $100 more in ads goes with $300 more in sales. A regression of sales on ads and a winter dummy gives the same 3.

Why it matters: FWL tells you what a coefficient with controls means. It isn't "the effect of x" in general; it's how y moves with the part of x the controls don't explain. Heteroskedasticity answers a different question: not what the number means, but how sure we can be about it. That's under Day 4, robust standard errors.

Check yourself. In the coffee shop, what does "controlling for season" compare?

Show answer

Weeks with more ads than usual for their season against weeks with fewer, within the same season. Summer weeks are never compared with winter weeks.

Same idea with the studying data: Hold it constant

Day 3 · Oct 15

How much should we trust 5.2%?

↑ Where this fits in the big picture

Two thumbs (omitted variable bias): where the + and − come from

You asked

"Day 3, Problem 2: Two thumbs. How do you know what's negative and positive, like x & y & z? How do you get +, − from them?"

"What is the way to find correlation with direction for OVB? Another example would be helpful."

When a variable z is left out and has a relationship to y and to x, the slope on x picks up part of z's effect. The two thumbs, or thinking about the direction of those two relationships, tell you which way that pushes the slope. Each thumb answers one question with a sign:

  • Thumb 1, z → y. Picture two people with the same x. If one has more z, is their y higher (+) or lower (−)?
  • Thumb 2, z with x (the "correlation with direction"). In the data, do people with more x tend to have more z (+) or less z (−)? It's a tendency, not a cause.
  • Multiply. Same signs (+ +, or − −): the bias is up, so the slope without z is too big. Different signs: the bias is down, so it's too small.

That's Day 3's formula written as signs: slope without z = slope with z + (thumb 1) × (thumb 2). In the studying example, −1 = 2 + (−30) × (0.1). The −30 is thumb 1 (the hard class lowers scores at the same hours) and the 0.1 is thumb 2 (hard-class students study more). If you have the data, thumb 2's sign is the slope from regressing z on x.

New example

Does tutoring raise grades? Left out: being behind already. Thumb 1: of two students with the same tutoring hours, the one who was behind gets a lower grade (−). Thumb 2: students who are behind sign up for more tutoring (+). Different signs, so the bias is down: the plain slope understates tutoring and can even make it look harmful.

Practice: sign the thumbs

So the plain slope (without z) is biased…

Sampling error: draw another sample

You asked

"Day 3: Can you go over sampling error: draw another sample. 5, 5a, 5b, 5c, 5d."

Even with no bias at all, the estimate isn't exactly the estimand, because we only have one sample. Draw a different 100 men and you get a different slope. The gap between a sample's estimate and the estimand is that sample's sampling error, and it changes from sample to sample.

  • 5a. Draw 1,000 samples of 100 men from Card's data. The slopes average 0.052 and spread out with an SD of 0.016.
  • 5b. That SD, the spread of the slope across samples, is the standard error: how much the estimate bounces from sample to sample. With 400 men per sample it's about 0.008. Four times the men, half the SE.
  • 5c. With all 3,010 men the SE is 0.0029, so the 95% confidence interval is 0.052 ± 1.96 × 0.0029 = 0.046 to 0.058.
  • 5d. "95%" describes the recipe, not this one interval: if we drew many samples and built an interval from each, about 95% of them would contain the true slope.
New example

Ask 100 random students how much they spend on coffee per week and you might get an average of $14. Ask a different 100 and you might get $12.50. Neither poll is biased; they differ by "luck," or sampling error. Ask 400 at a time and the averages land closer together.

Three terms that sound alike
  • Sampling error is one number for one sample: how far that sample's estimate lands from the estimand, just from the luck of who got drawn. It's different in every sample, and we never know it, because we never know the estimand.
  • SD (standard deviation) measures the spread of any list of numbers: wages in one sample, or slopes from 1,000 samples.
  • SE (standard error) is one particular SD: the SD of the estimate across many samples. It's the typical size of the sampling error. We only ever have one sample, so we estimate the SE (R does it for us).

So SD ≠ SE: the SD of wages in Card's data says how spread out wages are, not how much the slope bounces. And sampling error ≠ SE: the sampling error is how far off this sample is, and the SE is how far off a sample typically is.

Bias vs. sampling error: bias pushes the estimate the same way in every sample, and more data won't fix it. Sampling error is random around the truth and shrinks as samples grow.

Check yourself. With samples of 1,600 men (16 times as many as 100), about what would the SE be?

Show answer

16 times the data divides the SE by √16 = 4: 0.016 / 4 = 0.004.

Press "draw another sample" yourself: Noise and luck

Day 3 revisited · Oct 20

Noisy data

↑ Where this fits in the big picture

A7: why does +2 count as the "bigger" error?

You asked

"Regression Day 3 (revisited), A7: Why is an error (e) that's equally far away from the true point (for example +2 and −2) treated as if +2 has the larger error? Is it not determined by absolute value?"

Good catch on the wording. "Bigger e" means more positive, not farther from zero. Think of temperatures: +2° and −2° are the same distance from 0, but +2° is warmer.

The sign is the whole point. e = +2 means the student reported more hours than they really had; e = −2 means fewer. Thumb 2 asks whether e moves up with reported hours, and taking the absolute value would erase exactly that direction.

In A7, P and Q both report 5 hours. P (e = +2) truly had 3 hours and scored 84. Q (e = −2) truly had 7 and scored 76. At the same reported hours, a more positive e goes with a higher score, so thumb 1 is +.

1. Bigger e means farther right on the number line bigger e −4−3−2−10+1+2+3+4 Q: e = −2 P: e = +2 2 from 0 2 from 0 2. e is the jump from true hours to reported hours P +2 Q −2 hollow: true filled: reported 0246810 hours

Top: P's e (+2) and Q's e (−2) are the same distance from 0, but P's is bigger because it's farther right. Bottom: e = reported − true. P reported more hours than they really had, so the arrow points right (+2). Q reported fewer, so it points left (−2).

Check yourself. R and S both report 4 hours on their phones. R's e is +1; S's e is −3. Who has the bigger e? Who truly spent more hours on the phone?

Show answer

R has the bigger e (+1 is more than −3), even though S's error is farther from zero. True hours = reported − e, so R truly had 3 hours and S had 7. S truly spent more time on the phone.

Part B: no bias, but less precise

You asked

"Day 3 revisited, Part B: What does it mean by no bias, but less precise? An example that includes other steps."

Picture darts. Bias means aiming at the wrong spot: every throw lands off the same way. Imprecision means aiming at the right spot, but the throws scatter more.

Random noise in log wages is the second kind. Averaged over many samples, the slope still lands on 0.052 (no bias). But each sample's slope bounces more, so the standard error grows: from 0.0029 to 0.0040 in Card's data.

New example, every step

A grader adds a random amount, up to 5 points either way, to each exam score. Does that bias the slope of score on study hours?

  1. Write it down. reported score = true score + v, where v is the random grading noise.
  2. Plug it into the true model. reported score = β0 + β1 hours + (u + v). The noise lands in the leftover.
  3. Two thumbs for v. v → reported score: +. v with hours: 0, because the noise is random, unrelated to hours and to u. Bias = (+) × 0 = 0.
  4. What changes. The leftover u + v is bigger, so the points scatter more around the line, so the slope wobbles more from sample to sample: a bigger SE.

Compare noise in x (Part A): that noise moves with reported x, so thumb 2 isn't zero, and on average it pulls the slope toward zero.

See it: noise in scores vs. noise in hours

The computer draws samples of 50 students from a process we set up, where every extra hour of studying adds 2 points to the true score. That 2 is the true slope. Pick where the random noise goes.

This sample
slope
Across 1,000 samples
average slope
how much the slope bounced (SE)

Because this is a simulation, we can see the true slope and 1,000 samples. With real data you get one sample and see neither.

Check yourself. If the random noise were added to the recorded study hours instead of the scores, would the slope be biased?

Show answer

Yes, toward zero on average. Noise in hours moves with recorded hours, so thumb 2 isn't zero. That's Part A.

Day 4 · Oct 20

Is it real, and is it big?

↑ Where this fits in the big picture

1e: R code in plain English

You asked

"Day 4, #1e: using English to explain what is happening."

lm(lwage ~ educ + exper, data = card)

Read ~ as "explained by." Left of it is y. Each name on the right gets its own coefficient, in order. R adds the intercept for you, and the leftover u is everything not listed. So we are estimating this model:

lwage = β0 + β1 educ + β2 exper + u
Piece by piece
In the codeWhat it meansIn the model
lm(fit a line by OLS ("linear model")—
lwagey, the outcome we're explaininglwage
~"explained by"=
not in the codethe intercept: R adds it for youβ0
educthe first x, with its own coefficient+ β1 educ
+ experthe second x ("+" means "and"), with its own coefficient+ β2 exper
, data = card)use Card's data—
not in the codethe leftover: everything not listed+ u

Read the last column top to bottom and you get the model above. Same color, same piece. The dashed boxes aren't in the code: R adds β0 on its own, and u is everything you left out.

In English: "explain log wages using years of school and years of experience, in Card's data." β1 is the return to school holding experience constant. Its estimate is 0.093: among men with the same experience, a year of school goes with about 9.3% higher wages.

Check yourself. Write the model and say it in English: lm(sales ~ ads + winter, data = shop)

Show answer
sales = β0 + β1 ads + β2 winter + u

Here, we want to explain sales using ad spending and a winter dummy. β1 is how sales move with ads, holding season constant.

Robust standard errors: what, why and how

You asked

"…and ALSO exactly why we use robust SEs."

"How do you find the robust SE? With another example."

"Define robust S.E."

"Can you explain heteroskedasticity… and how it relates to regressions / why is it important?"

Define. A standard error is how much an estimate would bounce from sample to sample. R's default formula for it makes an assumption: that the points are spread around the line equally at every x. That's called homoskedasticity. When the spread changes with x (the cloud fans out), it's called heteroskedasticity. Homoskedasticity is an assumption about the process that produced the data. We only ever see one sample, so we can't know for sure whether it holds.

A robust standard error is computed without that assumption. If the spread really is equal, robust and default come out about the same (Card: 0.00287 vs. 0.00291). If it isn't, only the robust one is right. Since we can't know which is true, robust is the safe choice either way, and that's why we always report it.

Heteroskedasticity doesn't bias the slope. It makes the default SE wrong, and every t, p and interval built from that SE inherits the mistake.

How do you find it? You don't compute it by hand. R does it: modelsummary(m, vcov = "robust"), or lm_robust() in place of lm(). In a table, look for the note "Robust standard errors in parentheses," or, if you made the table, make sure you add that note!

New example: restaurant spending and income

Households earning $30,000 all spend a little on restaurants. Households earning $180,000 range from almost nothing to a lot, so the cloud fans out. Here the computer draws samples of 100 households from a process we set up, where every extra $1,000 of income adds $1.50 a month in restaurant spending. That 1.50 is the true slope, the estimand.

Because this is a simulation, we get to see things you never see when you're actually doing analysis: the true slope (the dashed line) and how much the slope bounces across 1,000 samples. With real data you get one sample, so all you'd have is the "This sample" numbers, and they can't tell you which SE is right.

This sample
slope
default SE
robust SE
Across 1,000 samples
how much the slope actually bounced
default SE, on average
robust SE, on average
95% CIs that caught the true slope
default
robust

Check yourself. If default and robust SEs come out nearly the same, which do you report?

Show answer

Robust. It's right either way. Two SEs that agree in one sample don't prove the spread is even, and robust costs nothing if it is.

Real or big: how we decide

You asked

"Day 4, Question 2b: Still confused with the question: is it rather real or not, and is it big or not?"

"Day 4, Real & Big. Another example. Specific how we decide 'Real' & 'Big.'"

They're two separate questions, and you answer both from the 95% confidence interval.

  1. Build the interval: estimate ± 1.96 × SE.
  2. Real? (statistically significant) Does the interval exclude 0? Excludes 0: real. Includes 0: not real. But this is assuming the null hypothesis is 0.
  3. Big? (economically significant) First say the smallest effect that would matter, and why. No formula picks it; it's a judgment call that depends on the setting. Then: if the whole interval is past that line, yes. If the whole interval is short of it, no. If the interval crosses it, can't tell.

"Not statistically significant" ("not real") can mean two different things. A tight interval around zero says the effect is near zero. A wide interval that includes zero says the data can't tell.

New example: free shipping

An online store tests offering free shipping to see if customers will order more. The outcome is dollars spent per order. The store decides that anything under $5 more per order isn't worth what free shipping costs. Decide each case, then check.

Four more studies, with "draw another sample": Real or big

Day 5 · Oct 22 and 27

What does the coefficient mean?

↑ Where this fits in the big picture

Dummies and interactions

You asked

"What does the coefficient on a dummy / interaction mean?"

A dummy's coefficient is the difference in average y between the group (dummy = 1) and the base group (dummy = 0), holding the other x's constant if we have other x's included. With no other x's, the intercept is the base group's average.

An interaction's coefficient is how much the slope differs between the groups.

New example: a coffee shop's daily sales
sales = 500 + 200 weekend

Weekdays average $500 (the intercept). Weekends average 500 + 200 = $700. The 200 is the gap between the two averages.

sales = 300 + 10 temp + 100 weekend + 5 (temp × weekend)

On weekdays each degree adds about $10. On weekends it adds about 10 + 5 = $15. The 5 is the difference in slopes between weekends and weekdays, in terms of how temperature is associated with sales.

Check yourself. Using the second equation, what are predicted sales on a 70° weekend day? On a 70° weekday?

Show answer

Weekend: 300 + 10(70) + 100 + 5(70) = 300 + 700 + 100 + 350 = $1,450. Weekday: 300 + 700 = $1,000. At 70° the weekend gap is 100 + 5 × 70 = $450.

Steps 1–4 draw these from Card's data: Dummies and slopes

Reading a regression table (Question 4)

You asked

"Day 5, Question 4: I don't understand how to interpret how columns/variables are related (positive/negative). Maybe another example would help."

"The Card Table 2 (not t), but how to interpret each column."

"Explaining how to read the tables like the one in Day 5 part 4."

Four rules for any regression table:

  1. Each column is one regression. The column heading says what's different about it.
  2. Each row is one x. The number is its coefficient. The number in parentheses under it is its robust standard error.
  3. A blank means that x wasn't in that regression. N is how many people it used.
  4. Compare neighboring columns that differ in one way. What changed, and what moved?

For a labeled picture of every part of a table, see the parts of a regression table in the big picture.

Day 5's table. Click any number.
(1) all men(2) men with IQ scores(3) add IQ
educ
smsa (lives in a city)
IQ
N

Dependent variable: log wage. Card's Table 2 controls in every column. Robust standard errors in parentheses.

Click any number in the table to see what it says.

The positive/negative part is two thumbs. From (2) to (3) the men are the same, and the only change is adding IQ. Thumb 1, IQ → wage: + (0.0025, holding school constant). Thumb 2, IQ with school: + (men with higher IQ scores tend to have more school). Same signs, so leaving IQ out biased educ up. Adding IQ takes that piece out: 0.076 falls to 0.070.

Compare (2) with (3), not (1) with (3): column (1) uses all 3,010 men, and the other two use only the 2,061 with IQ scores.

New example: house prices
(1)(2) add size
bedrooms0.1200.030
(0.020)(0.020)
square feet (100s)0.040
(0.004)
N2,0002,000

Dependent variable: log price. Robust standard errors in parentheses. Made-up data.

Check yourself. (a) Interpret bedrooms in column (1).

Show answer

Each extra bedroom goes with about 12% higher prices (100 × 0.120).

Check yourself. (b) Why does it fall in column (2)? Use two thumbs.

Show answer

Size → price: + (0.040). Size with bedrooms: + (homes with more bedrooms are bigger). Same signs, so column (1) was biased up. Holding size constant, an extra bedroom goes with about 3% higher prices.

Check yourself. (c) Is bedrooms statistically significant in column (2)?

Show answer

t = 0.030 / 0.020 = 1.5, which is less than 1.96, so no, not at 5%. Its 95% CI, about −0.9% to 6.9%, includes zero.

Practice

Try some on your own

You asked

"Examples of questions that'll be asked on Exam 2."

These are new practice questions in the style of exam questions: short answers, new settings. Try each one before you open the answer.

1. Logs. A store regresses log(spending per order) on a free-shipping dummy, then adds controls.

(1)(2) add controls
free shipping0.0840.059
(0.012)(0.013)
controlsnoyes
N5,0005,000

Dependent variable: log(spending per order). Robust standard errors in parentheses. Made-up data.

(a) Interpret 0.084. (b) How much did the estimate fall from column (1) to column (2), and in what units?

Show answer

(a) Orders with free shipping are about 8.4% larger, on average. (b) From 8.4% to 5.9%: a drop of 2.5 percentage points.

2. A t test against a number other than zero. An estimate is 0.072 with robust SE 0.010. Test H0: β1 = 0.05 at the 5% level.

Show answer

t = (0.072 − 0.05) / 0.010 = 2.2. Since |t| > 1.96, reject: the estimate is statistically different from 0.05.

3. Code to model. lm(score ~ hours + tutor, data = class), where tutor = 1 for students with a tutor. Write the model. Which coefficient is the hours slope holding tutoring constant?

Show answer
score = β0 + β1 hours + β2 tutor + u

β1.

4. FWL. In words, how could you get the coefficient on hours in question 3 from two simple regressions?

Show answer

Regress hours on tutor and keep the residuals: hours compared with students who have the same tutor status. Then regress score on those residuals. That slope equals β1.

5. Sign of the bias. A regression of sales on ad spending gives 2.1. Adding a holiday-season dummy drops it to 1.4. Explain the drop with two thumbs.

Show answer

Holiday → sales: +. Holiday with ads: + (stores advertise more in the holidays). Same signs, so leaving the season out biased the ad slope up. Adding it removes that piece.

6. Averages from dummies. sales = β0 + β1 weekend + β2 summer + β3 (weekend × summer) + u. Write E(sales | weekday, winter) and E(sales | weekend, summer). Which coefficients give the summer-minus-winter difference on weekends?

Show answer

E(sales | weekday, winter) = β0. E(sales | weekend, summer) = β0 + β1 + β2 + β3. On weekends, summer minus winter = (β0 + β1 + β2 + β3) − (β0 + β1) = β2 + β3.

7. Standard errors. Which standard errors should you report, and why?

Show answer

Robust. They don't assume the spread around the line is the same at every x, so they're right whether or not it is.

8. Real or big. A training program raises wages by an estimated 3% (SE 0.5%). Anything under 1% isn't worth the program's cost. Is it statistically significant (real)? Is it economically significant (big)?

Show answer

95% CI: 3 ± 1.96 × 0.5 = 2.0% to 4.0%. Real: yes, it excludes 0. Big: yes, all of it is above 1%.