knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

layers

Lifecycle: experimental Travis build status Codecov test coverage Version

The layers package provides a simple library for doing common reinsurance calculations outside of Analyze Re.

Installation

You can install the development version of layers from GitHub with:

# install.packages("devtools")
devtools::install_github("jfkingiii/layers")

If using Windows, Rtools should be installed: https://cran.r-project.org/bin/windows/Rtools/

Example

Use the included sample YELT, yelt_test, to try out some of the layers functions.

library(layers)

# Look at the help files
help(package = layers)

# Look at the AAL by line
AAL(yelt_test)

# Create some layers and get their metrics
options(scipen = 999)
test_layer <- layer(4000000, 1000000, 1, "yelt_test",
                    lobs=c("PHYSICIANS", "CHC", "MEDCHOICE"))
gross_layer <- layer(UNLIMITED, 0, 1, "yelt_test",
                     lobs=c("PHYSICIANS", "CHC", "MEDCHOICE", "HOSPITAL"))
# Aggregate limits and deductibles are optional and default to UNLIMITED and 0.
# Notice the `Sign` value which can be changed using the `minus` function.
# This allows combining layers by adding and subtracting when building portfolios.

test_layer
gross_layer
summary(test_layer)
summary(gross_layer)

# Test some OEPs
VaR(gross_layer, 5, "OEP")
VaR(gross_layer, 10, "OEP")
VaR(test_layer, 15, "OEP")
VaR(test_layer, 20, "OEP")

# Try a layer with aggregate parameters
agg_layer <- layer(4000000, 1000000, 1, "yelt_test",
                   lobs=c("PHYSICIANS","CHC","MEDCHOICE"),
                   agg_attachment = 4000000, agg_limit = 12000000)
summary(agg_layer)

# Portolio expected losses
layer1 <- layer(100000, 100000, 1, "yelt_test", lobs="PHYSICIANS")
layer2 <- layer(100000, 200000, 1, "yelt_test", lobs="PHYSICIANS")
layer3 <- layer(100000, 300000, 1, "yelt_test", lobs="PHYSICIANS")
P <- portfolio(layer1, layer2, layer3)

expected(layer1) + expected(layer2) + expected(layer3)
expected(P)

# Use a portfolio as an argument to portfolio
ceded <- portfolio(layer1, layer2, layer3)
net <- portfolio(gross_layer, minus(ceded))
expected(gross_layer) - expected(ceded)
expected(net)
summary(net)


jfkingiii/layers documentation built on July 21, 2020, 8:57 p.m.