View source: R/aggregateDist.R
aggregateDist  R Documentation 
Compute the aggregate claim amount cumulative distribution function of a portfolio over a period using one of five methods.
aggregateDist(method = c("recursive", "convolution", "normal", "npower", "simulation"), model.freq = NULL, model.sev = NULL, p0 = NULL, x.scale = 1, convolve = 0, moments, nb.simul, ..., tol = 1e06, maxit = 500, echo = FALSE) ## S3 method for class 'aggregateDist' print(x, ...) ## S3 method for class 'aggregateDist' plot(x, xlim, ylab = expression(F[S](x)), main = "Aggregate Claim Amount Distribution", sub = comment(x), ...) ## S3 method for class 'aggregateDist' summary(object, ...) ## S3 method for class 'aggregateDist' mean(x, ...) ## S3 method for class 'aggregateDist' diff(x, ...)
method 
method to be used 
model.freq 
for 
model.sev 
for 
p0 
arbitrary probability at zero for the frequency
distribution. Creates a zeromodified or zerotruncated
distribution if not 
x.scale 
value of an amount of 1 in the severity model (monetary
unit). Used only with 
convolve 
number of times to convolve the resulting distribution
with itself. Used only with 
moments 
vector of the true moments of the aggregate claim
amount distribution; required only by the 
nb.simul 
number of simulations for the 
... 
parameters of the frequency distribution for the

tol 
the resulting cumulative distribution in the

maxit 
maximum number of recursions in the 
echo 
logical; echo the recursions to screen in the

