Person Time Height After Treated
1 Adelaide Before 48 FALSE TRUE
2 Adelaide After 54 TRUE TRUE
3 Bella Before 47 FALSE FALSE
4 Bella After 51 TRUE FALSE
11 Dec 2024
What changes are included in each value?
\[Y_{it} = \beta_0 + \beta_1After_t + \beta_2Treated_i + \beta_3After_tTreated_i + \varepsilon_{it}\] where \(After_t\) is a binary variable for being in the post-treatment period, and \(Treated_t\) is a binary variable for being in the treated group
Person Time Height After Treated
1 Adelaide Before 48 FALSE TRUE
2 Adelaide After 54 TRUE TRUE
3 Bella Before 47 FALSE FALSE
4 Bella After 51 TRUE FALSE
\[Y_{it} = \beta_0 + \beta_1After_t + \beta_2Treated_i + \beta_3After_tTreated_i + \varepsilon_{it}\]
df <- read.csv('http://nickchk.com/eitc.csv') %>%
mutate(after = year >= 1994,
treated = children > 0)
df %>%
group_by(after, treated) %>%
summarize(proportion_working = mean(work))
# A tibble: 4 Ă— 3
# Groups: after [2]
after treated proportion_working
<lgl> <lgl> <dbl>
1 FALSE FALSE 0.575
2 FALSE TRUE 0.446
3 TRUE FALSE 0.573
4 TRUE TRUE 0.491
did_reg
Dependent Var.: work
Constant 0.575*** (0.009)
afterTRUE -0.002 (0.013)
treatedTRUE -0.129*** (0.012)
afterTRUE x treatedTRUE 0.047** (0.017)
_______________________ _________________
S.E. type IID
Observations 13,746
R2 0.01260
Adj. R2 0.01238
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
did_data <- tibble(group = sort(rep(1:10, 10)),
time = rep(1:10, 10)) %>%
mutate(CurrentlyTreated = group %in% c(1,9) & time >= 7) %>%
mutate(Outcome = group + time + 3*CurrentlyTreated + rnorm(100))
did_data
# A tibble: 100 Ă— 4
group time CurrentlyTreated Outcome
<int> <int> <lgl> <dbl>
1 1 1 FALSE 1.50
2 1 2 FALSE 2.43
3 1 3 FALSE 3.70
4 1 4 FALSE 5.75
5 1 5 FALSE 4.57
6 1 6 FALSE 6.47
7 1 7 TRUE 11.1
8 1 8 TRUE 12.6
9 1 9 TRUE 12.6
10 1 10 TRUE 13.6
# â„ą 90 more rows
# Put group first so the clustering is on group
many_periods_did <- feols(Outcome ~ CurrentlyTreated | group + time, data = did_data)
etable(many_periods_did)
many_periods_did
Dependent Var.: Outcome
CurrentlyTreatedTRUE 3.095*** (0.4991)
Fixed-Effects: -----------------
group Yes
time Yes
____________________ _________________
S.E.: Clustered by: group
Observations 100
R2 0.96131
Within R2 0.34238
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
PB4A7- Quantitative Applications for Behavioural Science