financial networks iv. analyzing and visualizing exposures

Post on 27-Jan-2015

106 Views

Category:

Economy & Finance

1 Downloads

Preview:

Click to see full reader

DESCRIPTION

Fourth lecture of a PhD level course on "Financial Networks" at Center for Financial Research at Goethe University, Frankfurt.

TRANSCRIPT

Dr. Kimmo SoramäkiFounder and CEOFNA, www.fna.fi

Center for Financial Studies at the Goethe UniversityPhD Mini-course Frankfurt, 25 January 2013

Financial Networks

IV. Analyzing and visualizingExposures

2

Tutorials

• Tutorial 1 – Loading Networks into FNA• Tutorial 2 – Managing Data in FNA• Tutorial 3 – Network Summary Measures• Tutorial 4 – Centrality Measures• Tutorial 5 – Connectedness and Components• Tutorial 6 – Network Visualization• Tutorial 7 – Correlation Networks• Tutorial 8 – Payment System Simulations• Tutorial 9 – Analyzing Cross-Border Banking Exposur

es

3

Cross-border banking exposures

• The BIS Consolidated Banking statistics report banks’ foreign claims for a network of 26 countries (available on the BIS statistics page, Table 9D).

• E.g. The exposures by the Austrian banking sector against borrowers in Italy are 16.5 billion in 2Q2012

• Aim to explore and identifyimportant/fragile countries

4

I. Loading data

• Source data at BIS Website:• Data in FNA list format (link)

# load arc list into FNA as a networkloada -file bis-updated-2012.csv -preserve false

• loada -command loads arcs and their properties from a text file• Creates referenced vertices if they do not exist• Retains all existing arc property values (does not overwrite

any existing data)• -preserve parameter defines whether to keep (true) or

overwrite (false) existing networks in database. By default 'true'.

• Network, source vertex and destination vertex are mandatory, all other fields are loaded as property values

# The data shows banking system exposures to particular countries.# See http://www.bis.org/publ/qtrpdf/r_qt1006y.htm for details.

net_id,arc_id,from_id,to_id,value2010-1Q,Australia-Austria,Australia,Austria,2112010-1Q,Australia-Belgium,Australia,Belgium,11282010-1Q,Australia-Canada,Australia,Canada,122312010-1Q,Australia-Chile,Australia,Chile,3352010-1Q,Australia-France,Australia,France,88652010-1Q,Australia-Germany,Australia,Germany,117022010-1Q,Australia-Greece,Australia,Greece,122010-1Q,Australia-India,Australia,India,21802010-1Q,Australia-Ireland,Australia,Ireland,35832010-1Q,Australia-Italy,Australia,Italy,86572010-1Q,Australia-Japan,Australia,Japan,40352010-1Q,Australia-Netherlands,Australia,Netherlands,59702010-1Q,Australia-Portugal,Australia,Portugal,7762010-1Q,Australia-Spain,Australia,Spain,27762010-1Q,Australia-Sweden,Australia,Sweden,7732010-1Q,Australia-Switzerland,Australia,Switzerland,33662010-1Q,Australia-Turkey,Australia,Turkey,63

Comment rows (1 and d 2)

Empty row (3)

Header row (4)

Data rows (5-)

Column

Field (with value ‘2010-1Q’)

Header field (with value ‘net_id’)

Delimiter (,)

CSV file for exposure data

6

file -parameter in loada

• Arc file (-file) : File from which to read arcs. Referenced vertices that do not exist are created automatically. To skip lines or use non-default field delimiter use the 'delimiter' and 'skiplines' arguments. Mandatory.

• The -file parameter has two important qualifiers– data delimiter : It can be 'comma', 'semicolon', 'whitespace', 'tab'.

The default separator is comma.– skiplines : is a list of lines to be skipped when reading the file. The

list can be given as comma separated integers, or may also include integer ranges as in skiplines=2-10,12 or skiplines=1-3,5-6. By default, all empty lines and lines starting with # are skipped.

• First read line must contain headers

• e.g. loada -file tabbeddata.txt[delimiter=tab;skiplines=1,3-5]

7

Other parameters in loada

• Network id column (-ncol) : Column name that contains network id. Optional. By default 'net_id'.

• Source column (-svcol) : Column name that contains source vertex. Optional. By default 'from_id'.

• Destination column (-dvcol) : Column name that contains destination vertex. Optional. By default 'to_id'.

• Decimal Separator (-decimalseparator) : Decimal separator used in the input file, commonly '.' or ','. Default value corresponds to 'Decimal separator' setting in 'Default format settings'. Optional.

• Date format (-dateformat) : Date format used in files. Default value corresponds to 'Date format' setting in 'Default format settings'. Optional.

• Time format (-timeformat) : Time format to use. Default value corresponds to 'Time format' setting in 'Default format settings'. Optional.

