1. Center for Financial Studies at the Goethe University
PhD Mini-course
Frankfurt, 25 January 2013
Financial Networks
IV. Analyzing and visualizing
Exposures
Dr. Kimmo Soramäki
Founder and CEO
FNA, www.fna.fi
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 identify
important/fragile countries
3
4. I. Loading data
• Source data at BIS Website:
• Data in FNA list format (link)
# load arc list into FNA as a network
loada -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
4
5. CSV file for exposure data
Comment rows
# The data shows banking system exposures to particular countries. (1 and d 2)
# See http://www.bis.org/publ/qtrpdf/r_qt1006y.htm for details.
Empty row (3)
Header field (with
net_id,arc_id,from_id,to_id,value
value ‘net_id’)
2010-1Q,Australia-Austria,Australia,Austria,211 Header row (4)
2010-1Q,Australia-Belgium,Australia,Belgium,1128
2010-1Q,Australia-Canada,Australia,Canada,12231
2010-1Q,Australia-Chile,Australia,Chile,335
2010-1Q,Australia-France,Australia,France,8865
Field (with value
2010-1Q,Australia-Germany,Australia,Germany,11702
‘2010-1Q’)
2010-1Q,Australia-Greece,Australia,Greece,12
2010-1Q,Australia-India,Australia,India,2180
2010-1Q,Australia-Ireland,Australia,Ireland,3583 Data rows (5-)
2010-1Q,Australia-Italy,Australia,Italy,8657
2010-1Q,Australia-Japan,Australia,Japan,4035
2010-1Q,Australia-Netherlands,Australia,Netherlands,5970
2010-1Q,Australia-Portugal,Australia,Portugal,776
2010-1Q,Australia-Spain,Australia,Spain,2776
2010-1Q,Australia-Sweden,Australia,Sweden,773
2010-1Q,Australia-Switzerland,Australia,Switzerland,3366
2010-1Q,Australia-Turkey,Australia,Turkey,63
Column Delimiter (,)
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]
6
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.
7
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)
8
9. II. Calculating Degree/Strength
degree -p value -saveas total_exposure
• 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'.
9
10. III. Making first visualization
viz
• 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
10
13. Principles
All details must convey unique meaning
1. High data-ink ratio
2. No chartjunk
3. Correct dimensions
4. 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'.
14
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'.
15
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'.
16
17. Range and Domain
Default Domain
Range lower bound Range upper bound
Smallest data value Largest data value
-0.7 0.9
Specified domain
Range lower bound Range upper bound
-1 1
Smallest data value Largest data value
Fixed range and bound allow comparison across data sets and across networks
17
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'.
18
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'.
19
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'.
20
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'.
21
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'.
22
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'.
23
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.
24
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
25
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'.
26
27. Relative Exposure to GDP
# Load GDP data as vertex properties
loadvp -file GDP-2012.csv
# Drop Turkey and Greece for which data is not available full series
dropv -v Greece,Turkey
# Calculate Exposure/GDP
calcap -e 10000*value/source:gdp -saveas GDP_relative_value
# Sum up relative exposure to country level
degree -p GDP_relative_value -direction out -saveas relative_debt
27