## credibility.buhlmann_straub()


The Bühlmann-Straub credibility model, as R's `actuar::cm(~group)`:


Usage


``` python
credibility.buhlmann_straub(
    ratios,
    weights=None,
    estimator="unbiased",
    tol=1.4901161193847656e-08,
    max_iter=100
)
```


group `i` in period `j` has ratio `X_ij` (loss per unit of exposure) with weight `w_ij`. Without weights it is Bühlmann's model.

The method, its estimators and its reference are documented once, in the Rust reference: https://docs.rs/prospicio-pricing/latest/prospicio_pricing/credibility/struct.BuhlmannStraub.html


## Parameters


`ratios: list of list of float`  
One row per group, one column per period; NaN for a missing cell.

`weights: list of list of float = None`  
The same shape, NaN in the same places; equal weights if omitted.

`estimator: (unbiased, iterative) = ``"unbiased"`  
The between variance: Bühlmann and Straub's unbiased estimator (`actuar`'s `"Buhlmann-Gisler"` and `"Ohlsson"`), or Bichsel and Straub's iterative one.

`tol: float = ``1.49e-8`  
Relative tolerance of the iterative estimator.

`max_iter: int = ``100`  


## Returns


`BuhlmannStraubFit`  


## Raises


`ValueError`  
For fewer than two groups, too few observations, mismatched shapes or missing cells, or missing ratios without weights.


## Examples

``` python
>>> from prospicio.credibility import buhlmann_straub
>>> fit = buhlmann_straub([[1.0, 2.0, 3.0], [4.0, 5.0, 9.0]])
>>> fit.within_variance
```

4.0