8

Other input data formats:

• GraphML (loadgraphml)• Matrix (loadmatrix)

• Network elements: arcs (loada), vertices (loadv) networks (loadn)

• Property data for existing network elements in database:for arcs (loadap), for vertices (loadvp) and networks (loadnp)

• Network series (loads)

9

II. Calculating Degree/Strength

• Weight property (-p) : Property name for arc weights. – For missing and NaN values 0 is used. – Optional. If none given, simple degree is calculated

• Direction of arcs (-direction) : Direction of arcs to consider for each vertex. – Allowed values: [in, out, both] – Optional, By default 'out'

• Save as property (-saveas) : Property name of saved result. Optional. By default 'degree'.

degree -p value -saveas total_exposure

10

III. Making first visualization

• viz -command is the simplest visualization command

• It uses simple logic to determine layout algorithm to be used– istree -> tree layout– isbipartite -> bipartite layout– Fruchterman-Reingold layout

• Creates an independent .html document that contains the visualization and all the network data

• Other layouts: circle, circletree, distance, sammon, any external coordinates

viz

11

12

Network Visualization

Principles

All details must convey unique meaning

1. High data-ink ratio2. No chartjunk3. Correct dimensions4. No duplication

(from Edward Tufte 2001)

14

Directed vs. undirected

• Display curved arcs (-curvedarcs) : If true, opposite links are shown as curved arcs between the two vertices. If false, opposite arcs are shown as straight lines on top of each other. Optional. By default 'true'.

• Display arrows (-arrows) : If true, links have arrows denoting link direction. If false, no arrows are shown. Optional. By default 'false'.

15

Vertex Color

• Vertex color (-vcolor) : Vertex property defining vertex colors. The property values can be any of the following:

– Hexadecimal color code, such as #8B0000 for dark red.– Valid color name. Such as 'darkred'.– Number. Color ranges from gray (lowest value) to dark red (highest

value) by a 100-step gradient.– Any string. A color from the palette is used for each unique string and

same strings get same color.

• Default vertex color (-vcolordefault) : Default vertex color used in case no arc color data is mapped and in case of missing data. Optional. By default 'black'.

16

Vertex Size

• Vertex size (-vsize) : The vertex property used for establishing vertex size. Vertex with smallest value (negative or positive) has smallest size, and vertex with largest value (negative or positive) has largest size. By default all vertices are same size. Optional. Data type: Numeric.

• Vertex height (-vheight) : The vertex property used for establishing vertex height. Specifications as with size.

• Vertex width (-vwidth) : The vertex property used for establishing vertex width. As with size.

• Vertex size range (-vsizerange) : Range of vertex sizes (in pixels). Optional. By default '3-20'.

• Vertex size domain (-vsizedomain) : Domain for vertex size. The vertex with the lowest value has the lower bound size defined by 'Vertex size range' and vertex with highest value has the upper bound size. Optional.

• Default vertex size (-vsizedefault) : Default vertex size in case size is not defined by data. Any value between 0.0 to 100.0 (inclusive). Optional. By default '3.0'.

17

Range and Domain

Smallest data value Largest data value

Default Domain

Range lower bound Range upper bound

Smallest data value Largest data value

Specified domain

Range lower bound Range upper bound

-0.7 0.9

-1 1

Fixed range and bound allow comparison across data sets and across networks

18

Vertex transparency

• Vertex transparency (-vtransparency) : The vertex property defining vertex transparency. Higher values are less transparent. Optional. Data type: Numeric.

• Vertex transparency range (-vtransparencyrange) : Range of vertex transparency. Optional. By default '0.2-0.8'.

• Vertex transparency domain (-vtransparencydomain) : Domain for vertex transparency. The vertex with the lowest value has the lower bound transparency defined by 'Vertex transparency range' and vertex with highest value has the upper bound transparency. Optional.

• Default vertex transparency (-vtransparencydefault) : Default vertex transparency in case transparency is not defined by data. Any value between 0.0 to 1.0 (inclusive). Optional. By default '0.7'.

19

Labels and hover behavior

• Vertex hover (-vhover) : Vertex property defining value shown on vertex hover. By default, nothing is shown on hover. Optional. By default none.

• Vertex label (-vlabel) : Vertex property defining vertex label. By default no label is shown. Optional. By default none.

• Arc hover (-ahover) : Name of arc property to display in arc tooltip on hover. Optional. By default none.

• Arc label (-alabel) : Name of arc property to display next to each arc. Optional. By default none.

• Label font color (-fontcolor) : The font color of arc and vertex labels. Optional. By default 'Black'.

• Label font size (-fontsize) : The font size of arc and vertex labels in pixels. Optional. By default '14'.

20

Arc width

