## reserving.ExcessPattern


A layer's development pattern derived from the ground-up triangle:


Usage

``` python
reserving.ExcessPattern()
```


the layer's age-to-age factors, its factors to ultimate and its tail, from the ground-up incurred factors and a severity by maturity (Bloom and Patrik, CAS E-Forum Fall 2013; Sahasrabuddhe, E-Forum Fall 2010; Pinto and Gogol, PCAS 74 (1987)). Build one with [ExcessPattern.from_ground_up](reserving.ExcessPattern.md#prospicio.reserving.ExcessPattern.from_ground_up).

The pattern goes into [ChainLadder](reserving.ChainLadder.md#prospicio.reserving.ChainLadder), [Mack](reserving.Mack.md#prospicio.reserving.Mack) and the expected-loss methods of a *layer* triangle through [selected](aggregate.GridAudit.md#prospicio.aggregate.GridAudit.selected), which gives their [ldf](reserving.Mack.md#prospicio.reserving.Mack.ldf), [ldf_kind](reserving.Mack.md#prospicio.reserving.Mack.ldf_kind) and [ldf_weight](reserving.Mack.md#prospicio.reserving.Mack.ldf_weight) arguments, and [tail](reserving.Mack.md#prospicio.reserving.Mack.tail): `ChainLadder(tail=p.tail, **p.selected(weight))`.


## Examples

Bloom and Patrik's four claims (100, 375, 250 and 500 at 12 months) developing 3.60 and 1.25 to ultimate, in the layer excess of 350.

``` python
>>> from prospicio.distributions import Grid
>>> from prospicio.reserving import ExcessLayer, ExcessPattern, ScaleShift, Triangle
>>> tri = Triangle.from_long(
...     [2020, 2020, 2020], [12, 24, 36],
...     {"incurred": [1225.0, 4410.0, 5512.5]},
... )
>>> probs = [0.0] * 21
>>> for j in (4, 15, 10, 20):
...     probs[j] = 0.25
>>> ultimate = Grid(112.5, probs)
>>> p = ExcessPattern.from_ground_up(
...     tri, "incurred", ExcessLayer(350.0), ScaleShift(ultimate)
... )
>>> round(p.layer_ldf[0], 6), round(p.layer_cdf[0], 6)
```

(17.2, 23.5)


## Attributes

| Name | Description |
|----|----|
| [ages](#ages) | Development ages (months) of the ground-up triangle. |
| [ground_up_ldf](#ground_up_ldf) | The ground-up age-to-age factors the pattern was derived from. |
| [ground_up_tail](#ground_up_tail) | The ground-up factor from the oldest age to ultimate. |
| [layer_cdf](#layer_cdf) | The layer's factors from each age to ultimate, with the tail. |
| [layer_ldf](#layer_ldf) | The layer's age-to-age factors, one fewer than the ages. |
| [ldf](#ldf) | The layer's age-to-age factors as a dict from age in months, the |
| [shifts](#shifts) | The scale shift of each age, the last for the tail; empty under a |
| [tail](#tail) | The layer's factor from the oldest age to ultimate (1 without a |

------------------------------------------------------------------------


#### ages


Development ages (months) of the ground-up triangle.


`ages: list[int]`


------------------------------------------------------------------------


#### ground_up_ldf


The ground-up age-to-age factors the pattern was derived from.


`ground_up_ldf: list[float]`


------------------------------------------------------------------------


#### ground_up_tail


The ground-up factor from the oldest age to ultimate.


`ground_up_tail: float`


------------------------------------------------------------------------


#### layer_cdf


The layer's factors from each age to ultimate, with the tail.


`layer_cdf: list[float]`


------------------------------------------------------------------------


#### layer_ldf


The layer's age-to-age factors, one fewer than the ages.


`layer_ldf: list[float]`


------------------------------------------------------------------------


#### ldf


The layer's age-to-age factors as a dict from age in months, the


`ldf: dict`


[ldf](reserving.Mack.md#prospicio.reserving.Mack.ldf) argument of the methods with `ldf_kind="ldf"`.


------------------------------------------------------------------------


#### shifts


The scale shift of each age, the last for the tail; empty under a


`shifts: list[float]`


[ParetoShape](reserving.ParetoShape.md#prospicio.reserving.ParetoShape).


------------------------------------------------------------------------


#### tail


The layer's factor from the oldest age to ultimate (1 without a


`tail: float`


ground-up tail under a scale shift). Pass it as the [tail](reserving.Mack.md#prospicio.reserving.Mack.tail) of the layer's chain ladder.


## Methods

| Name | Description |
|----|----|
| [credibility_weights()](#credibility_weights) | The weight on the derived pattern at each age, `1 - z` with |
| [from_ground_up()](#from_ground_up) | The layer pattern from the ground-up incurred column, an optional |
| [selected()](#selected) | The derived pattern as the arguments of the chain ladder, Mack and |

------------------------------------------------------------------------


#### credibility_weights()


The weight on the derived pattern at each age, `1 - z` with


Usage

``` python
credibility_weights(layer_triangle, column, k, max_influence, counts=None)
```


`z = n / (n + k)`, [n](pricing.TrendFit.md#prospicio.pricing.TrendFit.n) the layer triangle's claim count (or its origins with a positive earlier value without counts) at the earlier age and [k](models.TargetEncoding.md#prospicio.models.TargetEncoding.k) the credibility constant, capped so that removing any one origin moves the blended factor by at most `max_influence` of it. Where the layer's own factor cannot be estimated the weight is 1.


##### Parameters


`layer_triangle: Triangle`  
The layer's own triangle, a single segment on the pattern's ages.

`column: str`  
The layer loss column.

`k: float`  
The credibility constant, positive. No default (design note, decision 19): the simulation study favours about 20.

`max_influence: float`  
The share of the blended factor one origin may move, positive.

`counts: str = None`  
The layer's claim count column on the same origins and ages.


##### Returns


`dict of int to float`  
The weight at each age except the oldest, for [ldf_weight](reserving.Mack.md#prospicio.reserving.Mack.ldf_weight).


------------------------------------------------------------------------


#### from_ground_up()


The layer pattern from the ground-up incurred column, an optional


Usage

``` python
from_ground_up(
    triangle, column, layer, model, counts=None, tail=None, basis="incurred"
)
```


claim count column and the ground-up tail.


##### Parameters


`triangle: Triangle`  
A single-segment triangle holding the ground-up column.

`column: str`  
The ground-up incurred (reported) loss column. Under a [ParetoShape](reserving.ParetoShape.md#prospicio.reserving.ParetoShape) it is the base development the model names (its counts above the threshold, or its base losses).

`layer: ExcessLayer`  
The layer, with positive expected loss at every age in the model.

`model: ScaleShift or ParetoShape`  
How the severity at each maturity relates to the ultimate one.

`counts: str = None`  
A reported claim count column on the same ages. Without it the counts are taken as complete at every age, which mixes frequency development into the severity shift. Not allowed with a [ParetoShape](reserving.ParetoShape.md#prospicio.reserving.ParetoShape).

`tail: float or tail estimator = None`  
The ground-up tail of the chain ladder: it fixes one more shift for the oldest age and the layer's tail. No tail by default.

`basis: incurred = ``"incurred"`  
The loss basis of the column. Only `"incurred"` is derived; `"paid"` is an error (design note, decision 9).


##### Returns


`ExcessPattern`  


------------------------------------------------------------------------


#### selected()


The derived pattern as the arguments of the chain ladder, Mack and


Usage

``` python
selected(weight=None)
```


the expected-loss methods.


##### Parameters


`weight: float or dict = ``1.0`  
The weight on the derived factors, a number or a dict from age in months to a number ([credibility_weights](reserving.ExcessPattern.md#prospicio.reserving.ExcessPattern.credibility_weights) gives one); the rest goes to the factors estimated from the layer triangle. Weight 1 selects the derived factors alone, which a sparse layer triangle needs.


##### Returns


`dict`  
[ldf](reserving.Mack.md#prospicio.reserving.Mack.ldf), [ldf_kind](reserving.Mack.md#prospicio.reserving.Mack.ldf_kind) and [ldf_weight](reserving.Mack.md#prospicio.reserving.Mack.ldf_weight), to be passed as keyword arguments. The layer's tail is separate: [tail](reserving.Mack.md#prospicio.reserving.Mack.tail).
