Skip to contents

The triangle with the development ages up to age months, as chainladder-python's tri[tri.development <= age]. Every age at or before age is kept, in every segment, measure and origin; the later ages are left out, not folded into a tail. age need not be one of the triangle's ages, and one at or past the last age returns the triangle unchanged. The origins, measures (a premium column among them), grains and basis (cumulative or incremental) are kept; the valuation becomes the latest valuation of a kept observed cell. An origin observed only at dropped ages keeps an empty row, which the fits trim when it is the first or the last origin and refuse between observed origins. On a cumulative triangle where every origin keeps an observed cell, the result equals triangle() on the rows of as.data.frame(x) at the kept ages (an origin left without cells is not in those rows); on an incremental one that rebuild brings the dropped ages back as zero increments, and this function does not.

Usage

max_age(x, age)

Arguments

x

A triangle.

age

The last age to keep, in months: one whole number, at or past the triangle's first age (an earlier one keeps nothing and is an error).

Value

A triangle.

Examples

long <- data.frame(
  year = c(2020, 2020, 2020, 2021, 2021, 2022),
  age = c(12, 24, 36, 12, 24, 12),
  paid = c(100, 150, 145, 110, 170, 120)
)
tri <- triangle(long, "year", "age", "paid")
max_age(tri, 24)@development
#> [1] 12 24
max_age(tri, 24)@values[1, 1, , ]
#>       development
#> origin  12  24
#>   2020 100 150
#>   2021 110 170
#>   2022 120  NA