## reserving.Separation


Taylor's (1977) separation method: increments over a normaliser are


Usage

``` python
reserving.Separation()
```


`r_j * lambda_(i+j)`, development proportions `r_j` (summing to 1) times an index `lambda_h` per calendar period.

`"arithmetic"` solves Taylor's equations on the column and diagonal sums (the marginal equations of a Poisson GLM on development and calendar factors). `"geometric"` is least squares on the logarithms, taken back to amounts by the geometric means; `"geometric_lognormal"` by the lognormal means (a factor `exp(sigma^2 / 2)` on every index, which needs at least 3 origins). The geometric methods need every increment positive. The triangle must be full: as many ages as origins, the origin grain equal to the development grain, no hole.

The indices after the triangle's last calendar period are not fitted: give exactly one of [future_rate](reserving.Separation.md#prospicio.reserving.Separation.future_rate), [future_index](reserving.Separation.md#prospicio.reserving.Separation.future_index) and [trend_periods](reserving.Separation.md#prospicio.reserving.Separation.trend_periods). On a triangle already restated by an economic index ([Indexation.restate](reserving.Indexation.md#prospicio.reserving.Indexation.restate)) the indices measure superimposed inflation.


## Parameters


`kind: (arithmetic, geometric, geometric_lognormal) = ``"arithmetic"`  

`normaliser: list of float`  
`n_i`, one per origin: finite and positive (claim counts, premium, exposure). Without it every origin has 1.

`future_rate: float`  
A constant annual rate from the last fitted index, compounded by months: above -1.

`future_index: CalendarIndex`  
The relative changes of an index from the triangle's last calendar period, read at the last sub-period of each period.

`trend_periods: int`  
The exponential trend of the last [trend_periods](reserving.Separation.md#prospicio.reserving.Separation.trend_periods) fitted indices, continued from the last: at least 2, at most the number of calendar periods.


## Raises


`ValueError`  
For an unknown [kind](pricing.Period.md#prospicio.pricing.Period.kind), or when not exactly one of the three future settings is given.


## Examples

``` python
>>> from prospicio.reserving import Separation, Triangle
>>> # Taylor (1977), Example 1: claims per claim incurred, cumulative.
>>> rows = [[50.4, 78.6, 87.6, 92.4], [58.0, 87.2, 96.9], [59.5, 92.7], [66.2]]
>>> tri = Triangle.from_long(
...     [2001 + i for i, row in enumerate(rows) for _ in row],
...     [12 * (j + 1) for row in rows for j in range(len(row))],
...     {"s": [v for row in rows for v in row]},
... )
>>> fit = Separation(future_rate=0.10).fit(tri, "s")
>>> [round(r, 4) for r in fit.proportions]
```

\[0.5835, 0.2878, 0.0866, 0.0421\]

``` python
>>> round(fit.indices[0], 1)
```

86.4


## Attributes

| Name | Description |
|----|----|
| [future_index](#future_index) | The index the future follows, or `None`. |
| [future_rate](#future_rate) | The annual rate past the last period, or `None`. |
| [kind](#kind) | `"arithmetic"`, `"geometric"` or `"geometric_lognormal"`. |
| [normaliser](#normaliser) | The normaliser `n_i`, or `None` for 1 in every origin. |
| [trend_periods](#trend_periods) | How many fitted indices the future trend uses, or `None`. |

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


#### future_index


The index the future follows, or `None`.


`future_index: CalendarIndex | None`


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


#### future_rate


The annual rate past the last period, or `None`.


`future_rate: float | None`


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


#### kind


`"arithmetic"`, `"geometric"` or `"geometric_lognormal"`.


`kind: str`


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


#### normaliser


The normaliser `n_i`, or `None` for 1 in every origin.


`normaliser: list[float] | None`


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


#### trend_periods


How many fitted indices the future trend uses, or `None`.


`trend_periods: int | None`


## Methods

| Name | Description |
|----|----|
| [fit()](#fit) | Fits [column](models.Design.md#prospicio.models.Design.column) of the triangle. |
| [glm()](#glm) | The Poisson GLM that the arithmetic method is, \`\`s ~ C(development) |

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


#### fit()


Fits [column](models.Design.md#prospicio.models.Design.column) of the triangle.


Usage

``` python
fit(triangle, column, segment=None)
```


##### Parameters


`triangle: Triangle`  

`column: str`  

`segment: dict of str to object = None`  
The key values choosing one segment of a triangle with several (compared as `str()` of each value); a triangle with one needs none.


##### Returns


`SeparationFit`  


##### Raises


`ValueError`  
For an unknown column, a triangle that is not full, a hole, fewer than 2 origins, a normaliser of the wrong length or with a value not finite and positive, a non-positive sum in the recursion, a non-positive increment in a geometric method, fewer than 3 origins for `"geometric_lognormal"`, or a future that cannot be formed (a rate at or below -1, an index that misses a period, a trend over fewer than 2 or more than all periods). Also when [segment](reserving.MackFit.md#prospicio.reserving.MackFit.segment) does not choose exactly one segment.


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


#### glm()


The Poisson GLM that the arithmetic method is, \`\`s ~ C(development)


Usage

``` python
glm(triangle, column)
```


- C(calendar)`on the increments of a single-segment triangle, with the future indices in its future rows. Its future means and reserves equal`fit`'s; its`prediction_error`is the delta method's and`predict_distribution\`\` draws the future cells. The dispersion is Pearson's.

A [future_rate](reserving.Separation.md#prospicio.reserving.Separation.future_rate) or [future_index](reserving.Separation.md#prospicio.reserving.Separation.future_index) is a fixed growth from the last fitted index, so the error covers that index's and takes the growth as given; a [trend_periods](reserving.Separation.md#prospicio.reserving.Separation.trend_periods) future is linear in the fitted calendar effects, so its uncertainty is included.


##### Parameters


`triangle: Triangle`  

`column: str`  


##### Returns


`OdpGlmFit`  


##### Raises


`NotSupportedError`  
For a geometric method (least squares on the logs) and with a normaliser (the variance of `n_i s_ij` is not an over-dispersed Poisson's: divide the triangle by the normaliser and fit it without one).

`ValueError`  
As [fit](risk.Gpd.md#prospicio.risk.Gpd.fit) does, for a triangle with several segments, and when the GLM does not converge (on increments that are not positive).


##### Examples

``` python
>>> from prospicio.reserving import Separation, Triangle
>>> rows = [[50.4, 78.6, 87.6, 92.4], [58.0, 87.2, 96.9], [59.5, 92.7], [66.2]]
>>> tri = Triangle.from_long(
...     [2001 + i for i, row in enumerate(rows) for _ in row],
...     [12 * (j + 1) for row in rows for j in range(len(row))],
...     {"s": [v for row in rows for v in row]},
... )
>>> model = Separation(future_rate=0.10)
>>> glm = model.glm(tri, "s")
>>> abs(glm.total_reserve - model.fit(tri, "s").total_reserve) < 1e-6
```

True
