ggsolvencyii

The goal of ggsolvencyii is to provide ‘ggplot2’-geom’s to show the composition of the Solvency (II) Capital Requirement (SCR) from (diversified) risks and subrisks, whether for standard formula (SF) or (partial) intern models (IM/PIM).

Installation

You can install ggsolvencyii from Github:

# install.packages("devtools", "dplyr" , "magrittr")
devtools::install_github("vanzanden/ggsolvencyii")
# or from the binary in github.com/vanzanden/ggsolvencyii/binaries/windows

Vignettes

The following vignettes are available or will be available soon check https://github.com/vanzanden/ggsolvencyii/tree/master/vignettes

  • ggsolvencyii (this vignette)
  • plotdetails
  • showcase
  • coding_overview

example

ggsolvencyii builds on ggplot-functionality and provides three geom’s: * geom_sii_risksurface * geom_sii_riskoutline * geom_sii_riskconnection

These were used to produce the following plot which for example could be used for an ORSA report.

the complete annotated code for the first figure is shown in vignette ‘showcase’. A further elaboration on the inner workings of the package and the use of parameter-values and tables can be found in vignette “coding overview’.

#> [1] "reminder: anonymous userdata is send to www.vanzanden.nl. This behaviour can be switched of by sii_setoption_statistics_participate(participate = FALSE). This reminder can be switched of with sii_setoption_statistics_remind(remind = FALSE)"
#> [1] "reminder: anonymous userdata is send to www.vanzanden.nl. This behaviour can be switched of by sii_setoption_statistics_participate(participate = FALSE). This reminder can be switched of with sii_setoption_statistics_remind(remind = FALSE)"
#> [1] "reminder: anonymous userdata is send to www.vanzanden.nl. This behaviour can be switched of by sii_setoption_statistics_participate(participate = FALSE). This reminder can be switched of with sii_setoption_statistics_remind(remind = FALSE)"
#> scaling is based on inputvalue (maxscrvalue) of 25.7433642812936
#> scaling is based on a max (level= 1) value of 25.7433642812936
#> scaling is based on a max (level= 1) value of 25.7433642812936
#> scaling is based on a max (level= 1) value of 25.7433642812936

The total surface (to the center point of each circle) of the outer segments show the size of undiversified risks. Diversification is made visible by the difference between the risk segment and the next segment nearer to the center of the plot. The red (out)lines are displayed for comparison with the previous SCR buildup.

For troubleshooting sii_debug_geom provides an overview of present risk descriptions and levels in the data and supporting tables.

Base plot and options

base

An life insurer reports its solvency ratio following Standard Formula rules, with English names for all risks. It has a set of risks, diversification effects, and accumulations to the SCR for the current situation (‘id’=1) and three three-year ORSA scenarios (‘id’ is 2-4, 5-7, 8-10). The results are stored in a datafile of which the first lines and columns are shown here:

id time comparewithid ratio SCR Adjustment-LACDT BSCR BSCR_div
1 1 2016 NA 230 23.00000 -10.000000 28.00000 -9.000000
4 2 2017 1 233 23.14993 -9.158458 27.30838 -9.135998
7 3 2018 2 238 19.99461 -9.435391 24.43000 -8.402552

Variable sii_z_ex1_data is the tidyverse representation of the dataset above (the first lines for ‘id’ = 1, 2 or 3 are shown).

time ratio description value id comparewithid
1 2016 230 SCR 23.00000 1 NA
2 2017 233 SCR 23.14993 2 1
3 2018 238 SCR 19.99461 3 2
11 2016 230 BSCR 28.00000 1 NA
12 2017 233 BSCR 27.30838 2 1
13 2018 238 BSCR 24.43000 3 2
21 2016 230 operational 5.00000 1 NA
22 2017 233 operational 5.00000 2 1

Variables sii_x_fillcolors… and sii_x_edgecolors are named lists with colorcodes for each risk-description

x
SCR #1f78b4
BSCR #48b0eb
operational #70d8ff
market #d95f02
health #4a1486
life #33a02c

The SCR composition of the current situation (id = 1) is shown below

ggplot() +
  geom_sii_risksurface(
    data = sii_z_ex1_data[sii_z_ex1_data$id == 1, ],
    mapping = aes(x = time, 
                  y = ratio, 
                  id = id, 
                  value = value, 
                  description = description, 
                  color = description,
                  fill = description
                   ) ) +
