## methods.cape_cod()


Cape Cod: Bornhuetter-Ferguson with the loss ratio estimated from the triangle.


Usage

``` python
methods.cape_cod(
    cells,
    *,
    premium,
    decay=1.0,
    trend=0.0,
    n_iters=1,
    dev_grain_months=12,
    average="volume",
    history_periods=None,
    drop_high=False,
    drop_low=False,
    preserve=1,
    drop_above=None,
    drop_below=None,
    exclude=(),
    exclude_valuations=(),
    trim_ties="volume",
    unsupported_factor="raise",
    exhausted_exclusions="keep",
    zero_cells="missing",
    tail=None,
    tail_factor=None,
    tail_decay=None,
    tail_attach_lag=None,
    tail_fit_lags=None,
    tail_steps=None,
    tail_rows=None
)
```


This is Gluck's generalized Cape Cod. Each origin's expected loss ratio is a weighted ratio of reported losses to "used-up" premium (premium times `pct_reported`) over all origins, where an origin `k` periods away is weighted by `decay ** k`. `decay=1` (the default) weights every origin equally, which is the classic Cape Cod and one loss ratio for the whole triangle; `decay=0` uses each origin's own experience only, which is the chain ladder.

`trend` is an annual rate, such as 0.05 for 5% a year (0, the default, compares amounts as they are). Each origin's losses are first brought to the valuation date's level, multiplied by `trend_factor = (1 + trend) ** (m / 12)`, where `m` is the whole months from the end of the origin period to [as_of](Triangle.as_of.md#ibnr.Triangle.as_of). The weighted ratio of those to used-up premium is the `trended_loss_ratio`, the loss ratio at the valuation date's level (chainladder-python's `apriori_`). Each origin's `expected_loss_ratio`, applied to its own premium, is that divided by its own `trend_factor` (chainladder-python's `detrended_apriori_`). With `decay=1` the trended loss ratio is one number for the whole triangle; with `decay=0` the trend cancels and the answer is the chain ladder's.

`n_iters` iterates the result as [benktander()](methods.benktander.md#ibnr.methods.benktander) does, with each origin's `premium * expected_loss_ratio` as the first a priori ultimate; 1 (the default) is Cape Cod itself, and 0 and counts above 10,000 are refused.

`cells`, the development options and the tail options are as in [chain_ladder()](methods.chain_ladder.md#ibnr.methods.chain_ladder) (with a tail, the used-up premium includes it), and `premium` as in [bornhuetter_ferguson()](methods.bornhuetter_ferguson.md#ibnr.methods.bornhuetter_ferguson). The loss ratios are in `origins.expected_loss_ratio` and `origins.trended_loss_ratio`, and `origins.trend_factor` is each origin's factor (1.0 at trend 0).
