Payments2Triangle: Converts Payments to a triangle

Description Usage Arguments Value Examples

View source: R/Payments2Triangle.R

Description

Payments2Triangle converts a list of cash flows to a triangle.

Usage

1
2
3
4
5
6
7
8
Payments2Triangle(
  accidentDate,
  transactionDate,
  cashFlows,
  years = NA,
  mode = "year",
  evalDate = "01-01"
)

Arguments

accidentDate

Date vector. Reference date for the triangle: accident date or underwriting date depending on the reference

transactionDate

Date vector. Date of transaction.

cashFlows

Numeric vector. Cash flows corresponding to the reference date and made at transaction date.

years

Numeric vector. Years to include in the analysis. By default, all years are taken.

mode

string. The mode of aggregation for triangle. The different possible modes are:

  • semester: aggregation over semesters for accident period and semesters for development period. Implies evalDate in ("07-01", "01-01")

  • quarter: aggregation over quarters for accident period and semesters for development period. Implies evalDate in ("10-01","07-01","04-01", "01-01")

  • year: aggregation on yearly step from evalDate for both accident and development period

  • yearRef: aggregation on fiscal years for accident periods and a first development period corresponding to the timelapse between beginning of the year and evalDate

evalDate

String. Date of evaluation, with format "m-d" (ex: "12-23"). All data after this date for the maximal year will not be considered.

Value

Triangle as a matrix

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
library(lubridate)
library(data.table)
origin_claim <- as.Date("2010-01-03")
origin_transaction <- as.Date("2010-01-25")
dates_claim <- origin_claim %m+% months(0:59)
dates_transaction <- origin_transaction %m+% months(0:59)
d <- data.table(expand.grid(dates_claim, dates_transaction))
colnames(d) <- c("date_claim", "date_transaction")
d <- d[date_claim < date_transaction]
d$amount <- 1:1
Payments2Triangle(d$date_claim, d$date_transaction, d$amount, years = NA, mode = "yearRef", evalDate = "01-01")
Payments2Triangle(d$date_claim, d$date_transaction, d$amount, years = 2011:2014, mode = "yearRef", evalDate = "01-01")
Payments2Triangle(d$date_claim, d$date_transaction, d$amount, years = NA, mode = "yearRef", evalDate = "04-05")
Payments2Triangle(d$date_claim, d$date_transaction, d$amount, years = NA, mode = "year", evalDate = "01-01")
Payments2Triangle(d$date_claim, d$date_transaction, d$amount, years = NA, mode = "year", evalDate = "04-05")
Payments2Triangle(d$date_claim, d$date_transaction, d$amount, years = NA, mode = "semester", evalDate = "01-01")
Payments2Triangle(d$date_claim, d$date_transaction, d$amount, years = NA, mode = "quarter", evalDate = "01-01")

ArnaudBu/ReservingLad documentation built on Sept. 21, 2021, 1:19 p.m.