• Arc width (-awidth) : The arc property defining arc width. Arc widths scale according to absolute value of given property, ie. values -100 and 100 have same width and are wider than arcs with values -10 and 10. Optional. Data type: Numeric.

• Arc width range (-awidthrange) : Range of arc widths (in pixels). Optional. By default '1-11'.

• Arc width domain (-awidthdomain) : Domain for arc width. The arc with the lowest value has the lower bound width defined by 'Arc width range' and arc with highest value has the upper bound width. Optional.

• Default arc width (-awidthdefault) : Default arc width in case width is not defined by data. Any value between 0.0 to 100.0 (inclusive). Optional. By default '1.0'.

21

Arc Color

• Arc color (-acolor) : Name of arc property that defines arc colors. The property values can be any of the following:

– Hexadecimal color code, such as #8B0000 for dark red.– Valid color name. Such as 'darkred'.– Number. Color ranges from light gray (lowest value) to dark gray

(highest value) by a 100-step gradient.– Any string (category). A color from the palette is used for each unique

string and same strings get same color.

• Default arc color (-acolordefault) : Default arc color used in case no arc color data is mapped and in case of missing data. Optional. By default 'black'.

22

Arc transparency

• Arc transparency (-atransparency) : The arc property defining arc transparency. Higher values are less transparent. Optional.

• Arc transparency range (-atransparencyrange) : Range of arc transparency. Optional. By default '0.2-0.8'.

• Arc transparency domain (-atransparencydomain) : Domain for arc transparency. The arc with the lowest value has the lower bound transparency defined by 'Arc transparency range' and arc with highest value has the upper bound transparency. Optional.

• Default arc transparency (-atransparencydefault) : Default arc transparency in case transparency is not defined by data. Any value between 0.0 to 1.0 (inclusive). Optional. By default '0.7'.

23

Scale

Scale allows to create comparable network layouts, similarly as domain and range comparable element sizes/width/colors.

Scale= length in pixels of distance 1 in coordinate system

• Scale (-scale) : Scale for coordinate system. Optional.

• Scale sensitivity (-scalesensitivity) : Sensitivity of scaling. Set 0 for no scaling. Any value between 0.0 to 1.0 (inclusive). Optional. By default '0.2'.

24

Filtering and sorting elements

• Network id (-id) : Id of the network to visualize. Use(*) for all networks. Optional. By default '*'.

• Show specific vertices. (-vshow) : Shows vertices according to expression criteria. Optional.

• Show specific arcs. (-ashow) : Shows arcs according to expression criteria. Optional.

• Sort networks (-sortn) : Comma separated list of network properties and order, e.g. 'vertex_id:asc'. Optional.

25

Better visualization

viz -vlabel vertex_id -vsize total_exposure -vcolordefault red -atransparency value -awidth value -npanel net_id -ahover value -fontsize 18 -vtransparencydefault 0.7 -saveas tutorial9_full

26

Other behavior• Network panel text (-npanel) : Html syntax string to show as network

description. Optional.

• Length of transition (-transition) : Speed of transition between networks (in milliseconds), 0 = immediate, 1000 = 1 second. Any value between 0 to 10000 (inclusive). Optional. By default '1000'.

• Time interval for looping frames (-loopinterval) : Time interval between automatic rotation of frames (in milliseconds), 0 = no rotation, 1000 = 1 second. Any value between 0 to 10000 (inclusive). Optional. By default '0'.

• Allow pan (-allowpan) : Allow panning of visualization. Optional. By default 'true'.

• Allow zoom (-allowzoom) : Allow zooming of visualization. Optional. By default 'true'.

• Allow rotate (-allowrotate) : Allow rotating of visualization. Optional. By default 'true'.

• Allow dragging (-allowdrag) : Allow dragging of vertices. Optional. By default 'true'.

• Slider position (-slider) : Larger than or equal to 0. Optional. By default '0'.

27

Relative Exposure to GDP

# Load GDP data as vertex propertiesloadvp -file GDP-2012.csv

# Drop Turkey and Greece for which data is not available full seriesdropv -v Greece,Turkey

# Calculate Exposure/GDP calcap -e 10000*value/source:gdp -saveas GDP_relative_value

# Sum up relative exposure to country leveldegree -p GDP_relative_value -direction out -saveas relative_debt

28

Visualize Exposure/GDP

circleviz -vsize relative_debt -vlabel vertex_id -vhover relative_debt -vsizedomain 0-0.05-vsizerange 5-20-arrows true-ahover value -awidth GDP_relative_value -atransparency GDP_relative_value-atransparencyrange 0-1 -vcolordefault red -fontsize 16 -sortv vertex_id-npanel net_id-saveas tutorial9_0

29

Which centrality metric would make sensefor the cross-border banking exposures?

Blog, Library and Demos at www.fna.fi

Dr. Kimmo Soramäki kimmo@soramaki.netTwitter: soramaki

top related