Generating claims history triangle from dataframe
generate_triangle.Rd
Creates a matrix with each historic origin year as row and as calendar year in columns and sums of col_name entrys in upper right triangle of the matrix
Usage
generate_triangle(
data,
col_name,
first_orig_year,
last_orig_year,
include_small_claims = FALSE
)
Details
last_orig_year will automatically be treated as the last observed calendar year, so the resulting matrix is quadratic /cr if include_small_claims = FALSE, data must contain an additional column named "Dev_year_since_large to separate small from large claim history
Examples
claims_data <- data.frame(Claim_id = c(rep("Claim1", 3), "Claim2", rep("Claim3", 2)),
Origin_year = c(rep(2010, 4), rep(2012, 2)),
Calendar_year = c(2010:2012, 2012, 2012, 2014),
Dev_year_since_large = c(0, 1, 2, 1, 1, 2),
Cl_payment_cal = rep(1000, 6))
print(claims_data)
#> Claim_id Origin_year Calendar_year Dev_year_since_large Cl_payment_cal
#> 1 Claim1 2010 2010 0 1000
#> 2 Claim1 2010 2011 1 1000
#> 3 Claim1 2010 2012 2 1000
#> 4 Claim2 2010 2012 1 1000
#> 5 Claim3 2012 2012 1 1000
#> 6 Claim3 2012 2014 2 1000
generate_triangle(claims_data, "Cl_payment_cal", 2009, 2014)
#> Calendar_year
#> Origin_year 2009 2010 2011 2012 2013 2014
#> 2009 0 0 0 0 0 0
#> 2010 0 0 1000 2000 0 0
#> 2011 0 0 0 0 0 0
#> 2012 0 0 0 1000 0 1000
#> 2013 0 0 0 0 0 0
#> 2014 0 0 0 0 0 0