root.period: Fitting loss frequency distribution

Description Usage Arguments Value See Also Examples

Description

Function fitting frequency distribution of losses aggregated by a given period and drawning rootogram.

Usage

1
2
3
4
root.period(data, period, type, begin = NULL, end = NULL, method = c("ML", "MinChisq"),
 	 scale = c("sqrt", "raw"), wknd = TRUE, crt = 0, bar_type = c("hanging", "standing", "deviation"),
       rect_gp = gpar(fill = "lightgray"), lines_gp = gpar(col = "red"), points_gp = gpar(col = "red"), 
       pch = 19, newpage = TRUE)

Arguments

data

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

period

describes how data should be agregated; possible period values are: "days","weeks","months" and "quarters"

type

distribution to be fitted; could be "poisson", "binomial", "nbinomial"

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

method

method to be used; could be "ML", "MinChisq"; see goodfit

scale

a raw or square root scale; see rootogram

wknd

a logical value indicating whether weekend days (wknd) count as days being bussiness days; wknd is designed only for period = "days"

crt

correction indicates how many days should be excluded from the time horizon; it is designed for holidays and only for period = "days"

bar_type

should the bars be hanging or standing or indicate the deviation between observed and fitted frequencies; see type in rootogram

rect_gp

graphical parameters of the rectangles; see rootogram

lines_gp

graphical parameters of the lines; see rootogram

points_gp

graphical parameters of the points; see rootogram

pch

plotting character for the points; see rootogram

Value

table

table of observed and fitted values

param

fitted parameters

p

value P(> X^2) from summary of goodfit

See Also

rootogram, goodfit, weekdays, loss.data.object, hist.period

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
data(loss.data.object)
x<- read.loss(5,5,loss.data.object)

# first example:
y<- root.period(x,"days","poisson")
	t <- y$table; t
 	par <- y$param; par
	p <- y$p; p

# second example: 

 root.period(x,"days","nbinomial") # rather good fit
 root.period(x,"weeks","nbinomial")
 root.period(x,"months","nbinomial") 
 root.period(x,"quarters","nbinomial") # that does not fit nbinomial at all
 root.period(x,"quarters","nbinomial",begin="2010-01-01",end="2010-12-31") # that at least computes something

# third example:
 root.period(x,"days","nbinomial",scale="raw") # values are plotted on the raw scale (y label is Frequency)
 root.period(x,"days","nbinomial") # values are plotted on the square root scale (y label is sqrt(Frequency))

# fourth example:
x<- read.loss(1,2,loss.data.object)
b = "2010-01-01"
e = "2010-12-31"
 root.period(x,"days","nbinomial",begin=b,end=e) # fit via ML (Maximum Likelihood) 
 root.period(x,"days","nbinomial","MinChisq",begin=b,end=e) # fit via Minimum Chi-squared.
 # there are some significant differences in function values table, param and p

# fifth example:
 # some changes of bar colours, lines and points types
 root.period(x,"days","nbinomial",rect_gp =gpar(fill = "lightblue"),
		lines_gp = gpar(col = "black"),points_gp = gpar(col = "darkblue"), pch = 20)

# sixth example:
 root.period(x,"days","nbinomial") # differences in bar types
 root.period(x,"days","nbinomial",bar_type="standing")
 root.period(x,"days","nbinomial",bar_type="deviation")

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