## Estimate age-to-age factors

### Description

Basic chain-ladder function to estimate age-to-age factors for a given cumulative run-off triangle. This function is used by Mack- and MunichChainLadder.

### Usage

```chainladder(Triangle, weights = 1, delta = 1)
```

### Arguments

 `Triangle` cumulative claims triangle. A (mxn)-matrix C_{ik} which is filled for k ≤q n+1-i; i=1,…,m; m≥q n , see `qpaid` for how to use (mxn)-development triangles with m

### Details

The key idea is to see the chain-ladder algorithm as a special form of a weighted linear regression through the origin, applied to each development period.

Suppose `y` is the vector of cumulative claims at development period `i+1`, and `x` at development period `i`, `weights` are weighting factors and `F` the individual age-to-age factors `F=y/x`. Then we get the various age-to-age factors:

• Basic (unweighted) linear regression through the origin: `lm(y~x + 0)`

• Basic weighted linear regression through the origin: `lm(y~x + 0, weights=weights)`

• Volume weighted chain-ladder age-to-age factors: `lm(y~x + 0, weights=1/x)`

• Simple average of age-to-age factors: `lm(y~x + 0, weights=1/x^2)`

Barnett & Zehnwirth (2000) use delta = 0, 1, 2 to distinguish between the above three different regression approaches: `lm(y~x + 0, weights=weights/x^delta)`.

Thomas Mack uses the notation `alpha = 2 - delta` to achieve the same result: `sum(weights*x^alpha*F)/sum(weights*x^alpha) # Mack (1999) notation`

### Value

chainladder returns a list with the following elements:

 `Models` linear regression models for each development period `Triangle` input triangle of cumulative claims `weights` weights used `delta` deltas used

### Author(s)

Markus Gesmann <markus.gesmann@gmail.com>

### References

Thomas Mack. The standard error of chain ladder reserve estimates: Recursive calculation and inclusion of a tail factor. Astin Bulletin. Vol. 29. No 2. 1999. pp.361:366

G. Barnett and B. Zehnwirth. Best Estimates for Reserves. Proceedings of the CAS. Volume LXXXVII. Number 167. November 2000.

See also `ata`, `predict.ChainLadder` `MackChainLadder`,

### Examples

```## Concept of different chain-ladder age-to-age factors.
## Compare Mack's and Barnett & Zehnwirth's papers.
x <- RAA[1:9,1]
y <- RAA[1:9,2]

F <- y/x
## wtd. average chain-ladder age-to-age factors
alpha <- 1 ## Mack notation
delta <- 2 - alpha ## Barnett & Zehnwirth notation

sum(x^alpha*F)/sum(x^alpha)
lm(y~x + 0 ,weights=1/x^delta)

## straight average age-to-age factors
alpha <- 0
delta <- 2 - alpha
sum(x^alpha*F)/sum(x^alpha)
lm(y~x + 0, weights=1/x^(2-alpha))

## ordinary regression age-to-age factors
alpha=2
delta <- 2-alpha
sum(x^alpha*F)/sum(x^alpha)
lm(y~x + 0, weights=1/x^delta)

## Compare different models
## age-to-age factors
sapply(CL0\$Models, function(x) summary(x)\$coef["x","Estimate"])
## f.se
sapply(CL0\$Models, function(x) summary(x)\$coef["x","Std. Error"])
## sigma
sapply(CL0\$Models, function(x) summary(x)\$sigma)
predict(CL0)

## age-to-age factors
sapply(CL1\$Models, function(x) summary(x)\$coef["x","Estimate"])
## f.se
sapply(CL1\$Models, function(x) summary(x)\$coef["x","Std. Error"])
## sigma
sapply(CL1\$Models, function(x) summary(x)\$sigma)
predict(CL1)

## age-to-age factors
sapply(CL2\$Models, function(x) summary(x)\$coef["x","Estimate"])
## f.se
sapply(CL2\$Models, function(x) summary(x)\$coef["x","Std. Error"])
## sigma
sapply(CL2\$Models, function(x) summary(x)\$sigma)
predict(CL2)

## Set 'weights' parameter to use only the last 5 diagonals,
## i.e. the last 5 calendar years
calPeriods <- (row(RAA) + col(RAA) - 1)
(weights <- ifelse(calPeriods <= 5, 0, ifelse(calPeriods > 10, NA, 1)))