| Type: | Package |
| Title: | Actuarial Functions for Non-Life Insurance Modelling |
| Version: | 0.2.0 |
| Description: | Assists actuaries and other insurance modellers in pricing, reserving and capital modelling for non-life insurance and reinsurance modelling. Provides functions that help model excess levels, capping and pure Incurred but not reported claims (pure IBNR). Includes capped mean, exposure curves and increased limit factor curves (ILFs) for LogNormal, Gamma, Pareto, Sliced LogNormal-Pareto and Sliced Gamma-Pareto distributions. Includes mean, probability density function (pdf), cumulative probability function (cdf) and inverse cumulative probability function for Sliced LogNormal-Pareto and Sliced Gamma-Pareto distributions. Includes calculating pure IBNR exposure with LogNormal and Gamma distribution for reporting delay. Includes three 'shiny' tools, one to simulate insurance claims applying reinsurance structures, fit generalised linear models and fit claims frequency or severity distributions. Methods used in the package refer to Free for All by Yiannis Parizas (2023) https://www.theactuary.com/2023/03/02/free-all; Escaping the triangle by Yiannis Parizas (2019) https://www.theactuary.com/features/2019/06/2019/06/05/escaping-triangle; Take to excess by Yiannis Parizas (2019) https://www.theactuary.com/features/2019/03/2019/03/06/taken-excess. |
| License: | GPL-3 |
| Encoding: | UTF-8 |
| Imports: | shiny (≥ 1.8.1), htmltools, base64enc, bslib (≥ 0.9.0), future, future.apply, parallel, methods, stats, utils, graphics, grDevices, plotly, reactable, fitdistrplus |
| Suggests: | knitr, rmarkdown, crch, testthat, DBI, RMySQL, RODBC, RPostgreSQL, RSQLite |
| VignetteBuilder: | knitr |
| Config/testthat/edition: | 3 |
| Config/roxygen2/version: | 8.1.0 |
| NeedsCompilation: | no |
| Packaged: | 2026-09-13 22:23:57 UTC; yiann |
| Author: | Yiannis Parizas [aut, cre] |
| Maintainer: | Yiannis Parizas <yiannis.parizas@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-09-13 22:50:02 UTC |
NetSimR: A non-life insurance package for computing various statistics
Description
The NetSimR package provides five categories of functions:
Capped means, Exposure and ILF curve from various severity distributions
Pure IBNR and UPR earned periods
Sliced distributions
Frequency-severity claims simulation
Shiny apps for simulating claims and fitting distributions
NetSimR mean functions
SlicedGammaParetoMean
SlicedLNormParetoMean
NetSimR capped mean functions
GammaCappedMean
LNormCappedMean
ParetoCappedMean
SlicedGammaParetoCappedMean
SlicedLNormParetoCappedMean
NetSimR exposure curve functions
ExposureCurveGamma
ExposureCurveLNorm
ExposureCurvePareto
ExposureCurveSlicedGammaPareto
ExposureCurveSlicedLNormPareto
NetSimR ILF curve functions
ILFGamma
ILFLNorm
ILFPareto
ILFSlicedGammaPareto
ILFSlicedLNormPareto
NetSimR pure IBNR functions
NetSimR Sliced distribution functions
dSlicedGammaPareto
dSlicedLNormPareto
pSlicedGammaPareto
pSlicedLNormPareto
qSlicedGammaPareto
qSlicedLNormPareto
NetSimR claims simulation functions
simulate_claims
simulate_function
NetSimR Shiny apps
run_shiny_simulator
run_shiny_distribution_fitting_tool
run_shiny_glm_fitting_tool
Author(s)
Maintainer: Yiannis Parizas yiannis.parizas@gmail.com
Authors:
Yiannis Parizas yiannis.parizas@gmail.com
Exposure Curve from a Gamma severity distribution
Description
Exposure Curve from a Gamma severity distribution
Usage
ExposureCurveGamma(x, shape, rate)
Arguments
x |
A positive real number - the claim amount where the exposure curve will be evaluated. |
shape |
A positive real number - the shape parameter of the Claim Severity's Gamma distribution. |
rate |
A positive real number - the rate parameter of the Claim Severity's Gamma distribution. |
Value
The value of the Exposure curve at x with Claim Severity from a Gamma distribution with parameters shape and rate.
Examples
ExposureCurveGamma(700,1,0.0005)
ExposureCurveGamma(1000,1.5,0.0006)
Exposure Curve from LogNormal a severity distribution
Description
Exposure Curve from LogNormal a severity distribution
Usage
ExposureCurveLNorm(x, mu, sigma)
Arguments
x |
A positive real number - the claim amount where the exposure curve will be evaluated. |
mu |
A real number - the first parameter of the Claim Severity's LogNormal distribution. |
sigma |
A positive real number - the second parameter of the Claim Severity's LogNormal distribution. |
Value
The value of the Exposure curve at x with Claim Severity from a LogNormal distribution with parameters mu and sigma.
Examples
ExposureCurveLNorm(2000,6,1.5)
ExposureCurveLNorm(1000,5,1.6)
Exposure Curve from a Pareto severity distribution
Description
Exposure Curve from a Pareto severity distribution
Usage
ExposureCurvePareto(x, scale, shape)
Arguments
x |
A positive real number - the claim amount where the exposure curve will be evaluated. |
scale |
A positive real number - the scale parameter of the Claim Severity's Pareto distribution. |
shape |
A positive real number - the shape parameter of the Claim Severity's Pareto distribution. |
Value
The value of the Exposure curve at x with Claim Severity from a Pareto distribution with parameters scale and shape. The exposure curve divides by the mean, which is infinite when shape <= 1; the function returns 0 in that case.
Examples
ExposureCurvePareto(700,500,1.2)
ExposureCurvePareto(20000,200,1.1)
Exposure Curve from a Sliced Gamma Pareto severity distribution
Description
Exposure Curve from a Sliced Gamma Pareto severity distribution
Usage
ExposureCurveSlicedGammaPareto(x, GShape, GRate, SlicePoint, PShape)
Arguments
x |
A positive real number - the claim amount where the exposure curve will be evaluated. |
GShape |
A positive real number - the shape parameter of the Claim Severity's Gamma distribution. |
GRate |
A positive real number - the rate parameter of the Claim Severity's Gamma distribution. |
SlicePoint |
A positive real number - the slice point and the scale parameter of the Claim Severity's Pareto distribution. |
PShape |
A positive real number - the shape parameter of the Claim Severity's Pareto distribution. |
Value
The value of the Exposure curve at x with an attritional claim Gamma distribution with parameters GShape and GRate and a large claim Pareto distribution with parameters SlicePoint and PShape. The exposure curve divides by the mean, which is infinite when PShape <= 1; the function returns 0 in that case.
Examples
ExposureCurveSlicedGammaPareto(3000,1,0.0005,1000,1.2)
ExposureCurveSlicedGammaPareto(1000,1.1,0.0006,2000,1.6)
ExposureCurveSlicedGammaPareto(2000,1.2,0.0004,3000,1.4)
Exposure Curve from a Sliced LogNormal Pareto severity distribution
Description
Exposure Curve from a Sliced LogNormal Pareto severity distribution
Usage
ExposureCurveSlicedLNormPareto(x, mu, sigma, SlicePoint, shape)
Arguments
x |
A positive real number - the claim amount where the exposure curve will be evaluated. |
mu |
A real number - the first parameter of the attritional Claim Severity's LogNormal distribution. |
sigma |
A positive real number - the second parameter of the attritional Claim Severity's LogNormal distribution. |
SlicePoint |
A positive real number - the slice point and the scale parameter of the tail Claim Severity's Pareto distribution. |
shape |
A positive real number - the shape parameter of the tail Claim Severity's Pareto distribution. |
Value
The value of the Exposure curve at x with an attritional claim LogNormal distribution with parameters mu and sigma and a large claim Pareto distribution with parameters SlicePoint and shape. The exposure curve divides by the mean, which is infinite when shape <= 1; the function returns 0 in that case.
Examples
ExposureCurveSlicedLNormPareto(1200,6,1.5,1000,1.2)
ExposureCurveSlicedLNormPareto(4000,7,1.6,3000,1.4)
Server function for the GLM Fitting tool application
Description
Server function for the GLM Fitting tool application
Usage
GLMFittingToolServer(input, output, session)
Arguments
input |
Input for the server function. |
output |
Output for the server function. |
session |
Session for the server function. |
Value
Called by shiny for its side effects, the outputs and observers of a session; the value is not used.
User interface of the Shiny GLM fitting tool
Description
A function of the request, so that it is built when the app starts, after every helper of the package is defined.
Usage
GLMFittingToolUI(request)
Arguments
request |
The request, supplied by shiny. |
Value
The user interface of the application, a bslib navbar page.
Gamma capped mean
Description
Gamma capped mean
Usage
GammaCappedMean(cap, shape, rate)
Arguments
cap |
A positive real number - the claim severity cap. |
shape |
A positive real number - the shape parameter of the Claim Severity's Gamma distribution. |
rate |
A positive real number - the rate parameter of the Claim Severity's Gamma distribution. |
Value
The mean of the claim severity capped at cap with a Gamma distribution with parameters shape and rate.
Examples
GammaCappedMean(700,1,0.0005)
GammaCappedMean(1000,1.5,0.0006)
Upper incomplete gamma function
Description
Upper incomplete gamma function
Usage
IGamma(a, x)
Arguments
a |
A positive real number - the shape parameter. |
x |
A positive real number. |
Value
The value of the upper incomplete gamma function at x with shape parameter a, i.e. gamma(a) * pgamma(x, a, lower.tail = FALSE).
Examples
IGamma(1,1)
IGamma(0.1,2)
Increased Limit Factor Curve from a Gamma severity distribution
Description
Increased Limit Factor Curve from a Gamma severity distribution
Usage
ILFGamma(xLow, xHigh, shape, rate)
Arguments
xLow |
A positive real number - the claim amount where the Increased Limit Factor Curve will be evaluated from. |
xHigh |
A positive real number - the claim amount where the Increased Limit Factor Curve will be evaluated to. |
shape |
A positive real number - the shape parameter of the Claim Severity's Gamma distribution. |
rate |
A positive real number - the rate parameter of the Claim Severity's Gamma distribution. |
Value
The value of the Increased Limit Factor curve from xLow to xHigh with Claim Severity from a Gamma distribution with parameters shape and rate.
Examples
ILFGamma(700,1000,1,0.0005)
ILFGamma(1000,1200,1.5,0.0006)
Increased Limit Factor Curve from a LogNormal severity distribution
Description
Increased Limit Factor Curve from a LogNormal severity distribution
Usage
ILFLNorm(xLow, xHigh, mu, sigma)
Arguments
xLow |
A positive real number - the claim amount where the Increased Limit Factor Curve will be evaluated from. |
xHigh |
A positive real number - the claim amount where the Increased Limit Factor Curve will be evaluated to. |
mu |
A real number - the first parameter of the Claim Severity's LogNormal distribution. |
sigma |
A positive real number - the second parameter of the Claim Severity's LogNormal distribution. |
Value
The value of the Increased Limit Factor curve from xLow to xHigh with Claim Severity from a LogNormal distribution with parameters mu and sigma.
Examples
ILFLNorm(1000,2000,6,1.5)
ILFLNorm(1000,1500,5,1.6)
Increased Limit Factor Curve from a Pareto severity distribution
Description
Increased Limit Factor Curve from a Pareto severity distribution
Usage
ILFPareto(xLow, xHigh, scale, shape)
Arguments
xLow |
A positive real number - the claim amount where the Increased Limit Factor Curve will be evaluated from. |
xHigh |
A positive real number - the claim amount where the Increased Limit Factor Curve will be evaluated to. |
scale |
A positive real number - the scale parameter of the Claim Severity's Pareto distribution. |
shape |
A positive real number - the shape parameter of the Claim Severity's Pareto distribution. |
Value
The value of the Increased Limit Factor curve from xLow to xHigh with Claim Severity from a Pareto distribution with parameters scale and shape.
Examples
ILFPareto(700,1200,500,1.2)
ILFPareto(1200,20000,200,1.1)
Increased Limit Factor Curve from a Sliced Gamma Pareto severity distribution
Description
Increased Limit Factor Curve from a Sliced Gamma Pareto severity distribution
Usage
ILFSlicedGammaPareto(xLow, xHigh, GShape, GRate, SlicePoint, PShape)
Arguments
xLow |
A positive real number - the claim amount where the Limit Factor Curve will be evaluated from. |
xHigh |
A positive real number - the claim amount where the Limit Factor Curve will be evaluated to. |
GShape |
A positive real number - the shape parameter of the attritional Claim Severity's Gamma distribution. |
GRate |
A positive real number - the rate parameter of the attritional Claim Severity's Gamma distribution. |
SlicePoint |
A positive real number - the slice point and the scale parameter of the tail Claim Severity's Pareto distribution. |
PShape |
A positive real number - the shape parameter of the tail Claim Severity's Pareto distribution. |
Value
The value of the Increased Limit Factor curve from xLow to xHigh with an attritional claim Gamma distribution with parameters GShape and GRate and a large claim Pareto distribution with parameters SlicePoint and PShape.
Examples
ILFSlicedGammaPareto(2000,3000,1,0.0005,1000,1.2)
ILFSlicedGammaPareto(800,1000,1.1,0.0006,2000,1.6)
ILFSlicedGammaPareto(1200,2000,1.2,0.0004,3000,1.4)
Increased Limit Factor Curve from a Sliced LogNormal Pareto severity distribution
Description
Increased Limit Factor Curve from a Sliced LogNormal Pareto severity distribution
Usage
ILFSlicedLNormPareto(xLow, xHigh, mu, sigma, SlicePoint, shape)
Arguments
xLow |
A positive real number - the claim amount where the Limit Factor Curve will be evaluated from. |
xHigh |
A positive real number - the claim amount where the Limit Factor Curve will be evaluated to. |
mu |
A real number - the first parameter of the attritional Claim Severity's LogNormal distribution. |
sigma |
A positive real number - the second parameter of the attritional Claim Severity's LogNormal distribution. |
SlicePoint |
A positive real number - the slice point and the scale parameter of the tail Claim Severity's Pareto distribution. |
shape |
A positive real number - the shape parameter of the tail Claim Severity's Pareto distribution. |
Value
The value of the Increased Limit Factor curve from xLow to xHigh with an attritional claim LogNormal distribution with parameters mu and sigma and a large claim Pareto distribution with parameters SlicePoint and shape.
Examples
ILFSlicedLNormPareto(800,1200,6,1.5,1000,1.2)
ILFSlicedLNormPareto(2000,4000,7,1.6,3000,1.4)
Lognormal capped mean
Description
Lognormal capped mean
Usage
LNormCappedMean(cap, mu, sigma)
Arguments
cap |
A positive real number - the claim severity cap. |
mu |
A real number - the first parameter of the Claim Severity's LogNormal distribution. |
sigma |
A positive real number - the second parameter of the Claim Severity's LogNormal distribution. |
Value
The mean of the claim severity capped at cap with a LogNormal distribution with parameters mu and sigma.
Examples
LNormCappedMean(2000,6,1.5)
LNormCappedMean(1000,5,1.6)
Pareto capped mean
Description
Pareto capped mean
Usage
ParetoCappedMean(cap, scale, shape)
Arguments
cap |
A positive real number - the claim severity cap. |
scale |
A positive real number - the scale parameter of the Claim Severity's Pareto distribution. |
shape |
A positive real number - the shape parameter of the Claim Severity's Pareto distribution. |
Value
The mean of the claim severity capped at cap with a Pareto distribution with parameters scale and shape. A cap at or below scale is returned unchanged, as no claim is smaller than scale. The arguments are recycled to a common length.
Examples
ParetoCappedMean(600,200,1.2)
ParetoCappedMean(800,100,1)
ParetoCappedMean(1000,500,0.8)
ParetoCappedMean(50,100,2)
Pareto capped mean intermediary calculation
Description
Pareto capped mean intermediary calculation
Usage
ParetoCappedMeanCalc(cap, scale, shape)
Arguments
cap |
A positive real number - the claim severity cap. |
scale |
A positive real number - the scale parameter of the Claim Severity's Pareto distribution. |
shape |
A positive real number - the shape parameter of the Claim Severity's Pareto distribution. |
Value
An interim calculation for the mean of the claim severity capped at cap with a Pareto distribution with parameters scale and shape. It is the closed form for cap >= scale and shape != 1; use ParetoCappedMean for the capped mean itself.
Examples
ParetoCappedMeanCalc(800,100,1.1)
ParetoCappedMeanCalc(1000,500,0.9)
Pure IBNR exposure from a Gamma reporting delay distribution
Description
Pure IBNR exposure from a Gamma reporting delay distribution
Usage
PureIBNRGamma(IncDate, ExpDate, ValDate, shape, rate)
Arguments
IncDate |
A date - the inception date of the period. |
ExpDate |
A date - the expiry date of the period. Must be greater than inception date. |
ValDate |
A date - the valuation date. |
shape |
A positive real number - the shape parameter of the reporing delay's Gamma distribution. |
rate |
A positive real number - the rate parameter of the reporing delay's Gamma distribution. |
Value
Unearned and Pure IBNR exposure in days and as a percentage of the period's duration, where the reporting delay has a Gamma distribution with parameters shape and rate.
Examples
Dates = data.frame(
inceptionDate = c("01/01/2006", "01/07/2006", "01/01/2007")
,expiryDate = c("31/12/2006", "30/06/2007", "31/12/2007")
)
Dates$inceptionDate<-as.POSIXct(Dates$inceptionDate, format="%d/%m/%Y")
Dates$expiryDate<-as.POSIXct(Dates$expiryDate, format="%d/%m/%Y")
ValuationDate<-as.POSIXct("30/10/2007", format="%d/%m/%Y")
PureIBNRGamma(Dates$inceptionDate,Dates$expiryDate,ValuationDate,7,0.15)
Pure IBNR exposure from a LogNormal reporting delay distribution
Description
Pure IBNR exposure from a LogNormal reporting delay distribution
Usage
PureIBNRLNorm(IncDate, ExpDate, ValDate, mu, sigma)
Arguments
IncDate |
A date - the inception date of the period. |
ExpDate |
A date - the expiry date of the period. Must be greater than inception date. |
ValDate |
A date - the valuation date. |
mu |
A real number - the first parameter of the reporing delay's LogNormal distribution. |
sigma |
A positive real number - the second parameter of the reporing delay's LogNormal distribution. |
Value
Unearned and Pure IBNR exposure in days and as a percentage of the period's duration, where the reporting delay has a LogNormal distribution with parameters mu and sigma.
Examples
Dates = data.frame(
inceptionDate = c("01/01/2006", "01/07/2006", "01/01/2007")
,expiryDate = c("31/12/2006", "30/06/2007", "31/12/2007")
)
Dates$inceptionDate<-as.POSIXct(Dates$inceptionDate, format="%d/%m/%Y")
Dates$expiryDate<-as.POSIXct(Dates$expiryDate, format="%d/%m/%Y")
ValuationDate<-as.POSIXct("30/10/2007", format="%d/%m/%Y")
PureIBNRLNorm(Dates$inceptionDate,Dates$expiryDate,ValuationDate,4,1.5)
Sliced Gamma Pareto capped mean
Description
Sliced Gamma Pareto capped mean
Usage
SlicedGammaParetoCappedMean(cap, GShape, GRate, SlicePoint, PShape)
Arguments
cap |
A positive real number - the claim severity cap. |
GShape |
A positive real number - the shape parameter of the attritional Claim Severity's Gamma distribution. |
GRate |
A positive real number - the rate parameter of the attritional Claim Severity's Gamma distribution. |
SlicePoint |
A positive real number - the slice point and the scale parameter of the tail Claim Severity's Pareto distribution. |
PShape |
A positive real number - the shape parameter of the tail Claim Severity's Pareto distribution. |
Value
The mean of the claim severity capped at cap with an attritional claim Gamma distribution with parameters GShape and GRate and a large claim Pareto distribution with parameters SlicePoint and PShape.
Examples
SlicedGammaParetoCappedMean(3000,1,0.0005,1000,1.2)
SlicedGammaParetoCappedMean(1000,1.1,0.0006,2000,1.6)
SlicedGammaParetoCappedMean(2000,1.2,0.0004,3000,1.4)
Sliced Gamma Pareto mean
Description
Sliced Gamma Pareto mean
Usage
SlicedGammaParetoMean(GShape, GRate, SlicePoint, PShape)
Arguments
GShape |
A positive real number - the shape parameter of the attritional Claim Severity's Gamma distribution. |
GRate |
A positive real number - the rate parameter of the attritional Claim Severity's Gamma distribution. |
SlicePoint |
A positive real number - the slice point and the scale parameter of the tail Claim Severity's Pareto distribution. |
PShape |
A positive real number - the Shape parameter of the tail Claim Severity's Pareto distribution. |
Value
The mean of the claim severity with an attritional claim Gamma distribution with parameters GShape and GRate and a large claim Pareto distribution with parameters SlicePoint and PShape.
Examples
SlicedGammaParetoMean(1,0.0005,1000,1.2)
SlicedGammaParetoMean(1.1,0.0006,2000,1.6)
SlicedGammaParetoMean(1.2,0.0004,3000,1.4)
Sliced LogNormal Pareto capped mean
Description
Sliced LogNormal Pareto capped mean
Usage
SlicedLNormParetoCappedMean(cap, mu, sigma, SlicePoint, shape)
Arguments
cap |
A positive real number - the claim severity cap. |
mu |
A real number - the first parameter of the attritional Claim Severity's LogNormal distribution. |
sigma |
A positive real number - the second parameter of the attritional Claim Severity's LogNormal distribution. |
SlicePoint |
A positive real number - the slice point and the scale parameter of the tail Claim Severity's Pareto distribution. |
shape |
A positive real number - the shape parameter of the tail Claim Severity's Pareto distribution. |
Value
The mean of the claim severity capped at cap with an attritional claim LogNormal distribution with parameters mu and sigma and a large claim Pareto distribution with parameters SlicePoint and shape.
Examples
SlicedLNormParetoCappedMean(1200,6,1.5,1000,1.2)
SlicedLNormParetoCappedMean(2500,6.5,1.4,2000,1.6)
SlicedLNormParetoCappedMean(4000,7,1.6,3000,1.4)
Sliced LogNormal Pareto mean
Description
Sliced LogNormal Pareto mean
Usage
SlicedLNormParetoMean(mu, sigma, SlicePoint, shape)
Arguments
mu |
A real number - the first parameter of the attritional Claim Severity's LogNormal distribution. |
sigma |
A positive real number - the second parameter of the attritional Claim Severity's LogNormal distribution. |
SlicePoint |
A positive real number - the slice point and the scale parameter of the tail Claim Severity's Pareto distribution. |
shape |
A positive real number - the shape parameter of the tail Claim Severity's Pareto distribution. |
Value
The mean of the claim severity with an attritional claim LogNormal distribution with parameters mu and sigma and a large claim Pareto distribution with parameters SlicePoint and shape.
Examples
SlicedLNormParetoMean(6,1.5,1000,1.2)
SlicedLNormParetoMean(6.5,1.4,2000,1.6)
SlicedLNormParetoMean(7,1.6,3000,1.4)
Apply a deductible and limit to claims
Description
Apply a deductible and limit to claims
Usage
apply_deductible_limit(
gross_claims_data,
reinsurance_structure,
deductible,
limit
)
Arguments
gross_claims_data |
A vector of Claims. |
reinsurance_structure |
The chosen reinsurance structure. Options are: 'No Reinsurance Structure', 'Unlimited Layer', 'Limited Layer', 'Exclude Layer'. |
deductible |
The deductible of the reinsurance structure. |
limit |
The limit of the reinsurance structure. |
Value
The ceded claims for the structure, with the chosen deductible and limit.
Examples
apply_deductible_limit(c(100, 50, 20), 'Limited Layer', 40, 20)
apply_deductible_limit(c(100, 50, 20), 'Limited Layer', 10, 30)
Apply severity cap function
Description
Apply severity cap function
Usage
apply_severity_cap(claims, severity_cap_boolean, severity_cap_amount)
Arguments
claims |
A vector of Claims. |
severity_cap_boolean |
A variable that if true, the function will cap the claims, otherwise will just return them. |
severity_cap_amount |
The claim cap value. |
Value
If severity_cap_boolean is true, then will return the minimum of severity_cap_amount or claims otherwise will return claims. The operation is vectorised.
The probability density function (pdf) of a Sliced Gamma Pareto severity distribution
Description
The probability density function (pdf) of a Sliced Gamma Pareto severity distribution
Usage
dSlicedGammaPareto(x, GShape, GRate, SlicePoint, PShape)
Arguments
x |
A positive real number - the claim amount where the probability density function (pdf) will be evaluated. |
GShape |
A positive real number - the shape parameter of the attritional Claim Severity's Gamma distribution. |
GRate |
A positive real number - the rate parameter of the attritional Claim Severity's Gamma distribution. |
SlicePoint |
A positive real number - the slice point and the scale parameter of the tail Claim Severity's Pareto distribution. |
PShape |
A positive real number - the shape parameter of the tail Claim Severity's Pareto distribution. |
Value
The value of the probability density function (pdf) at x with an attritional claim Gamma distribution with parameters GShape and GRate and a large claim Pareto distribution with parameters SlicePoint and PShape.
Examples
dSlicedGammaPareto(3000,1,0.0005,1000,1.2)
dSlicedGammaPareto(1000,1.1,0.0006,2000,1.6)
dSlicedGammaPareto(2000,1.2,0.0004,3000,1.4)
The probability density function (pdf) of a Sliced LogNormal Pareto severity distribution
Description
The probability density function (pdf) of a Sliced LogNormal Pareto severity distribution
Usage
dSlicedLNormPareto(x, mu, sigma, SlicePoint, shape)
Arguments
x |
A positive real number - the claim amount where the probability density function (pdf) will be evaluated. |
mu |
A real number - the first parameter of the attritional Claim Severity's LogNormal distribution. |
sigma |
A positive real number - the second parameter of the attritional Claim Severity's LogNormal distribution. |
SlicePoint |
A positive real number - the slice point and the scale parameter of the Claim Severity's Pareto distribution. |
shape |
A positive real number - the shape parameter of the Claim Severity's Pareto distribution. |
Value
The value of the probability density function (pdf) at x with an attritional claim LogNormal distribution with parameters mu and sigma and a large claim Pareto distribution with parameters SlicePoint and shape.
Examples
dSlicedLNormPareto(1200,6,1.5,1000,1.2)
dSlicedLNormPareto(4000,7,1.6,3000,1.4)
The class of the distribution objects
Description
Each object describes one frequency or severity distribution of the simulator:
its parameters (ids used as app input ids, labels, allowed ranges and whether they
must be whole numbers) and the functions the simulator needs. simulate_func
draws values; moments_func gives the mean and standard deviation. Severity
distributions also have survival_func and tail_quantile_func (the
upper-tail probability and its inverse), used to splice Pareto tails and to draw only
the claims that reach a layer, and optionally sum_func, which draws the total
of a given number of claims in one step. Frequency distributions may have
split_func, which draws the number of claims and how many of them are large.
Allowed ranges are param_min_values and param_max_values (NA for no
bound), with param_min_strict and param_max_strict marking bounds the
value may not equal.
Server function for the Distribution Fitting tool application
Description
Server function for the Distribution Fitting tool application
Usage
distribution_fitting_tool_Server(input, output, session)
Arguments
input |
Input for the server function. |
output |
Output for the server function. |
session |
Session for the server function. |
Value
Called by shiny for its side effects, the outputs and observers of a session; the value is not used.
User interface of the Shiny distribution fitting tool
Description
The page is built when the package is installed; run_shiny_distribution_fitting_tool() pairs it with distribution_fitting_tool_Server.
Usage
distribution_fitting_tool_UI
Value
The user interface of the application, a bslib navbar page.
Error function
Description
Error function
Usage
erf(x)
Arguments
x |
A real number. |
Value
The value of the error function at x.
Examples
erf(0.1)
erf(0.5)
A vector with the frequency distribution objects
Description
A vector with the frequency distribution objects
Usage
freq_dist_options
Value
The frequency distribution objects.
A data frame with the frequency distribution parameter placeholders
Description
A data frame with the frequency distribution parameter placeholders
Usage
freq_dist_parameter_placeholders
Value
The frequency distribution parameter placeholders.
Parameter to set the maximum number of pareto slices
Description
Parameter to set the maximum number of pareto slices
Usage
max_number_of_pareto_slices
Value
The maximum number of Pareto Slices.
The cumulative density function (cdf) of a Sliced Gamma-Pareto severity distribution
Description
The cumulative density function (cdf) of a Sliced Gamma-Pareto severity distribution
Usage
pSlicedGammaPareto(x, GShape, GRate, SlicePoint, PShape)
Arguments
x |
A positive real number - the claim amount where the cumulative density function (cdf) will be evaluated. |
GShape |
A positive real number - the shape parameter of the attritional Claim Severity's Gamma distribution. |
GRate |
A positive real number - the rate parameter of the attritional Claim Severity's Gamma distribution. |
SlicePoint |
A positive real number - the slice point and the scale parameter of the tail Claim Severity's Pareto distribution. |
PShape |
A positive real number - the shape parameter of the tail Claim Severity's Pareto distribution. |
Value
The value of the cumulative density function (cdf) at x with an attritional claim Gamma distribution with parameters GShape and GRate and a large claim Pareto distribution with parameters SlicePoint and PShape.
Examples
pSlicedGammaPareto(3000,1,0.0005,1000,1.2)
pSlicedGammaPareto(1000,1.1,0.0006,2000,1.6)
pSlicedGammaPareto(2000,1.2,0.0004,3000,1.4)
The cumulative density function (cdf) of a Sliced LogNormal Pareto severity distribution
Description
The cumulative density function (cdf) of a Sliced LogNormal Pareto severity distribution
Usage
pSlicedLNormPareto(x, mu, sigma, SlicePoint, shape)
Arguments
x |
A positive real number - the claim amount where the cumulative density function (cdf) will be evaluated. |
mu |
A real number - the first parameter of the attritional Claim Severity's LogNormal distribution. |
sigma |
A positive real number - the second parameter of the attritional Claim Severity's LogNormal distribution. |
SlicePoint |
A positive real number - the slice point and the scale parameter of the tail Claim Severity's Pareto distribution. |
shape |
A positive real number - the shape parameter of the tail Claim Severity's Pareto distribution. |
Value
The value of the cumulative density function (cdf) at x with an attritional claim LogNormal distribution with parameters mu and sigma and a large claim Pareto distribution with parameters SlicePoint and shape.
Examples
pSlicedLNormPareto(1200,6,1.5,1000,1.2)
pSlicedLNormPareto(4000,7,1.6,3000,1.4)
The inverse cumulative density function of a Sliced Gamma Pareto severity distribution
Description
The inverse cumulative density function of a Sliced Gamma Pareto severity distribution
Usage
qSlicedGammaPareto(q, GShape, GRate, SlicePoint, PShape)
Arguments
q |
A real number between 0 and 1 - the probability where the inverse cumulative density function will be evaluated. |
GShape |
A positive real number - the shape parameter of the attritional Claim Severity's Gamma distribution. |
GRate |
A positive real number - the rate parameter of the attritional Claim Severity's Gamma distribution. |
SlicePoint |
A positive real number - the slice point and the scale parameter of the tail Claim Severity's Pareto distribution. |
PShape |
A positive real number - the shape parameter of the tail Claim Severity's Pareto distribution. |
Value
The value of the inverse cumulative density function at q with an attritional claim Gamma distribution with parameters GShape and GRate and a large claim Pareto distribution with parameters SlicePoint and PShape.
Examples
qSlicedGammaPareto(0.5,1,0.0005,1000,1.2)
qSlicedGammaPareto(0.2,1.1,0.0006,2000,1.6)
qSlicedGammaPareto(0.8,1.2,0.0004,3000,1.4)
The inverse cumulative density function of a Sliced LogNormal Pareto severity distribution
Description
The inverse cumulative density function of a Sliced LogNormal Pareto severity distribution
Usage
qSlicedLNormPareto(q, mu, sigma, SlicePoint, shape)
Arguments
q |
A real number between 0 and 1 - the probability where the inverse cumulative density function will be evaluated. |
mu |
A real number - the first parameter of the attritional Claim Severity's LogNormal distribution. |
sigma |
A positive real number - the second parameter of the attritional Claim Severity's LogNormal distribution. |
SlicePoint |
A positive real number - the slice point and the scale parameter of the tail Claim Severity's Pareto distribution. |
shape |
A positive real number - the shape parameter of the tail Claim Severity's Pareto distribution. |
Value
The value of the inverse cumulative density function at q with an attritional claim LogNormal distribution with parameters mu and sigma and a large claim Pareto distribution with parameters SlicePoint and shape.
Examples
qSlicedLNormPareto(0.5,6,1.5,1000,1.2)
qSlicedLNormPareto(0.7,7,1.6,3000,1.4)
A vector with the reinsurance structure options
Description
A vector with the reinsurance structure options
Usage
reinsurance_structures_options
Value
The reinsurance structure options
A function to run the distribution fitting tool application
Description
A function to run the distribution fitting tool application
Usage
run_shiny_distribution_fitting_tool()
Value
A shiny app object. Printing it, as happens when the function is called at the console, opens the application; it can also be passed to shiny::runApp().
Examples
if (interactive()) {
run_shiny_distribution_fitting_tool()
}
A function to run the GLM fitting tool application
Description
A function to run the GLM fitting tool application
Usage
run_shiny_glm_fitting_tool()
Value
A shiny app object. Printing it, as happens when the function is called at the console, opens the application; it can also be passed to shiny::runApp().
Examples
if (interactive()) {
run_shiny_glm_fitting_tool()
}
A function to run the shiny simulator application
Description
A function to run the shiny simulator application
Usage
run_shiny_simulator()
Value
Opens the shiny simulator application
Examples
if (interactive()) {
run_shiny_simulator()
}
A vector with the severity distribution objects
Description
A named list of distributionClass objects, one for each severity distribution
of the simulator: Normal, LogNormal, Gamma, Exponential, Pareto and Fixed_Severity.
The names are the values accepted by the sevDistr argument of
simulate_function(). The Normal distribution has its own parameter ids
(normal_mean, normal_sd), so that switching between the Normal and the Log-Normal in
the app does not carry values across.
Usage
sev_dist_options
Value
The severity distribution objects.
A data frame with the severity distribution parameter placeholders
Description
A data frame with the severity distribution parameter placeholders
Usage
sev_dist_parameter_placeholders
Value
The severity distribution parameter placeholders.
Server function for the Shiny Simulator application
Description
Server function for the Shiny Simulator application
Usage
shiny_simulator_server(input, output, session)
Arguments
input |
Input for the server function. |
output |
Output for the server function. |
session |
Session for the server function. |
Value
Returns server rendering for the shiny application.
UI file for the Shiny NetSimR Simulator Tool
Description
UI file for the Shiny NetSimR Simulator Tool
Usage
shiny_simulator_ui
Value
Returns the UI code for the shiny application.
Simulate claims with a frequency-severity model
Description
A simpler interface to simulate_function, with short argument names and
defaults for everything optional. Leaving an option out (NULL) switches the feature off:
no seed, no Pareto slices, no cap, no reinstatement limit.
Usage
simulate_claims(
n_sims,
frequency,
frequency_params,
severity,
severity_params,
seed = NULL,
truncate_at_zero = FALSE,
pareto_thresholds = NULL,
pareto_alphas = NULL,
severity_cap = NULL,
eel_layer = "none",
eel_deductible = NULL,
eel_limit = NULL,
eel_reinstatements = NULL,
agg_layer = "none",
agg_deductible = NULL,
agg_limit = NULL,
parallel = FALSE,
chunk_size = NULL,
gross = TRUE,
shortcuts = TRUE,
progress = NULL
)
Arguments
n_sims |
Number of simulations (e.g. years). |
frequency |
Name of the claim count distribution; see Details. |
frequency_params |
Parameters of the claim count distribution, either all unnamed in the order of Details or all named. |
severity |
Name of the claim size distribution; see Details. |
severity_params |
Parameters of the claim size distribution, either all unnamed in the order of Details or all named. |
seed |
A whole number for a reproducible run. NULL (the default) uses the current random number stream, so |
truncate_at_zero |
TRUE to draw Normal claim sizes from the Normal distribution truncated at zero, so no claim is negative. Only used with the Normal severity. |
pareto_thresholds |
Increasing claim sizes above which the severity tail is replaced by Pareto slices, one per slice (at most six). NULL (the default) for no slices. |
pareto_alphas |
The Pareto alpha of each slice, one per threshold. |
severity_cap |
The largest amount a single claim can reach, or NULL (the default) for no cap. |
eel_layer |
The each-and-every-loss layer: "none" (the default), "unlimited", "limited" or "exclude". |
eel_deductible |
The deductible of the each-and-every-loss layer. |
eel_limit |
The limit of a "limited" or "exclude" each-and-every-loss layer. |
eel_reinstatements |
The number of reinstatements of a "limited" each-and-every-loss layer, so it pays at most |
agg_layer |
The aggregate layer: "none" (the default), "unlimited", "limited" or "exclude". |
agg_deductible |
The deductible of the aggregate layer. |
agg_limit |
The limit of a "limited" or "exclude" aggregate layer. |
parallel |
TRUE to run the chunks of simulations on parallel workers. Results are the same as a sequential run. |
chunk_size |
The number of simulations per vectorised batch; NULL (the default) chooses it from the expected number of claims. |
gross |
TRUE (the default) to return the gross totals before the layers. FALSE allows a much faster run with an "unlimited" or "limited" each-and-every-loss layer, by drawing only the claims that reach it. |
shortcuts |
TRUE (the default) to use exact shortcuts where the settings allow; see |
progress |
An optional function called after each chunk of a sequential run with the fraction done and a short description. |
Details
Distributions are chosen by name; case, spaces and underscores are ignored, so "Negative Binomial", "negative_binomial" and "Negative_Binomial" are the same. Their parameters are given in the order below, or named with these names:
| Distribution | Type | Parameters |
| Poisson | frequency | lambda |
| Negative_Binomial | frequency | r, beta (Gamma shape and scale of the Poisson mean) |
| Binomial | frequency | n, p |
| Fixed_number_of_Counts | frequency | count |
| Normal | severity | mean, sd |
| LogNormal | severity | meanlog, sdlog |
| Gamma | severity | shape, scale |
| Exponential | severity | rate |
| Pareto | severity | alpha, x_m (minimum) |
| Fixed_Severity | severity | amount |
Layers are "none", "unlimited" (everything above the deductible), "limited" (the limit excess of the deductible) or "exclude" (the claims with that layer removed). The each-and-every-loss layer applies to every claim; the aggregate layer applies to each simulation's total after the each-and-every-loss layer.
Value
A data frame with one row per simulation: claim_counts, total_claims (after the layers), gross_claims (before them, unless gross = FALSE) and, with limited reinstatements, number_of_reinstatements_used.
See Also
simulate_function, which this calls, and run_shiny_simulator for the same model in an app.
Examples
# 10,000 years of Poisson claim counts with Log-Normal claim sizes
claims <- simulate_claims(
10000, frequency = "Poisson", frequency_params = 3,
severity = "LogNormal", severity_params = c(meanlog = 8, sdlog = 1.5), seed = 1
)
summary(claims$total_claims)
# a Pareto tail above 100,000, and a layer of 50,000 excess of 20,000 on each
# claim with two reinstatements
ceded <- simulate_claims(
10000, "Poisson", 3, "LogNormal", c(8, 1.5), seed = 1,
pareto_thresholds = 100000, pareto_alphas = 1.5,
eel_layer = "limited", eel_deductible = 20000, eel_limit = 50000,
eel_reinstatements = 2
)
mean(ceded$total_claims)
Simulate insurance claims with reinsurance structures
Description
A function to simulate frequency - severity of insurance claims using chunked vectorisation. The function applies severity cap, reinsurance structure for each and every loss claim, reinsurance structure for aggregate claims, and allows for piecewise pareto slices
Usage
simulate_function(
numOfSimulations,
freq_params,
sev_params,
seedSetBinary = FALSE,
seedValue = NULL,
freqDistr,
sevDistr,
paretoSlice = FALSE,
pareto_slice_times = NULL,
slice_pareto_alphas = NULL,
slice_pareto_x_ms = NULL,
sevCapBinary = FALSE,
sev_cap_amount = NULL,
reinsuranceStructureEEL = "No Reinsurance Structure",
reinsurance_structure_eel_dedctible_amount = NULL,
reinsurance_structure_eel_limit_amount = NULL,
reinsuranceStructureAL = "No Reinsurance Structure",
reinsurance_structure_al_dedctible_amount = NULL,
reinsurance_structure_al_limit_amount = NULL,
reinsuranceStructureLimitedReinstatements = FALSE,
reinsuranceStructureReinstatementLimit = NULL,
multiprocessing = FALSE,
sevTruncateAtZero = FALSE,
chunk_size = NULL,
gross = TRUE,
shortcuts = TRUE,
progress = NULL
)
Arguments
numOfSimulations |
The number of simulations to run. |
freq_params |
A vector of the frequency distribution parameters. |
sev_params |
A vector of the severity distribution parameters. |
seedSetBinary |
True if there is a fixed seed, otherwise false. |
seedValue |
The seed value, a whole number between |
freqDistr |
The frequency distribution. Options are as per the freq_dist_options. |
sevDistr |
The severity distribution. Options are as per the sev_dist_options. |
paretoSlice |
True if there is Pareto slicing. |
pareto_slice_times |
The number of Pareto slices. |
slice_pareto_alphas |
A vector of Pareto slices' alpha parameters. |
slice_pareto_x_ms |
A vector of Pareto slices' x_m parameters. |
sevCapBinary |
True if there is a severity cap. |
sev_cap_amount |
The severity cap amount. |
reinsuranceStructureEEL |
The chosen reinsurance structure for each and every loss claim. |
reinsurance_structure_eel_dedctible_amount |
The deductible for each and every loss reinsurance structure. |
reinsurance_structure_eel_limit_amount |
The limit for each and every loss reinsurance structure. |
reinsuranceStructureAL |
The chosen reinsurance structure for aggregate claims. |
reinsurance_structure_al_dedctible_amount |
The deductible for aggregate reinsurance structure. |
reinsurance_structure_al_limit_amount |
The limit for aggregate reinsurance structure. |
reinsuranceStructureLimitedReinstatements |
True if there is a limit in reinstatements, otherwise false. |
reinsuranceStructureReinstatementLimit |
The reinstatement limit. |
multiprocessing |
True to run the chunks in parallel with the future package, otherwise false. A future plan with more than one worker that the caller has already set is reused and left running. Otherwise the call starts a multisession plan with one worker per available core ( |
sevTruncateAtZero |
True to draw Normal severities from the Normal distribution truncated at zero, so that no claim is negative. Ignored for other severity distributions. Defaults to FALSE. |
chunk_size |
The number of simulations processed per vectorised batch. By default (NULL) it is chosen from the expected number of claims per simulation, so that a batch holds about a million claims (between 100 and 10,000 simulations). |
gross |
True (the default) to return the gross total claims before reinsurance. Set it to FALSE when only the totals after the structures are needed: with an each-and-every-loss layer this allows drawing only the claims that reach the layer, which is much faster. |
shortcuts |
True (the default) to use exact shortcuts where the settings allow: when no layer, cap, Pareto slice or truncation acts on individual claims, each simulation's total is drawn in one step for the Normal, Gamma, Exponential and fixed severities; with |
progress |
An optional function called after each chunk of a sequential run with the fraction done and a short description, e.g. to update a progress bar. |
Details
Random numbers: each chunk of simulations uses its own L'Ecuyer-CMRG random stream,
derived from one seed, so a run gives the same results whether or not it runs in
parallel. With seedSetBinary = TRUE the run is reproducible from seedValue
and the caller's random number stream is left unchanged; otherwise the seed is drawn
from the caller's stream, so set.seed() before the call also makes it reproducible.
The streams always use Inversion for normal draws and Rejection sampling, so a seed
gives the same results whatever the caller's RNGkind(), which is restored afterwards.
Results depend on the chunk size, which by default adapts to the expected number of
claims per simulation.
Value
A data frame with one row per simulation: the claim count, the total claims after the reinsurance structures, the gross total claims before them (unless gross = FALSE), and the number of reinstatements used (when reinstatements are limited).
Stops with an error that names any required setting that is missing or invalid.
Examples
# 1,000 simulated years of Poisson claim counts with Normal claim sizes, no reinsurance
results <- simulate_function(
numOfSimulations = 1000, freq_params = 3, sev_params = c(1000, 200),
seedSetBinary = TRUE, seedValue = 1, freqDistr = "Poisson", sevDistr = "Normal"
)
summary(results$total_claims)
# the same claims ceded to a layer of 1,500 excess of 800 on each claim
layer <- simulate_function(
numOfSimulations = 1000, freq_params = 3, sev_params = c(1000, 200),
seedSetBinary = TRUE, seedValue = 1, freqDistr = "Poisson", sevDistr = "Normal",
reinsuranceStructureEEL = "Limited Layer",
reinsurance_structure_eel_dedctible_amount = 800,
reinsurance_structure_eel_limit_amount = 1500
)
mean(layer$total_claims)