period.loss: Aggregating losses by period

Description Usage Arguments Value See Also Examples

Description

Function aggregating losses by a given period.

Usage

1
period.loss(data, period = c("none", "days", "weeks", "months", "quarters"),dts = FALSE)

Arguments

data

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

period

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

dts

logical: whether to have period begins' dates or not (FALSE default)

Value

List of aggreagated losses.

See Also

key.sum, weekdays, as.Date

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
data(loss.data.object)
x<- read.loss(1,2,loss.data.object)
 t0 <- period.loss(x,"none"); t0
 t1 <- period.loss(x,"days"); t1
 t2 <- period.loss(x,"weeks"); t2
 t3 <- period.loss(x,"months"); t3
 t4 <- period.loss(x,"quarters"); t4

sum(t0);sum(t1); sum(t2); sum(t3); sum(t4) # note that all these values must be equal

# the same with dates - note that only for days and no period there are original
# dates; for weeks, months and periods there are only dates opening period in which
# loss occured

 t0 <- period.loss(x,"none",dts=T); t0
 t1 <- period.loss(x,"days",dts=T); t1
 t2 <- period.loss(x,"weeks",dts=T); t2
 t3 <- period.loss(x,"months",dts=T); t3
 t4 <- period.loss(x,"quarters",dts=T); t4

sum(t0);sum(t1); sum(t2); sum(t3); sum(t4)

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