Code for


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Ana Babus-Peter Kondor: Trading and information diffusion in Over-the-Counter Markets
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

at http://personal.lse.ac.uk/kondor/papers.htm

Distrubuted under the Creative Common (NC) licence.

The functions diameter.m, isconnected.m,shortest_pathDP.m, assortativity.m, degrees.m, degrees_und.m, degrees_dir.m are from the freeware MATLAB network tools prepared by Gergana Buonova and downloaded from

http://ocw.mit.edu/courses/engineering-systems-division/esd-342-network-representations-of-complex-engineering-systems-spring-2010/tools/matlab_functions.zip


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


This folder containes the code for calculating the equilibrium both in the conditional guessing game and the OTC game for any network along with welfare, expected profit etc. These codes also generate all the figures and Tables in the maintext. 

In particular,
1. For Figure 1, we run cirulantiteration

2. For Figure 2, we run welfare4_paper2

3. For Figure 3 run the following set of commands
load A12matrix.mat 
G=graph(A12+A12');
[~,order] = sort(centrality(G,'eigenvector'),'descend');
H0=reordernodes(G,order);
plot(H0)

4. We did the calibration excercise on a high performing cluster at the LSE. In particular,
a. rosigscript.m creates a grid of parameter values and saves it to rosigvec.mat.
b. gmmgran_eig.m loads one particular combination of rho and sigma from rosigvec.mat (each combination is identified by the running parameter "taskid")  and calculates the relevant moments and saves the results in a separate file. 
c. aggregation.m loads all files created in step b, and aggregates them into a file A10matrices.mat. 

(Two variants corresponding to the finest and the corsest grids we use are included, impliying that the reader can recreate these graphs without going through steps a-d.) 

d. The first part of calibration2.m loads A10matrices.mat and finds the grid point which is closest to the moments we want to match. It saves the
resulting parameter combination to file rosigecal.mat. It also calculates the implied moments at this parameter combination.

We are refining the grid and repeating the process a-d. until we are satisfied with the closeness of the match. The last output is saved to A10matrices_eig_finest.mat.

5. For Figure 4, we repeat a.-d. in point 4 on a course grid including our calibrated parameters and save the results in A10matrices_eig_corsest.mat. Then, the figures are created by the second part of calibration2.m.

6. Running gmmgrancal_eig.m recalculates all relevant variables for the calibrated parameters. It prints on the screen the spread of core and periphery dealers and on large and small trades described which is qualitatively described at the last paragraph of 5.2.2 and saves the results in file grancaldata3. gmmgrancal_eig_largerrho.m does the same for the higher rho discussed the online Appendix and saves the results in grancaldata3_largerho. 

7. Figure 5 and the corresponding plot with larger rho in the Appendix is generated by scatterplot.m.


If in doubt, please feel free to contact us.

Good luck,
Ana Babus and Peter Kondor

