mc: Monte Carlo loss simulation

Description Usage Arguments Value Note See Also Examples

Description

Performs Monte Carlo loss simulation for a given number of given periods and some fitted distributions for loss frequency and denstiy.

Usage

1
2
3
4
5
6
mc(x, rfun = NULL, period, iterate, nmb = 1000, begin = NULL, end = NULL,
   wknd = TRUE, crt = 0, type = NULL, param = NULL, zero = F, distname = NULL, fit=T,
   flist = c("beta", "cauchy", "chi-squared", "exponential","f", "gamma", "geometric", 
   "log-normal", "logistic", "normal", "weibull", "inverse gaussian"), 

   p = c(0.95, 0.99, 0.999), ...)

Arguments

x

list with two columnes, first with dates of events and second with loss amount

rfun

random generation for the chosen distribution; NULL default

period

could be "days", "weeks", "months" or "quarters" (loss are aggregated by days, weeks, months or quarters respectively)

iterate

could be "years", "quarters", "months" or "weeks"

nmb

number of period iterations

begin

period begin date; if not given, it would be minimum from loss dates

end

period end date; if not given, it would be maximum from loss dates

wknd

whether to have 252 days a year (FALSE) or not (TRUE, then 365), designed only for period = "days"

crt

correction; argument passed to root.period

type

could be "poisson", "binomial", "nbinomial", if not given, it would be chosen (fitted) automatically

param

start parameters (only for rfun not being character, see examples)

zero

should zero losses be drawn (TRUE) or not (FALSE)?

distname

distribution name; if rfun= rbeta, it should be distname = "beta" (it is designed for that case)

fit

logical: fit rfun parameters?

flist

list of distributions "beta", "cauchy", "chi-squared", "exponential", "gamma", "geometric", "log-normal", "logistic", "negative binomial", "normal", "poisson", "weibull", "inverse gaussian"

p

confidence level (default c(0.95, 0.99, 0.999))

...

arguments passed to root.period

Value

table$losses

generated losses

table$q

losses p-quantile

ad

absolute differences between empirical and fitted density values

Note

"log-normal" and "lognormal" are not the same anymore; only "log-normal" would work

See Also

root.period, loss.fit.dist, fitdistr

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
data(loss.data.object)


x<- read.loss(3,2,loss.data.object)

# first example:

 l1 = mc(x,begin="2010-01-01",end="2010-12-31")$table
 l1

# second example:

 l2 = mc(x,rfun = "inverse gaussian",nmb =100)$table
 l2 # yearly losses for 100 years, 365 days per year

# third example:

 l3 = mc(x,rfun = "beta", p=c(0.95))$table

# fourth example:

 l4 = mc(x,rfun = "beta",type = "binomial")$table # type of frequency distribution is chosen

# fifth example:

 l5 = mc(x,rfun = rbeta,param = list(shape1 = 0.47,shape2 = 36.66),period = "days",distname = "beta")$table
# parameters for beta distribution are given

# sixth example:

 l6 = mc(x,rfun = "normal") # comapare loss.fit.dist("normal",x) - fit is very poor

# seventh example:

 l7 = mc(x,rfun = rnorm,type = "binomial",param = list(mean=3,sd=4))$table
# parameters for normal distribution are given (and very poor, comparing loss.fit.dist("normal",x) or sixth example )

# eighth example:

 l8 = mc(x,flist= c("normal","inverse gaussian"))$table

barryrowlingson/opVaR documentation built on May 11, 2019, 7:24 p.m.