## reserving.ApcGlmFit


A fitted APC GLM, from [ApcGlm.fit](reserving.ApcGlm.md#prospicio.reserving.ApcGlm.fit).


Usage

``` python
reserving.ApcGlmFit()
```


Each effect's periods are indexed from 0; the second difference at `l` (`l = 2..k - 1`) is the change in the effect's slope at period `l`.


## Attributes


`effects: str`  
`"APC"`, `"AP"`, `"AC"` or `"PC"`.

`extrapolation: str`  
`"I0"`, `"I1"` or `"I2"`.

`origins: list of str`  
The origin periods; [fitted](models.GlmFit.md#prospicio.models.GlmFit.fitted) and [reserves](reserving.ApcGlmFit.md#prospicio.reserving.ApcGlmFit.reserves) follow them.

`ages: list of int`  
The development ages in months; the columns of [fitted](models.GlmFit.md#prospicio.models.GlmFit.fitted) follow them.

`level: float`  
The log mean of the first origin's first age.

`age_slope: float`  
The step in the log mean from age 0 to age 1, at origin 0.

`accident_slope: float`  
The step in the log mean from accident 0 to accident 1, at age 0.

`age_second_differences: list of float`  
The development effect's second differences, `l = 2..k - 1`; empty without a development effect.

`accident_second_differences: list of float`  
The accident effect's second differences; empty without it.

`calendar_second_differences: list of float`  
The calendar effect's fitted second differences; empty without it.

`future_calendar_second_differences: list of float`  
The two extrapolated calendar second differences, at `l = k` and `l = k + 1` (all later ones are 0); zeros for `"I2"` and without a calendar effect.

`fitted: list of list of float`  
The fitted mean of each observed cell, one row per origin, `None` below the latest diagonal.

`deviance: float`  
The GLM's deviance on the observed cells.

`reserves: list of float`  
The sum of each origin's future means; the first origin's is 0 (no tail past the oldest age).

`total_reserve: float`  

`coefficients: list of float`  
The canonical coefficients, in the order of [names](models.Coding.md#prospicio.models.Coding.names).

`names: list of str`  
[level](reserving.ApcGlmFit.md#prospicio.reserving.ApcGlmFit.level), `slope_age`, `slope_accident`, then `dd_age[l]`, `dd_accident[l]` and `dd_calendar[l]` for the effects in the model.

`covariance: list of list of float`  
The coefficients' covariance, as a list of rows.

`dispersion: float`  
Pearson's dispersion [phi](reserving.PaidIncurredFit.md#prospicio.reserving.PaidIncurredFit.phi).

`future: FutureCells`  
The future cells' means.

`odp_fit: OdpGlmFit`  
The GLM on the canonical design, with [residuals](reserving.OneYearFit.md#prospicio.reserving.OneYearFit.residuals), [predict_distribution](models.GlmFit.md#prospicio.models.GlmFit.predict_distribution) and the rest of `OdpGlmFit`.


## Attributes

| Name | Description |
|----|----|
| [accident_second_differences](#accident_second_differences) | The accident effect's second differences; empty without it. |
| [accident_slope](#accident_slope) | The step in the log mean from accident 0 to accident 1, at age 0. |
| [age_second_differences](#age_second_differences) | The development effect's second differences, `l = 2..k - 1`; empty without it. |
| [age_slope](#age_slope) | The step in the log mean from age 0 to age 1, at origin 0. |
| [ages](#ages) | The development ages in months; the columns of [fitted](models.GlmFit.md#prospicio.models.GlmFit.fitted) follow them. |
| [calendar_second_differences](#calendar_second_differences) | The calendar effect's fitted second differences; empty without it. |
| [coefficients](#coefficients) | The canonical coefficients, in the order of [names](models.Coding.md#prospicio.models.Coding.names). |
| [covariance](#covariance) | The coefficients' covariance, as a list of rows. |
| [deviance](#deviance) | The GLM's deviance on the observed cells. |
| [dispersion](#dispersion) | Pearson's dispersion [phi](reserving.PaidIncurredFit.md#prospicio.reserving.PaidIncurredFit.phi). |
| [effects](#effects) | `"APC"`, `"AP"`, `"AC"` or `"PC"`. |
| [extrapolation](#extrapolation) | `"I0"`, `"I1"` or `"I2"`: the rule used for the future cells. |
| [fitted](#fitted) | The fitted mean of each observed cell, `None` below the latest diagonal. |
| [future](#future) | The future cells' means, as [FutureCells](reserving.FutureCells.md#prospicio.reserving.FutureCells). |
| [future_calendar_second_differences](#future_calendar_second_differences) | The two extrapolated calendar second differences, at `l = k` and `l = k + 1`. |
| [level](#level) | The log mean of the first origin's first age. |
| [names](#names) | The canonical coefficients' names. |
| [odp_fit](#odp_fit) | The GLM on the canonical design, as `OdpGlmFit`: residuals, |
| [origins](#origins) | The origin periods; [fitted](models.GlmFit.md#prospicio.models.GlmFit.fitted) and [reserves](reserving.ApcGlmFit.md#prospicio.reserving.ApcGlmFit.reserves) follow them. |
| [reserves](#reserves) | The sum of each origin's future means; the first origin's is 0. |
| [total_reserve](#total_reserve) | The total reserve. |

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


#### accident_second_differences


The accident effect's second differences; empty without it.


`accident_second_differences: list[float]`


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


#### accident_slope


The step in the log mean from accident 0 to accident 1, at age 0.


`accident_slope: float`


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


#### age_second_differences


The development effect's second differences, `l = 2..k - 1`; empty without it.


`age_second_differences: list[float]`


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


#### age_slope


The step in the log mean from age 0 to age 1, at origin 0.


`age_slope: float`


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


#### ages


The development ages in months; the columns of [fitted](models.GlmFit.md#prospicio.models.GlmFit.fitted) follow them.


`ages: list[int]`


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


#### calendar_second_differences


The calendar effect's fitted second differences; empty without it.


`calendar_second_differences: list[float]`


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


#### coefficients


The canonical coefficients, in the order of [names](models.Coding.md#prospicio.models.Coding.names).


`coefficients: list[float]`


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


#### covariance


The coefficients' covariance, as a list of rows.


`covariance: list[list[float]]`


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


#### deviance


The GLM's deviance on the observed cells.


`deviance: float`


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


#### dispersion


Pearson's dispersion [phi](reserving.PaidIncurredFit.md#prospicio.reserving.PaidIncurredFit.phi).


`dispersion: float`


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


#### effects


`"APC"`, `"AP"`, `"AC"` or `"PC"`.


`effects: str`


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


#### extrapolation


`"I0"`, `"I1"` or `"I2"`: the rule used for the future cells.


`extrapolation: str`


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


#### fitted


The fitted mean of each observed cell, `None` below the latest diagonal.


`fitted: list[list[float | None]]`


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


#### future


The future cells' means, as [FutureCells](reserving.FutureCells.md#prospicio.reserving.FutureCells).


`future: FutureCells`


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


#### future_calendar_second_differences


The two extrapolated calendar second differences, at `l = k` and `l = k + 1`.


`future_calendar_second_differences: list[float]`


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


#### level


The log mean of the first origin's first age.


`level: float`


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


#### names


The canonical coefficients' names.


`names: list[str]`


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


#### odp_fit


The GLM on the canonical design, as `OdpGlmFit`: residuals,


`odp_fit: OdpGlmFit`


[predict_distribution](models.GlmFit.md#prospicio.models.GlmFit.predict_distribution) and the future design.


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


#### origins


The origin periods; [fitted](models.GlmFit.md#prospicio.models.GlmFit.fitted) and [reserves](reserving.ApcGlmFit.md#prospicio.reserving.ApcGlmFit.reserves) follow them.


`origins: list[str]`


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


#### reserves


The sum of each origin's future means; the first origin's is 0.


`reserves: list[float]`


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


#### total_reserve


The total reserve.


`total_reserve: float`


## Methods

| Name | Description |
|----|----|
| [predict_distribution()](#predict_distribution) | Joint draws of the future cells' increments, as |
| [prediction_error()](#prediction_error) | The reserves' prediction error by origin and in total, as |

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


#### predict_distribution()


Joint draws of the future cells' increments, as


Usage

``` python
predict_distribution(n_sims, seed, parameters="mean_preserving")
```


`OdpGlmFit.predict_distribution`: the same draws as `fit.odp_fit.predict_distribution` for the same arguments.


##### Parameters


`n_sims: int`  

`seed: int`  

`parameters: (mean_preserving, normal, fixed) = ``"mean_preserving"`  
How the coefficients are drawn, as `OdpGlmFit`'s.


##### Returns


`PredictiveDistribution`  


##### Raises


`ValueError`  
If [n_sims](esg.Scenarios.md#prospicio.esg.Scenarios.n_sims) is 0 or [parameters](risk.Distortion.md#prospicio.risk.Distortion.parameters) is unknown.


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


#### prediction_error()


The reserves' prediction error by origin and in total, as


Usage

``` python
prediction_error()
```


`OdpGlmFit.prediction_error`: the process error and the parameter error by the delta method. The extrapolated calendar effect is a fixed linear function of the fitted second differences, so its uncertainty is included.


##### Returns


`dict`  
`origin` (the labels, then `"Total"`), [reserve](reserving.MackFit.md#prospicio.reserving.MackFit.reserve), `process_se`, `parameter_se`, `rmsep` and [cv](distributions.Tweedie.md#prospicio.distributions.Tweedie.cv), as lists.
