======================================================================	
Guide to Replication Archive for
“Market Failure in Kidney Exchange” by Nikhil Agarwal, Itai Ashlagi, Eduardo Azevedo, Clayton R. Featherstone and Ömer Karaduman
======================================================================

Repository for data analysis.
--------------------------------------

This repository generates the tables and figures reported in the
Descriptive Evidence and Data Appendix sections of the paper


A. Setup Instructions
----------------------------------------------------------------------

Analysis was run using Stata 13, R 3.5.2, GNU make 3.82, and bash
4.2.46 and tested on a 64-bit linux based machine, kernel 3.10.0.


B. Directory Structure and Included Files
--------------------------------------------------------------------------------

The directory structure for the project is as follows. Not all
directories are in the repository, since some cannot be shared while
others are for output. The directories that need to be created for
output are marked with an asterisk (*). Those with input files that
are confidential are market with two asterisks (**). The user has to
create these directories. Symbolic links wll suffice.

ado:		Stata ado files

constants:	Estimated constants in the text are outputted here.

datasets**: 	external link to encrypted location for final datasets, as
		generated by the data construction repo. See make-data
		replication files for process details.

do:		Stata do scripts
	
figures*:	Figures in the manuscript are outputted here.

intermediate-tables:	xls files that form the skeleton of tables. Scripts fill copies of
			these with numbers and then export them to pdf
			in the tables directory

log:		logs from all scripts that are run by the makefile

r:		R scripts go here
			
raw-files**:	eternal link to the encrypted location of the STAR dataset

sh:		bash utility scripts go here

tables:		Tables for the manuscript are outputted here.


Researchers interested in using our dataset should directly contact
APD, NKR and UNOS to obtain permission:

	APD (Alliance for Paired Donation, Inc.)
	PO Box 965,
	Perrysburg, OH 4352
	Main Number: 419.866.5505

	NKR (National Kidney Registry)
	PO Box 460
	Babylon, NY 11702-0460

	UNOS (United Network for Organ Sharing)
	700 N 4th St,
	Richmond, VA 23219
	Main Number: 804.782.4800


C. Code Generating Results
------------------------------------------------------------------------

In order to generate the results, one should run the makefile by
typing the command "make" in the root directory. The tables will be
saved in the tables folder, the constants in the constants folder, and
the figures in the figures folder.

The makefile runs the following Stata and R scripts.

efficiency.R: Generates Figure 1 (Market fragmentation and trends in
	      kidney exchange) and Figure 2 (Evidence of hospitals
	      performing inefficient matches), along with numbers
	      about the fraction of PKE transplants facilitated by the
	      clearinghouses and the fraction that are inefficient, as
	      discussed in Section 3.2 (Evidence of Inefficiency)

efficiency.do: Generates Table 1 (Summary Statistics for Kidney
	       Exchange Transplants)

participation.do: Generates Figures 3a and 3b (Heterogeneity in
		participation in the NKR, intensive and extensive
		margins)

summary.do: Computes Table 2 (Summary Statistics for NKR Submissions)

tx-match-quality.do: Computes the quality of the match between the
		STAR and clearinghouse datasets.  Most results are
		reported in Appendix C (Data appendix)
