Skip to content

Commit

Permalink
add final table appendix and closes #1, closes #2, closes #3, and closes
Browse files Browse the repository at this point in the history
  • Loading branch information
ariedamuco committed Sep 29, 2023
1 parent 59ccc62 commit 5245ad7
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 28 deletions.
63 changes: 43 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,46 @@ Data files needed to generate all the replication is included in the data folder
| `previous_consip.dta` | Own/Derived | Yes |


### The main.txt contains the file order and commands to run from the command line.
# Computational requirements

### Software requirements

- Stata (code was last run with version 16)
- `estout` (as of 26apr2022)
- `reghdfe` (as of 08aug2023)
- `pdslasso` (as of 04sept2018)
- `outreg` (as of 18sep2015)
- `outtable` (as of 03aug2014)
- `listtab` (as of 04 November 2012)
- `ftools` (as of 08aug2023)

and `did_multiplegt`, `lassopack`, `egenmore` , `moremata`, `blindschemes`, `scheme-burd`.


- the program "`install-packages.do`" combines setup as in https://gist.github.com/larsvilhuber/8ead0ba85119e4085e71ab3062760190
and configuration as in
https://gist.github.com/larsvilhuber/c3dddbcf73e7534a22e3583b3422d7c5
will install all dependencies locally, and should be run once.

- Python 3.10.9

#### Summary

- The code is relatively fast to run and you should be able to run everything within one hour.

- Figures are saved in .pdf in
line with the AEA, guidelines, however, the colors might change if the code is run from bash rather than Stata terminal

- Table 4, and the resulting Figure 4 and Table D1 (robustness to Table 4) depend on setting the seed and the code may
provide different results depending on the operating system. This issue raises because we are dealing with multiple transactions on the same date for the same identifier, Stata selects randomly which dates go first every time the code is run.
Hence, we set a seed and use a uniformly distributed variable to break the ties (on which date gets ordered first).


#### Details

The code was last run on a **8-core Chip Apple M1 with MacOS version 12.5**.

### The main.sh contains the file order and commands to run from the command line.

The provided code reproduces:
- All numbers provided in text in the paper
Expand All @@ -61,11 +100,11 @@ The provided code reproduces:
| Table E2 | appendix-het-pb-class.do |
| Table E3 | appendix-het-quantity.do |
| Table E4 | fe-quartiles.do |
| Table F1 | appendix-event_studies.do |
| Table F1 | appendix-event-study.do |
| Table F2 | did-complex-simple.do |
|-------------------|--------------------------|
| Figure 1 | goods_deals.do |
| Figure 2 | event_studies.do|
| Figure 2 | event_study.do|
| Figure 3 | competence.do|
| Figure 4 | previous-consip-coefficient-estimates.do |
|-------------------|--------------------------|
Expand All @@ -74,33 +113,17 @@ The provided code reproduces:
| Figures D1 | robustness-drop-one.do|
| Figure D2 |cofficient-estimates-DH.do |
| Figure F1 | appendix-event-study.do |
| Figure F2 | appendix-event-study-end-deal.do |
|-------------------|--------------------------|

# Description of programs/code


- Programs in `code/intermediate` will prepare the data and files needed to run the tables and figures above
- Programs in `code/tables` will generate all tables included the paper and appendix
- Programs `code/figures` will generate all figures included the paper and appendix
- The code in `main.sh` will run all necessary files for this replication package

```
Stata commands needed to run the files:
reghdfe version 5.7.3 13nov2019
esttab version 2.0.9 06feb2016 Ben Jann
estout version 3.21 19aug2016 Ben Jann
version 2.3.5 05feb2016 Ben Jann
frmttable version 1.31 12jul2015 by John Luke Gallup
pdslasso package 1.1 15jan2019
Also make sure to install the following:
ssc install moremata # Prerequisite to implement De Chaisemartin and d’Haultfoeuille (2020)
ssc install did_multiplegt # Implements De Chaisemartin and d’Haultfoeuille (2020)
ssc install blindschemes #For plots
set scheme burd #For plots
References
Expand Down
45 changes: 45 additions & 0 deletions code/figures/appendix-event-study-end-deal.do
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
set scheme plotplain

use "data/consip.dta", clear
drop if consip==1

include "code/intermediate/good-char.do"
gen date_q=qofd(dofm(ym(year, month)))
gen edeal1 =qofd(deal_start1)

****** End of a deal: version revision
preserve
gen ldeal1 =qofd(deal_end1)
gen ldeal2 =qofd(deal_end2)
gen ldeal3 =qofd(deal_end3)

gen recenter_end1 = .
replace recenter_end1 = date_q - ldeal1 if date<deal_start2
replace recenter_end1 = -1 if date<=deal_end1 & recenter_end1==0
replace recenter_end1= . if recenter_end1<0 & activeD==0

gen recenter_end2 = .
replace recenter_end2 = date_q - ldeal2 if date>deal_end1 & date<deal_start3
replace recenter_end2 = -1 if date<=deal_end2 & recenter_end2==0
replace recenter_end2= . if recenter_end2<0 & activeD==0

gen recenter_end3 = .
replace recenter_end3 = date_q - ldeal3 if date>deal_end2
replace recenter_end3 = -1 if date<=deal_end3 & recenter_end3==0
replace recenter_end3= . if recenter_end3<0 & activeD==0
replace recenter_end3= . if recenter_end3>=0 & activeD==1

gen centering_var = recenter_end1 if recenter_end2==.&recenter_end3==.
replace centering_var = recenter_end2 if recenter_end2!=.&recenter_end3==.
replace centering_var=recenter_end3 if recenter_end3!=.

local first_lead -4
local last_lag 4
local normalize_lead = 0
include "code/intermediate/leads-lags.do"


twoway (scatter coef leads_lags , mcolor(navy) lcolor(navy)) (line ci_low leads_lags , lpattern(dash)) /*
*/(line ci_high leads_lags , lpattern(dash)), graphregion(color(white)) xline(5) yline(0, lcolor(black)) ylabel(-1(.2)1) xtitle("Quarters to/from event") xlabel(1 "-4" 2 "-3" 3 "-2" 4 "-1" 5 "0" 6 "1" 7 "2" 8 "3" 9 "4") legend(off)
graph export "output/figures/es_end_all.pdf", replace

File renamed without changes.
2 changes: 1 addition & 1 deletion code/figures/goods_deals.do
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ merge 1:m good date_m using `purchases'
format date_m %tm

