Long Term Protection Model in R Dr. Urszula Gasser, Senior Pricing Actuary
2 Disclaimer The following presentation is for general information, education and discussion purposes only. Views or opinions expressed, whether oral or in writing do not necessarily reflect those of PartnerRe nor do they constitute legal or professional advice.
3 The need
4 Life insurance Gives protection against loss resulting from death (or serious illness) of an insured
5 Life insurance Gives protection against loss resulting from death (or serious illness) of an insured
6 specialized need for tools Life reinsurer needs to… underlying model risk
7 The model
8 healthy What about Mr Bloggs?
9 dead healthy What about Mr Bloggs?
10 dead healthy What about Mr Bloggs? lapsed
11 dead healthy What about Mr Bloggs? cancer early lapsed
12 dead healthy What about Mr Bloggs? cancer early lapsed
13 dead severe cancer healthy What about Mr Bloggs? cancer early lapsed
14 dead severe cancer healthy What about Mr Bloggs? cancer early lapsed
15 What about Mr Bloggs? healthy early severe cancer cancer early and severe cancer lapsed dead
16 What about Mr Bloggs? healthy early severe cancer cancer early and severe cancer lapsed dead
17 What about Mr Bloggs? healthy q x l h x (d) i 1 i 2 x x early severe cancer cancer i 1 x * i 2 x i lb2->lb1 x (d) i lb1->lb2 x (d) early and l lb2 x (d) q lb2->dead x (d) l lb1 x (d) severe l lb1+lb2 q lb1+lb2->dead x (d) x (d) cancer q lb1->dead x (d) lapsed dead q x ,i x ,l x – mortality rate, incidence rate, lapse rate d – duration (months) in given state
18 And what about Mrs Bloggs?
19 To model Mr & Mrs Bloggs policy we decided to build our own, Long Term Protection Model for pricing
20 The tool
21 LTPM pricing tool needs to be • User friendly • Easy to access • Simple to set-up • Fast to calculate • Straightforward to interpret • Flexible • Stable • Secure • Auditable
22 We decided to do it in R as opposed to most tools used in the re/insurance industry, because these come often with: • Legacy issues (too heavy) • Calculation constraints (some things are not possible) • Access issues (desktop versions, use of “workers”, external clouds) • Transparency issues (black-box) • Maintenance issues (costly upgrade, adaptation)
23 Why R? • Becoming the standard analytics tool at university level and in many industries • Free • Open source • Meets our needs • Fast • Flexible • Reduces the number of platforms we maintain
24 R is an excellent fit… … but we also need an infrastructure to support all the tool requirements
25 The workflow
26 First, let’s look at the steps in the calculation Input data
27 Steps in the calculation Shiny web interface Input data
28 Steps in the calculation Shiny web interface Dedicated server Input data
29 Steps in the calculation Code repository with version control Shiny web interface Dedicated server and issue tracker Input data
30 Steps in the calculation Code repository with version control Shiny web interface Dedicated server and issue tracker Input data
31 Steps in the calculation Code repository with version control Shiny web interface Dedicated server and issue tracker Input data
32 Steps in the calculation Code repository with version control Shiny web interface Dedicated server and issue tracker Input data
33 Steps in the calculation Code repository with version control Shiny web interface Dedicated server and issue tracker http://www.freeiconspng.com/images/server-icon Output data https://openclipart.org https://commons.wikimedia.org/wiki/File:Gnome-laptop.svg https://commons.wikimedia.org/wiki/File:Nexus_5_Front_View.png https://commons.wikimedia.org/wiki/File:Tablet-apple-ipad.svg Input data
34 The interface
35
36 web interface
37 web interface collaboration
38 web interface collaboration choice of model version
39 web interface collaboration choice of model version intuitive names
40 web interface collaboration choice of model version intuitive names upload of the input data
41
42
43
44
45
46
47
48
49 Content of a run Input Output Model code + Run log file Gitlab reference Run ZIP
50 The anatomy
51 GitLab repository LTPM Shiny apps LTPMcreate LTPMrun R packages as LTPMcalc LTPMlogging LTPMinput git submodules GitLab project
52 Shiny applications There are two Shiny applications in the LTPM: 1. LTPMcreate: the main application where pricing exercises can be defined and runs can be created. 2. LTPMrun: an interface to each individual run which displays run details (e.g. input files and settings), status messages, and provides access to results.
53 GitLab repository LTPM Shiny apps LTPMcreate LTPMrun R packages as LTPMcalc LTPMlogging LTPMinput git submodules GitLab project
54 GitLab repository LTPM Shiny apps LTPMcreate LTPMrun R packages as LTPMcalc LTPMlogging LTPMinput git submodules
55 R packages To support the calculations we have created three R extension packages: 1. LTPMcalc: includes all functionality for the actual calculations for the multi-state model. 2. LTPMinput: functionality to convert user input (i.e. spreadsheets) to an intermediate format (i.e. CSV). 3. LTPMlogging: functionality to allow all scripts and applications to log time-stamped information to the console or to a file on disk.
56 GitLab repository LTPM Shiny apps LTPMcreate LTPMrun R packages as LTPMcalc LTPMlogging LTPMinput git submodules
57 GitLab repository LTPM Shiny apps LTPMcreate LTPMrun R packages as LTPMcalc LTPMlogging LTPMinput git submodules GitLab GitLab group project
58 Packages as git submodules – GitLab view
59 Anatomy of LTPMrun execute.R LTPMlogging install.R Shiny LTPMinput input.R application calc.R LTPMcalc
60 Executable R scripts The LTPMrun application has one R script to execute a full calculation run called execute.R. This script defines three execution steps, each implemented in a separate R script: 1. install.R: installation of R extension packages required by the run, 2. input.R: reading and conversion of input file(s) provided by the user, 3. calc.R: perform the calculations.
61 LTPMcalc The R package which implements the actual model functionality including the multi-state model. The multi-state model is a Markov chain, which is a discrete-time Markov process. Implementation details can be found in the package ‘vignette’.
62 Flexibility and adaptability
63 Choice of actuarial model version User can choose between: - the latest released version - past released versions - customized version created by themselves - customized version created by other user V1.0 V2.0 V3.0 V5.0 V4.0 Master branch Branch 1 Branch 2 Tags
64 Choice of actuarial model version list of git tags list of git branches
65 Quality assurance
66 How do we ensure that the model is correct? We can never guarantee that the model is completely free of errors and bugs. To minimize errors, we apply standard practices for quality assurance in software development: 1. Many small unit tests for individual functions. 2. Integration (i.e. end-to-end) tests using pre- calculated results. 3. User testing.
67 GitLab • Source code version control using Git. • Issue tracker to track bugs and our progress in fixing these. • Continuous Integration (CI) ‘pipelines’ to automatically test –on the target system– all changes committed to the source code repository. - performed in target environment - immediate upon push - notifications can be send to Slack
68 GitLab - Continuous Integration
69 Questions?
Recommend
More recommend