In this question, you will work with data from Card and Krueger (1994). David Card and Alan Krueger collected information about fast-food restaurants in New Jersey (NA) and eastern Pennsylvania (PA) during two rounds of interviews. The first interview wave was in March 1992, just before New Jersey raised its minimum wage from 4.25 to 5.05 dollars - the raise occurred in April 1992. The second round of interviews was in November and December of 1992, 7 months after the new minimum wage policy in New Jersey. During that period, the minimum wage in Pennsylvania remained at the federal level of $4.25. The authors evaluated the impact of the new minimum wage law by analyzing this data.
Some columns have the same name but end with “2”. That means those values correspond to the second round of interviews (after the minimum wage raise).
Variable | Definition |
---|---|
sheet | Restaurant id |
chain | 1 if Burger King, 2 if KFC, 3 if Roy Rogers, and 4 if Wendy’s |
co_owned | 1 if restaurant is company-owned |
state | 1 if New Jersey, 0 if Pennsylvania |
wage_st | Starting wage (Dollar/hour) in March |
wage_st2 | Starting wage (Dollar/hour) in Nov/Dec |
fte | Full time equivalent employment in March |
fte2 | Full time equivalent employment in Nov/Dec |
Download the dataset here and answer the following:
How many Burger King, KFC, Roy Rogers, Wendy’s, and company-owned stores were located in NJ and PA? What are the percentages of store types in each State?
Calculate four averages: the average starting wages (wage_st
) in NJ and PA before and after the new minimum wage law in NJ. What is the difference-in-differences estimate of the impact of minimum wage on fast food starting wage in NJ?
Repeat the same exercise as in (b) for full-time equivalent employment (fte
). What is the impact of the new minimum wage law on employment in NJ fast-food restaurants?
Download the panel data version of this dataset here. Then, run the following regression DiD model
\[Y_{ist}=\alpha+\beta Dint_{st} + \lambda POST_{t} + \gamma TREAT_{s}+\varepsilon_{st}\] using wages and full time equivalent employment. How do those estimates compare to the results in (b) and (c)?
Hint: you need to create the variables Dint, POST, and TREAT.
A nice feature of regression DiD is that you can control for other factors. For instance, you might want to add covariates such as chains (chain
) and a dummy to capture whether the restaurant is company-owned (co_owned
). Repeat the models you used in (d), adding those covariates. Do your results change too much when adding restaurant-specific covariates? Do you have an explanation for that?
An alternative to comparing NJ and PA restaurants is to use restaurants within NJ with high and low wages before the minimum wage increase. Restrict the sample to NJ and identify restaurants paying salaries above and below 5 dollars/hour (i.e., create a dummy that takes on 1 if the restaurant pays salary below 5 dollars). Then, compare employment and wages before and after the new minimum wage law between restaurants above and below the $5 threshold. What is the relative impact of the minimum wage on employment within NJ? How do the within NJ estimates compare to those obtained in part (d)?
Hint: Use the first dataset for (f) and (g)
library(tidyverse)
<-readRDS("ck94.RDS")
ck94#ck94%>%group_by(chain, state)%>%summarize(number=n())
<-ck94%>%mutate(rest=case_when(chain==1 ~ "Burger King",
ck94==2 ~ "KFC",
chain==3 ~ "Roy Rogers",
chain==4 ~ "Wendy's"),
chainStates=case_when(state==0 ~ "PA",
==1 ~ "NJ"))
state
%>%group_by(rest, States)%>%summarize(number=n()) ck94
## # A tibble: 8 x 3
## # Groups: rest [4]
## rest States number
## <chr> <chr> <int>
## 1 Burger King NJ 136
## 2 Burger King PA 35
## 3 KFC NJ 68
## 4 KFC PA 12
## 5 Roy Rogers NJ 82
## 6 Roy Rogers PA 17
## 7 Wendy's NJ 45
## 8 Wendy's PA 15
%>%group_by(co_owned, States)%>%summarize(number=n()) ck94
## # A tibble: 4 x 3
## # Groups: co_owned [2]
## co_owned States number
## <dbl> <chr> <int>
## 1 0 NJ 218
## 2 0 PA 51
## 3 1 NJ 113
## 4 1 PA 28
<-ck94%>%group_by(rest, States)%>%summarize(number=n())
table1%>%group_by(States)%>%mutate(frac=number/sum(number))%>%ungroup() table1
## # A tibble: 8 x 4
## rest States number frac
## <chr> <chr> <int> <dbl>
## 1 Burger King NJ 136 0.411
## 2 Burger King PA 35 0.443
## 3 KFC NJ 68 0.205
## 4 KFC PA 12 0.152
## 5 Roy Rogers NJ 82 0.248
## 6 Roy Rogers PA 17 0.215
## 7 Wendy's NJ 45 0.136
## 8 Wendy's PA 15 0.190
<-ck94%>%group_by(co_owned, States)%>%summarize(number=n())
table2%>%group_by(States)%>%mutate(frac=number/sum(number))%>%ungroup() table2
## # A tibble: 4 x 4
## co_owned States number frac
## <dbl> <chr> <int> <dbl>
## 1 0 NJ 218 0.659
## 2 0 PA 51 0.646
## 3 1 NJ 113 0.341
## 4 1 PA 28 0.354
The average starting wage at fast-food restaurants in New Jersey increased by 10.4% \((0.48/4.61\times 100)\) following the rise in the minimum wage.
%>%group_by(States)%>%summarize(`Average Wages Before MWL`=mean(wage_st, na.rm=T),
ck94`Average Wages After MWL`=mean(wage_st2, na.rm=T))
## # A tibble: 2 x 3
## States `Average Wages Before MWL` `Average Wages After MWL`
## <chr> <dbl> <dbl>
## 1 NJ 4.61 5.08
## 2 PA 4.63 4.62
=(5.08-4.61)-(4.62-4.63)
DiD_wage DiD_wage
## [1] 0.48
Despite the increase in wages, full-time equivalent employment increased in New Jersey relative to Pennsylvania.
%>%group_by(States)%>%summarize(`Average FTE Before MWL`=mean(fte, na.rm=T),
ck94`Average FTE After MWL`=mean(fte2, na.rm=T))
## # A tibble: 2 x 3
## States `Average FTE Before MWL` `Average FTE After MWL`
## <chr> <dbl> <dbl>
## 1 NJ 17.1 17.6
## 2 PA 19.9 17.5
=(17.6-17.1)-(17.5-19.9)
DiD_fte DiD_fte
## [1] 2.9
The estimates are the same: 0.48 for the minimum wage and 2.9 for the FTE. Establishing a significance level of 5%, the results for FTE are not statistically significant.
library(fixest)
<-readRDS("ck94_panel.RDS")
ck94_panel<-ck94_panel%>%mutate(post=ifelse(wave==2,1,0),
ck94_paneltreat=state,
dint=post*treat)
<-feols(wage_st~dint+post+treat, data=ck94_panel)
reg_wage<-feols(fte~dint+post+treat, data=ck94_panel)
reg_fte
etable(reg_wage, reg_fte)
## reg_wage reg_fte
## Dependent Var.: wage_st fte
##
## (Intercept) 4.630*** (0.0317) 19.95*** (1.019)
## dint 0.4814*** (0.0507) 2.914. (1.611)
## post -0.0127 (0.0456) -2.407. (1.446)
## treat -0.0180 (0.0353) -2.884* (1.135)
## _______________ __________________ ________________
## S.E. type IID IID
## Observations 779 801
## R2 0.40726 0.00805
## Adj. R2 0.40497 0.00431
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
TWFE equivalence:
<-feols(wage_st~dint|state+wave, se="standard", data=ck94_panel)
fe_wage<-feols(fte~dint|state+wave, se="standard", data=ck94_panel)
fe_fte
etable(fe_wage, fe_fte)
## fe_wage fe_fte
## Dependent Var.: wage_st fte
##
## dint 0.4814*** (0.0507) 2.914. (1.611)
## Fixed-Effects: ------------------ --------------
## state Yes Yes
## wave Yes Yes
## _______________ __________________ ______________
## S.E. type IID IID
## Observations 779 801
## R2 0.40726 0.00805
## Within R2 0.10437 0.00409
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Results barely change when adding the covariates/are robust to the inclusion of controls - those controls are uncorrelated with the treatment.
<-feols(wage_st~dint+chain+co_owned|state+wave, se="standard", data=ck94_panel)
fe_wage_cov<-feols(fte~dint+chain+co_owned|state+wave, se="standard", data=ck94_panel)
fe_fte_cov
etable(fe_wage_cov, fe_fte_cov)
## fe_wage_cov fe_fte_cov
## Dependent Var.: wage_st fte
##
## dint 0.4777*** (0.0497) 2.962. (1.600)
## chain 0.0398*** (0.0091) -0.1216 (0.2951)
## co_owned 0.0489* (0.0211) -2.272*** (0.6831)
## Fixed-Effects: ------------------ ------------------
## state Yes Yes
## wave Yes Yes
## _______________ __________________ __________________
## S.E. type IID IID
## Observations 779 801
## R2 0.43017 0.02346
## Within R2 0.13898 0.01956
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Within New Jersey, wages slightly contracted at high-wage stores and expanded at the low-wage stores. The same happened with full-time equivalent employment.
Just like the NJ and PA results, the within NJ estimates show that employment increased after the new minimum wage law. The FTE change in high-wage NJ stores was -4.7, while the FTE change in Pennsylvania was -2.4.
Results in the paper are different (-2.16 in high-wage NJ stores and -2.28 in PA), so I will double-check the dataset. Overall, the values are similar for those two groups that shouldn’t be affected by the new minimum wage law, providing a robustness check for NJ-PA results.
<-ck94%>%filter(state==1)
NJ<-NJ%>%mutate(treated=ifelse(wage_st<=5, 1, 0))
NJ
%>%group_by(treated)%>%summarize(`Average Wages Before MWL`=mean(wage_st, na.rm=T),
NJ`Average Wages After MWL`=mean(wage_st2, na.rm=T))
## # A tibble: 3 x 3
## treated `Average Wages Before MWL` `Average Wages After MWL`
## <dbl> <dbl> <dbl>
## 1 0 5.30 5.14
## 2 1 4.54 5.08
## 3 NA NaN 5.06
<-(5.08-4.54)-(5.14-5.30)
DiD_NJ_wage DiD_NJ_wage
## [1] 0.7
%>%group_by(treated)%>%summarize(`Average FTE Before MWL`=mean(fte, na.rm=T),
NJ`Average FTE After MWL`=mean(fte2, na.rm=T))
## # A tibble: 3 x 3
## treated `Average FTE Before MWL` `Average FTE After MWL`
## <dbl> <dbl> <dbl>
## 1 0 21.8 17.1
## 2 1 16.6 17.3
## 3 NA 17.0 22.5
<-(17.3-16.6)-(17.1-21.8)
DiD_NJ_fte DiD_NJ_fte
## [1] 5.4
The new minimum wage law in NJ should not affect restaurants in PA. Still, the difference-in-differences estimate gives an increase in wages and a decrease in full-time equivalent employment. The increase in wages is driven by the sharp decline in hourly salary at high-wage stores in PA. The decrease in FTE is partly due to the reduction of employment at low-wage restaurants and the increase in fte
at high-wage stores.
It is important to have in mind that, overall, full-time equivalent employment in PA decreased. David Card and Alan Krueger speculate that the worsening of the economies of the middle-Atlantic states during 1992 was the reason for that. However, suppose the economy of Pennsylvania is getting worse while the economy in New Jersey is stable throughout the study period. In that case, it is hard to defend their main identification assumption: common trends in employment. Using difference-in-differences as a research design, we assume that there are no time-variant unit-specific unobservables. In this case, Pennsylvania may not provide a very good measure of counterfactual employment rates in NJ in the absence of minimum wage change.
<-ck94%>%filter(state==0)
PA<-PA%>%mutate(treated=ifelse(wage_st<=5, 1, 0))
PA
%>%group_by(treated)%>%summarize(`Average Wages Before MWL`=mean(wage_st, na.rm=T),
PA`Average Wages After MWL`=mean(wage_st2, na.rm=T))
## # A tibble: 3 x 3
## treated `Average Wages Before MWL` `Average Wages After MWL`
## <dbl> <dbl> <dbl>
## 1 0 5.38 4.88
## 2 1 4.59 4.60
## 3 NA NaN 4.58
<-(4.60-4.59)-(4.88-5.38)
DiD_PA_wage DiD_PA_wage
## [1] 0.51
%>%group_by(treated)%>%summarize(`Average FTE Before MWL`=mean(fte, na.rm=T),
PA`Average FTE After MWL`=mean(fte2, na.rm=T))
## # A tibble: 3 x 3
## treated `Average FTE Before MWL` `Average FTE After MWL`
## <dbl> <dbl> <dbl>
## 1 0 16.1 19.6
## 2 1 20.3 17.7
## 3 NA 17.9 11.7
<-(17.7-20.3)-(19.6-16.1)
DiD_PA_fte DiD_PA_fte
## [1] -6.1
Common sense dictates that more police on the streets reduce criminal activity. It is also a prediction from the standard model of the economics of crime, whenever that increase in policing reflects a higher probability of apprehension perceived by offenders (Becker 1968). Nevertheless, to establish a causal effect between those two, you need to break the circle: more crime leads to more police on the streets. One way to do it is through natural experiments.
Draca, Machin and Witt (2011) investigated the police intervention that emerged after the terrorist attacks on London in July 2005 called “Operation Theseus.” In the following six weeks after the attacks, some boroughs in central London experienced a 34% increase in policing. Throughout the period policing was intensified, the number of crimes dropped significantly in these areas under intense monitoring. Their results indicate that an increase of 10% of the police presence has reduced crimes by 3 to 4%, on average.
Download part of their data here and answer the following:
Variable | Definition |
---|---|
ocu | Borough id |
week | Weeks from January 1, 2004, to December 31, 2005 |
tot | Total number of crimes |
h | Total policing hours |
pop | Borough’s population |
crimepop | Total number of crimes per 1,000 people |
hpop | Policing hours per 1,000 people |
To answer most of the questions, you will work with a subset of the available data. In particular, the focus is on the weeks between July 8, 2004 - August 19, 2004 (one year before the terrorist attack/pre-treatment period) and July 7, 2005 - August 18, 2005 (treatment period). Filter the data for weeks>=28 & weeks<=33
(before) and weeks>=80 & weeks<=85
(after).
Define the treatment and control groups creating the dummy treatment
that takes on 1 if ocu==1|ocu==2|ocu==3|ocu==6|ocu==14
- these are the treated boroughs located in central London - and zero otherwise. Also, define the dummy post
that takes on 1 if weeks>=80
and zero otherwise.
What is the difference-in-differences estimate of the impact of the terrorist attack on policing levels (hpop
)? What is the difference-in-differences estimate of the effects of the terrorist attack on total crime (crimepop
)?
Using the full dataset, plot the evolution of average policing hours per 1,000 people in treated (treatment==1
) and the control (treatment==0
) boroughs from January 2004 to December 2005. Do the same for average crime per 1,000 people. What can you say about the common trends assumption in this setting?
Hint: average out hpop
and crimepop
using group_by
and summarize()
. You want to group_by()
treatment status and also week.
\[\text{log(crimepop)}_{it}= \beta \text{Dint}_{it}+ Week_{t}+Borough_{i}+ \varepsilon_{it}\]
\[\text{log(hpop)}_{it}= \gamma \text{Dint}_{it}+ Week_{t}+Borough_{i}+ \varepsilon_{it}\]
where Dint
is the interaction between treatment
(treated boroughs) and post
(the treatment period).
Time to calculate the police-crime elasticity \(\eta\) and interpret the results. \(\beta\) represents the percentage average decrease in crimes, and \(\gamma\) represents the percentage average increase in policing hours during the high-alert six weeks in London. Get \(\eta\) by diving \(\frac{\beta}{\gamma}\). Then, interpret this result.
Can you think about any issue that could affect the identification of the causal effect of police on crime in their setting?
library(tidyverse)
setwd("D:/OneDrive - University of Illinois - Urbana/Causal Inference/ECON 474 Spring 2022/HW/HW3")
<-readRDS("london.RDS")
london<-london%>%filter(week>=28 & week<=33 | week>=80 & week<=85) london_sub
There are (at least) two ways to do that. You can either use the function case_when()
or the regular ifelse()
to identify both treatment
and post
. Using case_when()
, the argument TRUE~0
places zeros for all the boroughs and weeks that do not satisfy the conditions you set as ~1
. You can also combine mutate()
with ifelse()
- then you don’t need to attach columns with $
.
<-london_sub%>%
london_submutate(treatment=case_when(
==1|ocu==2|ocu==3|ocu==6|ocu==14 ~ 1,
ocuTRUE~0),
post=case_when(
post=week>=80 ~ 1,
TRUE~0))
$treatment2<-ifelse(london_sub$ocu==1|
london_sub$ocu==2|
london_sub$ocu==3|
london_sub$ocu==6|
london_sub$ocu==14, 1, 0)
london_sub
$post2<-ifelse(london_sub$week>=80, 1, 0)
london_sub
all.equal(london_sub$treatment, london_sub$treatment2)
## [1] TRUE
all.equal(london_sub$post, london_sub$post2)
## [1] TRUE
%>%
london_subgroup_by(treatment, post)%>%
summarize(crime=mean(crimepop),
police=mean(hpop))
## # A tibble: 4 x 4
## # Groups: treatment [2]
## treatment post crime police
## <dbl> <dbl> <dbl> <dbl>
## 1 0 0 1.99 82.9
## 2 0 1 1.98 85.4
## 3 1 0 4.02 169.
## 4 1 1 3.58 242.
#### Or you can do this
mean(london_sub$crimepop[london_sub$treatment==1 & london_sub$post==1])
## [1] 3.58271
mean(london_sub$crimepop[london_sub$treatment==1 & london_sub$post==0])
## [1] 4.017104
mean(london_sub$crimepop[london_sub$treatment==0 & london_sub$post==1])
## [1] 1.977582
mean(london_sub$crimepop[london_sub$treatment==0 & london_sub$post==0])
## [1] 1.991956
### Policing hours
mean(london_sub$hpop[london_sub$treatment==1 & london_sub$post==1])
## [1] 241.8959
mean(london_sub$hpop[london_sub$treatment==1 & london_sub$post==0])
## [1] 169.0502
mean(london_sub$hpop[london_sub$treatment==0 & london_sub$post==1])
## [1] 85.44319
mean(london_sub$hpop[london_sub$treatment==0 & london_sub$post==0])
## [1] 82.85734
The difference-in-differences estimate for crimepop
is:
\[\underbrace{(\underbrace{3.58}_{After}-\underbrace{4.02}_{Before})}_{\text{Treatment Group}}-\underbrace{(\underbrace{1.98}_{After}-\underbrace{1.99}_{Before})}_{\text{Control Group}}=-0.43\]
The difference-in-differences estimate for hpop
is:
\[\underbrace{(\underbrace{241.89}_{After}-\underbrace{169.05}_{Before})}_{\text{Treatment Group}}-\underbrace{(\underbrace{85.44}_{After}-\underbrace{82.85}_{Before})}_{\text{Control Group}}=70.259\]
One can observe the pre-treatment trends of policing hours and crime in treatment and control groups to evaluate whether or not it is heroic to assume common trends. In this context, I would say it is alright - we need to consider that crime is highly volatile. The hpop
and crimepop
trends before week 80 (behind the dashed line) are similar for control and treatment groups.
library(ggthemes)
<-london%>%
londonmutate(treatment=case_when(
==1|ocu==2|ocu==3|ocu==6|ocu==14 ~ 1,
ocuTRUE~0))
<-london%>%group_by(treatment, week)%>%summarize(police_hours=mean(hpop), crime=mean(crimepop))
data_plot<-data_plot%>%mutate(status=ifelse(treatment==1, "Treatment", "Control"))
data_plot
<-ggplot()+
plot1geom_line(data=data_plot,
aes(x=week, y=police_hours, col=status),
size=1.4)+
scale_color_fivethirtyeight("Treatment Status")+
theme_fivethirtyeight()+
labs(x = "Week", y="Policing Hours per 1,000 people")+
geom_vline(xintercept = 80, linetype="dashed")+
theme(axis.text=element_text(size=12),
axis.title=element_text(size=12,face="bold"))
plot1
<-ggplot()+
plot2geom_line(data=data_plot,
aes(x=week, y=crime, col=status),
size=1.4)+
scale_color_fivethirtyeight("Treatment Status")+
theme_fivethirtyeight()+
labs(x = "Week", y="Total crime per 1,000 people")+
geom_vline(xintercept = 80, linetype="dashed")+
theme(axis.text=element_text(size=12),
axis.title=element_text(size=12,face="bold"))
plot2
Another way to see whether control and treatment groups are comparable on pre-treatment outcomes is through an event-study plot with leads and lags of the treatment effect. Ideally, those confidence interval bars during the pre-treatment period (weeks before the dashed line) should include the x-axis (0 value). These results are different from the original paper since the authors use the year-on-year, seasonally differenced data.
library(fixest)
= feols(hpop~i(week, treatment, ref=79)|ocu+week, cluster=~ocu, data=london)
hpop_plot #coefplot(florida_plot)
iplot(hpop_plot, main="The Effect of Terrorist Attack on Policing Hours per 1,000 people")
= feols(crimepop~i(week, treatment, ref=79)|ocu+week, cluster=~ocu, data=london)
crime_plot #coefplot(florida_plot)
iplot(crime_plot, main="The Effect of Terrorist Attack on Total Crimes per 1,000 people")
<-london_sub%>%
london_submutate(dint=treatment*post)
<-feols(log(crimepop)~dint|ocu+week, data=london_sub)
reg_crime<-feols(log(hpop)~dint|ocu+week, data=london_sub)
reg_police
etable(reg_crime, reg_police)
## reg_crime reg_police
## Dependent Var.: log(crimepop) log(hpop)
##
## dint -0.1088*** (0.0272) 0.3363*** (0.0283)
## Fixed-Effects: ------------------- ------------------
## ocu Yes Yes
## week Yes Yes
## _______________ ___________________ __________________
## S.E.: Clustered by: ocu by: ocu
## Observations 384 384
## R2 0.96237 0.98725
## Within R2 0.07913 0.60227
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
The DiD estimates point to an average increase in policing hours by 33.63% and an average decrease in crime by 10.88%. Hence, the police-crime elasticity is equal to \(\eta=\frac{-10.88}{33.63}=0.32\), i.e., a 10% increase in policing can reduce the total number of crimes by 3.2%.
Some boroughs in the control group are very close to the treated region, which is a potential contamination source. If crime is going to the next block, moving from treated to control areas, that would artificially increase the estimated effect. In addition, there is also a problem if people change their behavior after a terrorist attack. For example, if people avoid the treated blocks, that would also reduce crime opportunities. The authors address these potential threats in the paper.