Skip to contents

fit_curves() is the table behind a chart of every fit against the data on a log axis. The losses at or above threshold are sorted ascending; empirical is the plotting position (n - i + 0.5) / n of the i-th of the n (1 the smallest), never 0 at the largest as the product-limit estimate is. Each family is fitted to those losses, each reported above threshold (the Pareto families from it, as severity_fit() with t), and its survival conditional on the threshold, S(x) / S(threshold), is a column, the columns in AIC order, lowest first; a family that fails to fit is left out. More than points losses are thinned to the rows unique(round(seq(0, n - 1, length.out = points))) as numpy computes them (halves rounded to even, as R's round() does too), keeping the smallest and largest; the plotting positions still count all n.

Usage

fit_curves(losses, threshold, families = NULL, points = 200)

Arguments

losses

Numeric vector; losses below threshold are dropped.

threshold

The reporting threshold of every loss, and the Pareto families' t.

families

Character vector of family names as for severity_fit(); NULL (default) for all nine: lognormal, gamma, weibull, loglogistic, exponential, burr, lomax, pareto, gen_pareto.

points

The most rows, at least 2 (default 200).

Value

A data frame with loss, empirical, then one column per family in AIC order, named by the family.

Examples

y <- c(1500, 2500, 4000, 10000, 1200, 3100, 800)
fit_curves(y, 1000, c("lognormal", "pareto"))
#>    loss  empirical    pareto  lognormal
#> 1  1200 0.91666667 0.8411622 0.91726666
#> 2  1500 0.75000000 0.6806753 0.80375311
#> 3  2500 0.58333333 0.4192463 0.52291209
#> 4  3100 0.41666667 0.3418526 0.41097856
#> 5  4000 0.25000000 0.2684219 0.29374870
#> 6 10000 0.08333333 0.1125349 0.05365798