Aggregate loss models:
x<-c(0:10)
plot(pgamma(x,2,1),type="l")
We can use any of the discretisation techniques
library(actuar)
## Warning: package 'actuar' was built under R version 4.1.2
##
## Attaching package: 'actuar'
## The following objects are masked from 'package:stats':
##
## sd, var
## The following object is masked from 'package:grDevices':
##
## cm
fl<-discretise(pgamma(x,2,1),from=0, to=5,method = "lower")
fu<-discretise(pgamma(x,2,1),from=0, to=5,method = "upper")
fr<-discretise(pgamma(x,2,1),from=0, to=5,method = "rounding")
fun<-discretise(pgamma(x,2,1),from=0, to=5,method = "unbiased",lev=levgamma(x,2,1))
for (i in 2:6) {
fl[i]<-fl[i-1]+fl[i]
}
for (i in 2:5) {
fu[i]<-fu[i-1]+fu[i]
}
for (i in 2:5) {
fr[i]<-fr[i-1]+fr[i]
}
for (i in 2:6) {
fun[i]<-fun[i-1]+fun[i]
}
x<-c(0:5)
plot(pgamma(x,2,1),type="l")
lines(fl,type="step",col="red")
## Warning in plot.xy(xy.coords(x, y), type = type, ...): plot type 'step' will be
## truncated to first character
plot(pgamma(x,2,1),type="l")
lines(fu,type="step",col="red")
## Warning in plot.xy(xy.coords(x, y), type = type, ...): plot type 'step' will be
## truncated to first character
plot(pgamma(x,2,1),type="l")
lines(fr,type="step",col="red")
## Warning in plot.xy(xy.coords(x, y), type = type, ...): plot type 'step' will be
## truncated to first character
plot(pgamma(x,2,1),type="l")
lines(fun,type="step",col="red")
## Warning in plot.xy(xy.coords(x, y), type = type, ...): plot type 'step' will be
## truncated to first character
First, we define our severity distribution and discretised the values by using the unbiased approach.
fx <- discretize(pgamma(x, 2, 1), from = 0,
to = 22,
method = "unbiased",
lev = levgamma(x, 2, 1))
Now, we can create our compund distribution by indicasting that the frequency is Poisson lambda and then indicating the scale, her, we just use the mean from the gamma.
Fs <- aggregateDist("recursive",
model.freq = "poisson",
model.sev = fx,
lambda = 10, x.scale = 2)
plot(Fs)
For the second problem we would need to use the convolution approach. This would be a long process. Instead, we use our new function:
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)
## Aggregate Claim Amount Empirical CDF:
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 0.0 175.0 300.0 314.5 425.0 2000.0
c(Fs(0), diff(Fs(25 * 0:21)))
## [1] 0.05000000 0.01500000 0.02337500 0.03467500 0.03257656 0.03578639
## [7] 0.03980787 0.04356232 0.04751800 0.04903380 0.05189806 0.05137886
## [13] 0.05118691 0.05030486 0.04818189 0.04575882 0.04280890 0.03937836
## [19] 0.03574568 0.03196808 0.02832446 0.02478833
plot(Fs)