Description Usage Arguments Value See Also Examples
Function fitting frequency distribution of losses aggregated by a given period and drawning rootogram.
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)
|
data |
list with two columnes, first with dates of events and second with loss amount |
period |
describes how data should be agregated; possible |
type |
distribution to be fitted; could be |
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 |
scale |
a raw or square root scale; see |
wknd |
a logical value indicating whether weekend days ( |
crt |
correction indicates how many days should be excluded from the time horizon; it is designed for holidays and only for |
bar_type |
should the bars be hanging or standing or indicate the deviation between observed and fitted frequencies; see |
rect_gp |
graphical parameters of the rectangles; see |
lines_gp |
graphical parameters of the lines; see |
points_gp |
graphical parameters of the points; see |
pch |
plotting character for the points; see |
table |
table of observed and fitted values |
param |
fitted parameters |
p |
value |
rootogram
, goodfit
, weekdays
, loss.data.object
, hist.period
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")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.