*** Course: FLS6183 *** Class: Causal Inference *** 02/2018 *** Natalia Moreira ** In this lab, we will use the example developed in chapter 2 of the book "Quantitative Social ** Science: An Introduction" - K. Imai. ** The first part of this lab follows the step-by-step of chapter 2 in order to ** calculate the difference-in-difference approach. ** The second part of this lab compares the results using the DiD approach and ** the bivariate regression approach. ** Unlike the chapter, we will stress how hypothesis tests are undertaken in both approaches. *** Part I. Difference-in-Difference clear * Define working directory cd "" * Import .csv data import delimited "minwage.csv" * Save .dta data save "minwage.dta", replace * Create dummy variables for the two states gen minwageNJ = 0 replace minwageNJ = 1 if location != "PA" gen minwagePA = 0 replace minwagePA = 1 if location == "PA" gen NJ = 0 replace NJ = 1 if location != "PA" gen PA = 0 replace PA = 1 if location == "PA" * Compare the proportion of restaurants whose wage is less than $ 5.05 tab wagebefore if minwageNJ==1 tab wageafter if minwageNJ==1 tab wagebefore if minwagePA==1 tab wageafter if minwagePA==1 * Compare the proportion of full-time employees in NJ and PA after increase the MW gen fullpropafterNJ = fullafter / (fullafter+partafter) if minwageNJ == 1 gen fullpropafterPA = fullafter / (fullafter+partafter) if minwagePA == 1 sum fullpropafterNJ fullpropafterPA * Compute the difference-in-means gen fullpropafter = fullafter / (fullafter+partafter) sort minwageNJ by minwageNJ: sum fullpropafter ttest fullpropafter, by(minwageNJ) * Full-time employment proportion in the previous period for NJ gen fullpropbefore = fullbefore / (fullbefore+partbefore) * Naive Test// Compute the difference-in-means NJ ttest fullpropbefore=fullpropafter if minwageNJ==1 return list // Returning results gen NJbeforemean = r(mu_1) gen NJaftermean = r(mu_2) gen NJdiff = NJbeforemean - NJaftermean tab NJdiff * Naive Test// Compute the difference-in-means PA ttest fullpropbefore=fullpropafter if minwagePA==1 return list gen PAbeforemean = r(mu_1) gen PAaftermean = r(mu_2) gen PAdiff = PAbeforemean - PAaftermean tab PAdiff * Testing mean difference ttest NJdiff == PAdiff *************************************************************************** *** Part II. Regression Model * We need to reshape and reload the data to use a regression to analylze the same question. use "minwage-reshaped.dta", clear * Naive regression reg fullprop NJ time * Interaction gen did = 0 replace did = time*NJ reg fullprop NJ time did * Let´s check if the results are the same calculating diff-in-diff sscinstall diff diff fullprop, t(NJ) p(time)