twoway (rbar deal_start1 deal_end1 good , horizontal barwidth(.45) color(gs13)) (rbar deal_start2 deal_end2 good , horizontal barwidth(.45) color(gs13)) (rbar deal_start3 deal_end3 good , horizontal barwidth(.45) color(gs13))(scatter good date_m if _m==3 & date<deal_start1, mcolor(plr1) mlwidth(tiny) msize(tiny) mstyle(diamond)) (scatter good date_m if _m==3 & date>=deal_start1 & [activeD==0|activeD==1], mcolor(plb1) mstyle(diamond) mlwidth(tiny) msize(tiny)), xline(528 540) yla(1/13, valuelabel tlength(0) ang(h) labsize(small)) xlabel(468 "January 1999" 480 "January 2000" 492 "January 2001" 504 "January 2002" 516 "January 2002" 528 "January 2003" 540 "January 2004" 552 "January 2005", labsize(small) angle(45)) ytitle("") xtitle("") plotr(m(large)) graphregion(fcolor(white)) legend(position(6) size(small) order( 4 "Pre-Consip purchases" 5 "Post-Consip purchases" 1 "Consip deals") cols(1))
graph export "output/figures/goods_deals.pdf", replace
graph export "output/figures/goods_deals.png ", replace

File renamed without changes.
Binary file modified data/consip.dta
Binary file not shown.
Binary file modified data/previous_consip.dta
Binary file not shown.
12 changes: 5 additions & 7 deletions main.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#! /bin/bash
#Please run first intermediate files, then tables and finally figures. While the order below is not strictly necessary, some figures are generated from table outputs

#alias stata-mp="c:/'Program Files'/Stata18/StataMP-64.exe" - to run on a Windows machine
#Intermediate files

stata-mp -e code/install-packages.do
#stata-mp -e code/install-packages.do

stata-mp -e code/intermediate/create-data.do #creates main data for analysis
stata-mp -e code/intermediate/good-char.do #stores locals for regressions
Expand All @@ -26,15 +26,15 @@ stata-mp -e code/tables/appendix-het-good.do #Appendix Table E1
stata-mp -e code/tables/appendix-het-pb-class.do #Appendix Table E2
stata-mp -e code/tables/appendix-het-quantity.do #Appendix Table E3
stata-mp -e code/tables/fe-quartiles.do #Appendix Table E4
stata-mp -e code/tables/appendix-event_study.do #Appendix Table F1
stata-mp -e code/tables/appendix-event-study.do #Appendix Table F1
stata-mp -e code/tables/did-complex-simple.do #Appendix Table F2


python code/tables/clean-tables.py #clean tables about previous Consip experience

#Figures
stata-mp -e code/figures/goods_deals.do #Figure 1
stata-mp -e code/figures/event_studies.do #Figure 2
#stata-mp -e code/figures/event_studies.do #Figure 2
stata-mp -e code/figures/competence.do #Figure 3
stata-mp -e code/figures/previous-consip-coefficient-estimates.do #Figure 4

Expand All @@ -44,7 +44,5 @@ stata-mp -e code/figures/descriptives_cutoffs.do #Figures B1 & B2
stata-mp -e code/figures/robustness-drop-one.do #Figures D1
stata-mp -e code/figures/cofficient-estimates-DH.do #Figure D2
stata-mp -e code/figures/appendix-event-study.do #Figure F1


deactivate
stata-mp -e code/figures/appendix-event-study-end-deal.do #Figure F2

0 comments on commit 5245ad7

Please sign in to comment.