## reserving.ClarkFit


A fitted Clark LDF or Cape Cod model of every segment of a triangle


Usage


``` python
reserving.ClarkFit()
```


column.

Per-origin lists ([origins](reserving.MackFit.md#prospicio.reserving.MackFit.origins), [latest](reserving.MackFit.md#prospicio.reserving.MackFit.latest), [expected_ultimate](reserving.ClarkFit.md#prospicio.reserving.ClarkFit.expected_ultimate), [ultimate](reserving.MackFit.md#prospicio.reserving.MackFit.ultimate), [reserve](reserving.MackFit.md#prospicio.reserving.MackFit.reserve) and the standard errors) run over the origins of each segment in turn, like the rows of [to_frame()](reserving.MackFit.md#prospicio.reserving.MackFit.to_frame). The fitted parameters and the standard errors of the total need a single-segment fit; for several segments use [totals_frame()](reserving.MackFit.md#prospicio.reserving.MackFit.totals_frame) or `segment(...)`. [total_ultimate](reserving.MackFit.md#prospicio.reserving.MackFit.total_ultimate) and [total_reserve](reserving.MackFit.md#prospicio.reserving.MackFit.total_reserve) sum over every segment.


## Examples

``` python
>>> from prospicio.reserving import ClarkLdf, Triangle
>>> rows = [[110.0, 290.0, 370.0, 420.0, 440.0], [95.0, 300.0, 390.0, 425.0],
...         [130.0, 320.0, 410.0], [105.0, 305.0], [120.0]]
>>> tri = Triangle.from_long(
...     [2020 + i for i, row in enumerate(rows) for _ in row],
...     [12 * (d + 1) for row in rows for d in range(len(row))],
...     [v for row in rows for v in row],
... )
>>> fit = ClarkLdf().fit(tri, "values")
>>> len(fit.covariance), fit.elr, fit.growth(float("inf"))
```

(7, None, 1.0)


## Attributes

| Name | Description |
|----|----|
| [chain_ladder](#chain_ladder) | The volume-weighted chain ladder of the same column, with the chain |
| [covariance](#covariance) | Covariance of the parameters: the expected ultimates (LDF) or the |
| [curve](#curve) | The growth curve. |
| [elr](#elr) | Expected loss ratio (Cape Cod), or `None` (LDF). |
| [expected_ultimate](#expected_ultimate) | Expected ultimate per origin, developed to infinity: fitted (LDF) |
| [exposure](#exposure) | Exposure per origin (Cape Cod), or `None` (LDF). |
| [index](#index) | Label of each segment, as [Triangle.index](reserving.Triangle.md#prospicio.reserving.Triangle.index). |
| [keys](#keys) | Names of the triangle's key columns; empty without keys. |
| [latest](#latest) | Latest observed cumulative value per origin. |
| [max_age](#max_age) | Age in months at which development stops; `None` for infinity. |
| [n_observations](#n_observations) | Number of observed incremental values fitted; [scale](reserving.ClarkFit.md#prospicio.reserving.ClarkFit.scale) divides by |
| [omega](#omega) | Fitted shape of the growth curve. |
| [origin_width](#origin_width) | Length of the origin period in months; ages are shifted by half of |
| [origins](#origins) | Origin period of each per-origin value. |
| [parameter_risk](#parameter_risk) | Parameter standard error per origin. |
| [process_risk](#process_risk) | Process standard error per origin. |
| [reserve](#reserve) | Reserve per origin. |
| [scale](#scale) | Over-dispersion `sigma**2`: squared Pearson residuals over the |
| [standard_error](#standard_error) | Standard error per origin: `sqrt(process**2 + parameter**2)`. |
| [theta](#theta) | Fitted scale of the growth curve, in months. |
| [total_parameter_risk](#total_parameter_risk) | Parameter standard error of the total reserve, with the covariance |
| [total_process_risk](#total_process_risk) | Process standard error of the total reserve. |
| [total_reserve](#total_reserve) | Total reserve across segments and origins. |
| [total_standard_error](#total_standard_error) | Standard error of the total reserve. |
| [total_ultimate](#total_ultimate) | Total ultimate across segments and origins. |
| [ultimate](#ultimate) | Ultimate per origin: the latest value plus the reserve. |

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


#### chain_ladder


The volume-weighted chain ladder of the same column, with the chain


`chain_ladder: ChainLadderFit`


ladder's ultimate.


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


#### covariance


Covariance of the parameters: the expected ultimates (LDF) or the


`covariance: list[list[float]]`


expected loss ratio (Cape Cod), then [omega](reserving.ClarkFit.md#prospicio.reserving.ClarkFit.omega) and [theta](reserving.ClarkFit.md#prospicio.reserving.ClarkFit.theta). NaN if the Fisher information is singular.


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


#### curve


The growth curve.


`curve: str`


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


#### elr


Expected loss ratio (Cape Cod), or `None` (LDF).


`elr: float | None`


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


#### expected_ultimate


Expected ultimate per origin, developed to infinity: fitted (LDF)


`expected_ultimate: list[float]`


or `elr * exposure` (Cape Cod).


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


#### exposure


Exposure per origin (Cape Cod), or `None` (LDF).


`exposure: list[float] | None`


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


#### index


Label of each segment, as [Triangle.index](reserving.Triangle.md#prospicio.reserving.Triangle.index).


`index: list[Any]`


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


#### keys


Names of the triangle's key columns; empty without keys.


`keys: list[str]`


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


#### latest


Latest observed cumulative value per origin.


`latest: list[float]`


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


#### max_age


Age in months at which development stops; `None` for infinity.


`max_age: float | None`


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


#### n_observations


Number of observed incremental values fitted; [scale](reserving.ClarkFit.md#prospicio.reserving.ClarkFit.scale) divides by


`n_observations: int`


this less the number of parameters.


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


#### omega


Fitted shape of the growth curve.


`omega: float`


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


#### origin_width


Length of the origin period in months; ages are shifted by half of


`origin_width: float`


it to the average date of loss.


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


#### origins


Origin period of each per-origin value.


`origins: list[str]`


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


#### parameter_risk


Parameter standard error per origin.


`parameter_risk: list[float]`


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


#### process_risk


Process standard error per origin.


`process_risk: list[float]`


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


#### reserve


Reserve per origin.


`reserve: list[float]`


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


#### scale


Over-dispersion `sigma**2`: squared Pearson residuals over the


`scale: float`


observed incremental values less the number of parameters.


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


#### standard_error


Standard error per origin: `sqrt(process**2 + parameter**2)`.


`standard_error: list[float]`


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


#### theta


Fitted scale of the growth curve, in months.


`theta: float`


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


#### total_parameter_risk


Parameter standard error of the total reserve, with the covariance


`total_parameter_risk: float`


between origins.


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


#### total_process_risk


Process standard error of the total reserve.


`total_process_risk: float`


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


#### total_reserve


Total reserve across segments and origins.


`total_reserve: float`


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


#### total_standard_error


Standard error of the total reserve.


`total_standard_error: float`


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


#### total_ultimate


Total ultimate across segments and origins.


`total_ultimate: float`


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


#### ultimate


Ultimate per origin: the latest value plus the reserve.


`ultimate: list[float]`


## Methods

| Name | Description |
|----|----|
| [growth()](#growth) | Share of the expected ultimate developed by a development age. |
| [segment()](#segment) | The fit of one segment, chosen by key values as |
| [to_frame()](#to_frame) | One row per segment and origin: the key columns, `origin`, |
| [totals_frame()](#totals_frame) | One row per segment: the key columns, the segment's total |

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


#### growth()


Share of the expected ultimate developed by a development age.


Usage


``` python
growth(age)
```


##### Parameters


`age: float`  
Development age in months, before the shift to the average date of loss; `inf` gives 1.


##### Returns


`float`  


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


#### segment()


The fit of one segment, chosen by key values as


Usage


``` python
segment(**keys)
```


[ChainLadderFit.segment](reserving.ChainLadderFit.md#prospicio.reserving.ChainLadderFit.segment).


##### Returns


`ClarkFit`  


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


#### to_frame()


One row per segment and origin: the key columns, `origin`,


Usage


``` python
to_frame()
```


[latest](reserving.MackFit.md#prospicio.reserving.MackFit.latest), [ultimate](reserving.MackFit.md#prospicio.reserving.MackFit.ultimate), [reserve](reserving.MackFit.md#prospicio.reserving.MackFit.reserve), (Cape Cod) [exposure](reserving.ClarkFit.md#prospicio.reserving.ClarkFit.exposure), [expected_ultimate](reserving.ClarkFit.md#prospicio.reserving.ClarkFit.expected_ultimate), [process_risk](reserving.MackFit.md#prospicio.reserving.MackFit.process_risk), [parameter_risk](reserving.MackFit.md#prospicio.reserving.MackFit.parameter_risk) and [standard_error](reserving.MackFit.md#prospicio.reserving.MackFit.standard_error). Needs pandas.


##### Returns


`pandas.DataFrame`  


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


#### totals_frame()


One row per segment: the key columns, the segment's total


Usage


``` python
totals_frame()
```


[latest](reserving.MackFit.md#prospicio.reserving.MackFit.latest), [ultimate](reserving.MackFit.md#prospicio.reserving.MackFit.ultimate) and [reserve](reserving.MackFit.md#prospicio.reserving.MackFit.reserve), the [process_risk](reserving.MackFit.md#prospicio.reserving.MackFit.process_risk), [parameter_risk](reserving.MackFit.md#prospicio.reserving.MackFit.parameter_risk) and [standard_error](reserving.MackFit.md#prospicio.reserving.MackFit.standard_error) of its total reserve, and its [omega](reserving.ClarkFit.md#prospicio.reserving.ClarkFit.omega), [theta](reserving.ClarkFit.md#prospicio.reserving.ClarkFit.theta), [scale](reserving.ClarkFit.md#prospicio.reserving.ClarkFit.scale) and (Cape Cod) [elr](reserving.ClarkFit.md#prospicio.reserving.ClarkFit.elr). Needs pandas.


##### Returns


`pandas.DataFrame`