theme_bw() +
scale_fill_manual(name = "Risks",values = sii_x_fillcolors_sf16_eng) +
scale_color_manual(name = "Risks",values = sii_x_edgecolors_sf16_eng)
#> [1] "reminder: anonymous userdata is send to www.vanzanden.nl. This behaviour can be switched of by sii_setoption_statistics_participate(participate = FALSE). This reminder can be switched of with sii_setoption_statistics_remind(remind = FALSE)"
#> scaling is based on a max (level= 1) value of 23

structure

Geom_sii_risksurface uses one default table for this plot sii_structure_sf16_eng. It defines each risks by indicating from which combined ‘child’-risks and diversification (suffix ‘d’) it is made up. Passing another structure table makes this geom usable for localisation or for internal models.

head(sii_structure_sf16_eng, 13)
description level childlevel
SCR 1 2
BSCR 2 3
operational 2 NA
Adjustment-LACDT 2d NA
BSCR_div 3d NA
market 3 4.01
life 3 4.02
non-life 3 4.03
health 3 4.04
cp-default 3 NA
intangibles 3 NA
market_div 4.01d NA
m_interestrate 4.01 NA
m_equity 4.01 NA
m_property 4.01 NA

levelmax

To prevent cluttering of the legend it is possible to group the smallest items of a level by providing a levelmax-table in such a way that the indicated maximum items in that level is not exceeded. the example is on another dataset sii_z_ex2_data, with only one SCR result.

sii_levelmax_sf16_993
level levelmax
1 99
2 99
3 99
4.01 3
4.02 3
4.03 3
4.04 3
5 3
ggplot() +
  geom_sii_risksurface(
    data = sii_z_ex2_data,
    mapping = aes(x = time, y = ratio, id = id, value = value, 
                  description = description, 
                  # color = description,
                  fill = description  
                  ),
    color = "black",
    levelmax = sii_levelmax_sf16_993) +
theme_bw() +
scale_fill_manual(name = "Risks",values = sii_x_fillcolors_sf16_eng) # +

# scale_color_manual(name = "Risks",values = sii_x_edgecolors_sf16_eng)

Rotation and squared

Rotationdescription rotates the plot in such a way that the indicated item (can be on either level, i.e. works also on ‘life’ or ‘operational’) is plotted on just on the righthandside of ‘12 o’clock’. rotationdegrees is then added.

The option squared makes a square plot, with the surface of all segments still in proportion. The angle between the ’radial’lines of equal sized segments differ, based on the position of the segment.

ggplot() +
  geom_sii_risksurface(
    data = sii_z_ex2_data,
    mapping = aes(x = time, y = ratio, id = id, value = value, 
                           description = description, 
                           fill = description, color = description),
                  squared = TRUE,
                  rotationdescription = 'm_equity',
                  rotationdegrees = -45) +
theme_bw() +
scale_fill_manual(name = "Risks",values = sii_x_fillcolors_sf16_eng) +
scale_color_manual(name = "Risks",values = sii_x_edgecolors_sf16_eng)

The second plot shows a comparison between a circle and square plot of the same data. Note that the radius of the SCR circle is smaller than the size of the SCR square !!

#> scaling is based on a max (level= 1) value of 30
#> scaling is based on a max (level= 1) value of 30

Scaling

all SCR-buildups from a single call to geom_sii_risksurface or geom_sii_riskoutline plot are by default scaled in such a way that the largest SCR has a plotradius of one. When combining more calls, with several datasets a manual maxscrvalue-value can be given as a parameter. To prevent distortion, depending on the scale of x and y axis, scalingx and scalingy parameters are available.

Plotdetails

The plotdetails table can be passed as a parameter to geom_sii_risksurface and geom_sii_riskoutline. It indicates whether to actual plot surfaces or outlinesegments (1 to 4) after the composition of the round (or squared) layout of segments. An example is the seperate plotting of inner and outer segments, with different transparancy in the showcase, or only plotting the outline of the SCR itself and the lowest risklevels. See the separate vignette for a detailed explanation.

Outlines, comparewithid

If the optional aes comparewithid is passed to geom_sii_riskoutline a link is made between the x and y value of an ‘id’ and the SCR composition of that SCR buildup where comparewithid references to. This can be used to overlay the outline of one SCR over the surfaceplot of another. This for easy comparison between the two. See vignettes “geom_sii_riskoutline” and “geom_sii_riskconnection” for details