PB4A7- Quantitative Applications for Behavioural Science
30 Oct 2024
\[ Y = \beta_0 + \beta_1X + \varepsilon \]
\[ ClassGrade = \beta_0 + \beta_1 StudyTime + \varepsilon \]
\[\beta_1 + corr(X,\varepsilon)\frac{\sigma_\varepsilon}{\sigma_X}\]
feols
with vcov = 'hetero'
in R or with “robust” in STATAWe will look at three features of the right-hand side
data(PSID, package = 'Ecdat')
PSID <- PSID %>%
filter(age >= 30, married %in% c('married','never married'), earnings > 0) %>%
mutate(married = married == 'married')
PSID %>%
group_by(married) %>%
summarize(log_earnings = mean(log(earnings)))
# A tibble: 2 Ă— 2
married log_earnings
<lgl> <dbl>
1 FALSE 9.26
2 TRUE 9.47
Notice:
Why does OLS give us a comparison of means when you give it a binary variable?
feols(log(earning..
Dependent Var.: log(earnings)
Constant 8.740*** (0.1478)
marriedTRUE 0.3404*** (0.0579)
kids -0.2259*** (0.0159)
age 0.0223*** (0.0038)
_______________ ___________________
S.E. type IID
Observations 2,803
R2 0.07609
Adj. R2 0.07510
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Mean of married is \(9.47\) and of non-married is \(9.26\). \[ \log(Earnings) = 0 + 9.47Married + 9.26NonMarried \] \[ \log(Earnings) = 3 + 6.47Married + 6.26NonMarried \]
These all give the exact same predictions! OLS can’t pick between them. There’s no single best way to minimize squared residuals
So we pick one with convenient properties, setting one of the categories to have a coefficient of 0 (dropping it) and making the coefficient on the other the difference relative to the one we left out
To think more about the right-hand-side, let’s go back to our original interpretation of an OLS coefficient \[ Y = \beta_0 + \beta_1X + \varepsilon \]
A one-unit change in \(X\) is associated with a \(\beta_1\)-unit change in \(Y\)
This logic still works with binary variables since “a one-unit change in \(X\)” means “changing \(X\) from No to Yes”
Notice that this assumes that a one-unit change in \(X\) always has the same effect on \(\beta_1\) no matter what else is going on
What if that’s not true?
What do they do?
\[ Y = \beta_1X + \beta_2X^2 \] \[ \partial Y/\partial X = \beta_1 + 2\beta_2X \]
So at \(X = 0\), the effect of a one-unit change in \(X\) is \(\beta_1\). At \(X = 1\), it’s \(\beta_1 + \beta_2\). At \(X = 5\) it’s \(\beta_1 + 5\beta_2\).
feols(Y ~ X, dat.. feols(Y ~ X + I(.. feols(Y ~ X + I(...1
Dependent Var.: Y Y Y
Constant 7.285*** (0.5660) -0.1295 (0.3839) 0.0759 (0.5091)
X -8.934*** (0.1953) 0.9779* (0.3831) 0.4542 (0.9331)
X square -2.003*** (0.0752) -1.738*** (0.4368)
X cube -0.0354 (0.0574)
_______________ __________________ __________________ __________________
S.E. type IID IID IID
Observations 200 200 200
R2 0.91357 0.98122 0.98126
Adj. R2 0.91313 0.98103 0.98097
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Downsides:
\[ Y = 1 + 2\log(X) \] \[ \log(Y) = 3 + 2\log(X) \]
\[ \log(Y) = 4 + 3X \]
\[ Y = \beta_0 + \beta_1X + \beta_2Z + \beta_3X\times Z + \varepsilon \] - Interaction terms are a little tough but also extremely important.
Expect to come back to these slides, as you’re almost certainly going to use interaction terms in both our assessment and the dissertation
\[ Y = \beta_0 + \beta_1X + \beta_2Z + \beta_3X\times Z \] \[ \partial Y/\partial X = \beta_1 + \beta_3 Z \]
feols(log(earnin..
Dependent Var.: log(earnings)
Constant 9.087*** (0.0583)
marriedTRUE 0.2381*** (0.0638)
collegeTRUE 0.8543*** (0.1255)
marriedTRUE x collegeTRUE -0.2541. (0.1363)
_________________________ __________________
S.E. type IID
Observations 2,803
R2 0.06253
Adj. R2 0.06153
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
PB4A7- Quantitative Applications for Behavioural Science