x, object 
an object of class 
xlim 
numeric of length 2; the x limits of the plot. 
ylab 
label of the y axis. 
main 
main title. 
sub 
subtitle, defaulting to the calculation method. 
aggregateDist
returns a function to compute the cumulative
distribution function (cdf) of the aggregate claim amount distribution
in any point.
The "recursive"
method computes the cdf using the Panjer
algorithm; the "convolution"
method using convolutions; the
"normal"
method using a normal approximation; the
"npower"
method using the Normal Power 2 approximation; the
"simulation"
method using simulations. More details follow.
A function of class "aggregateDist"
, inheriting from the
"function"
class when using normal and Normal Power
approximations and additionally inheriting from the "ecdf"
and
"stepfun"
classes when other methods are used.
There are methods available to summarize (summary
), represent
(print
), plot (plot
), compute quantiles
(quantile
) and compute the mean (mean
) of
"aggregateDist"
objects.
For the diff
method: a numeric vector of probabilities
corresponding to the probability mass function evaluated
at the knots of the distribution.
The frequency distribution must be a member of the (a, b, 0) or (a, b, 1) families of discrete distributions.
To use a distribution from the (a, b, 0) family,
model.freq
must be one of
"binomial"
,
"geometric"
,
"negative binomial"
or
"poisson"
,
and p0
must be NULL
.
To use a zerotruncated distribution from the (a, b, 1) family,
model.freq
may be one of the strings above together with
p0 = 0
. As a shortcut, model.freq
may also be one of
"zerotruncated binomial"
,
"zerotruncated geometric"
,
"zerotruncated negative binomial"
,
"zerotruncated poisson"
or
"logarithmic"
,
and p0
is then ignored (with a warning if non NULL
).
(Note: since the logarithmic distribution is always zerotruncated.
model.freq = "logarithmic"
may be used with either p0 =
NULL
or p0 = 0
.)
To use a zeromodified distribution from the (a, b, 1) family,
model.freq
may be one of standard frequency distributions
mentioned above with p0
set to some probability that the
distribution takes the value 0. It is equivalent, but more
explicit, to set model.freq
to one of
"zeromodified binomial"
,
"zeromodified geometric"
,
"zeromodified negative binomial"
,
"zeromodified poisson"
or
"zeromodified logarithmic"
.
The parameters of the frequency distribution must be specified using
names identical to the arguments of the appropriate function
dbinom
, dgeom
, dnbinom
,
dpois
or dlogarithmic
. In the latter case,
do take note that the parametrization of dlogarithmic
is
different from Appendix B of Klugman et al. (2012).
If the length of p0
is greater than one, only the first element
is used, with a warning.
model.sev
is a vector of the (discretized) claim amount
distribution X; the first element must be fx(0) = Pr[X = 0].
The recursion will fail to start if the expected number of claims is
too large. One may divide the appropriate parameter of the frequency
distribution by 2^n and convolve the resulting distribution
n = convolve
times.
Failure to obtain a cumulative distribution function less than
tol
away from 1 within maxit
iterations is often due
to too coarse a discretization of the severity distribution.
The cumulative distribution function (cdf) Fs(x) of the aggregate claim amount of a portfolio in the collective risk model is
Fs(x) = sum(n; Fx^{*n}(x) * pn)
for x = 0, 1, …; pn = Pr[N = n] is the frequency probability mass function and Fx^{*n}(x) is the cdf of the nth convolution of the (discrete) claim amount random variable.
model.freq
is vector pn of the number of claims
probabilities; the first element must be Pr[N = 0].
model.sev
is vector fx(x) of the (discretized)
claim amount distribution; the first element must be
fx(0).
The Normal approximation of a cumulative distribution function (cdf) F(x) with mean m and standard deviation s is
F(x) ~= pnorm((x  m)/s).
The Normal Power 2 approximation of a cumulative distribution function (cdf) F(x) with mean m, standard deviation s and skewness g is
F(x) ~= pnorm(3/g + sqrt(9/g^2 + 1 + (6/g) * (x  m)/s)).
This formula is valid only for the righthand tail of the distribution and skewness should not exceed unity.
This methods returns the empirical distribution function of a sample
of size nb.simul
of the aggregate claim amount distribution
specified by model.freq
and
model.sev
. rcomphierarc
is used for the simulation of
claim amounts, hence both the frequency and severity models can be
mixtures of distributions.
Vincent Goulet vincent.goulet@act.ulaval.ca and LouisPhilippe Pouliot
Klugman, S. A., Panjer, H. H. and Willmot, G. E. (2012), Loss Models, From Data to Decisions, Fourth Edition, Wiley.
Daykin, C.D., Pentikäinen, T. and Pesonen, M. (1994), Practical Risk Theory for Actuaries, Chapman & Hall.
discretize
to discretize a severity distribution;
mean.aggregateDist
to compute the mean of the
distribution;
quantile.aggregateDist
to compute the quantiles or the
ValueatRisk;
CTE.aggregateDist
to compute the Conditional Tail
Expectation (or Tail ValueatRisk);
rcomphierarc
.
## Convolution method (example 9.5 of Klugman et al. (2012)) fx < c(0, 0.15, 0.2, 0.25, 0.125, 0.075, 0.05, 0.05, 0.05, 0.025, 0.025) pn < c(0.05, 0.1, 0.15, 0.2, 0.25, 0.15, 0.06, 0.03, 0.01) Fs < aggregateDist("convolution", model.freq = pn, model.sev = fx, x.scale = 25) summary(Fs) c(Fs(0), diff(Fs(25 * 0:21))) # probability mass function plot(Fs) ## Recursive method (example 9.10 of Klugman et al. (2012)) fx < c(0, crossprod(c(2, 1)/3, matrix(c(0.6, 0.7, 0.4, 0, 0, 0.3), 2, 3))) Fs < aggregateDist("recursive", model.freq = "poisson", model.sev = fx, lambda = 3) plot(Fs) Fs(knots(Fs)) # cdf evaluated at its knots diff(Fs) # probability mass function ## Recursive method (high frequency) fx < c(0, 0.15, 0.2, 0.25, 0.125, 0.075, 0.05, 0.05, 0.05, 0.025, 0.025) ## Not run: Fs < aggregateDist("recursive", model.freq = "poisson", model.sev = fx, lambda = 1000) ## End(Not run) Fs < aggregateDist("recursive", model.freq = "poisson", model.sev = fx, lambda = 250, convolve = 2, maxit = 1500) plot(Fs) ## Recursive method (zeromodified distribution; example 9.11 of ## Klugman et al. (2012)) Fn < aggregateDist("recursive", model.freq = "binomial", model.sev = c(0.3, 0.5, 0.2), x.scale = 50, p0 = 0.4, size = 3, prob = 0.3) diff(Fn) ## Equivalent but more explicit call aggregateDist("recursive", model.freq = "zeromodified binomial", model.sev = c(0.3, 0.5, 0.2), x.scale = 50, p0 = 0.4, size = 3, prob = 0.3) ## Recursive method (zerotruncated distribution). Using 'fx' above ## would mean that both Pr[N = 0] = 0 and Pr[X = 0] = 0, therefore ## Pr[S = 0] = 0 and recursions would not start. fx < discretize(pexp(x, 1), from = 0, to = 100, method = "upper") fx[1L] # non zero aggregateDist("recursive", model.freq = "zerotruncated poisson", model.sev = fx, lambda = 3, x.scale = 25, echo=TRUE) ## Normal Power approximation Fs < aggregateDist("npower", moments = c(200, 200, 0.5)) Fs(210) ## Simulation method model.freq < expression(data = rpois(3)) model.sev < expression(data = rgamma(100, 2)) Fs < aggregateDist("simulation", nb.simul = 1000, model.freq, model.sev) mean(Fs) plot(Fs) ## Evaluation of ruin probabilities using Beekman's formula with ## Exponential(1) claim severity, Poisson(1) frequency and premium rate ## c = 1.2. fx < discretize(pexp(x, 1), from = 0, to = 100, method = "lower") phi0 < 0.2/1.2 Fs < aggregateDist(method = "recursive", model.freq = "geometric", model.sev = fx, prob = phi0) 1  Fs(400) # approximate ruin probability u < 0:100 plot(u, 1  Fs(u), type = "l", main = "Ruin probability")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.