Product-limit estimate and goodness of fit for large losses
product_limit.Rdproduct_limit() is the Kaplan-Meier estimator for left-truncated,
right-censored losses: at each value x where an uncensored loss lies,
the weight at risk (losses reported below x and not below it), the
uncensored weight there, and the survival conditional on the lowest
reporting threshold, prod(1 - events / at_risk).
Usage
product_limit(
losses,
reporting_thresholds = NULL,
censored = NULL,
weights = NULL
)
goodness_of_fit(
severity,
losses,
reporting_thresholds = NULL,
censored = NULL,
weights = NULL,
truncated_above = NULL
)Arguments
- losses
Numeric vector of losses at or above
t(t[1]).- reporting_thresholds
Per-loss reporting thresholds, or
NULL.- censored
Logical vector,
TRUEwhere a loss was capped, orNULL.- weights
Per-loss weights, or
NULL.- severity
A fitted or any other severity.
- truncated_above
Per-loss bounds from above, or
NULL: a loss is conditioned on not exceeding its bound (a study of claims up to 50,000);Infmeans none.
Value
product_limit(): a data frame with x, at_risk, events,
survival. goodness_of_fit(): a list with a data frame table (x,
at_risk, survival, model_survival, model_quantile),
max_distance, ks_p_value, tail_mean and tail_cv.
Details
goodness_of_fit() compares a severity with that estimate: P-P
(survival against model_survival, the model's survival conditional on
the lowest reporting threshold), Q-Q (x against model_quantile, the
model's conditional quantile at the middle of each step) and
max_distance, the largest gap between the two survival functions. With
a bound from above common to every loss (truncated_above), both sides
are conditioned on it too; bounds that differ are refused.
ks_p_value is the classical two-sided Kolmogorov-Smirnov p-value of
max_distance among the losses (SciPy's kstwo; with one threshold and
no censoring, ks.test()'s exact p-value). It is optimistic for a fitted
severity: the parameters were chosen to bring the curve close to these
losses, so the true p-value is smaller. tail_mean and tail_cv are the
mean and coefficient of variation of X | X > t, t the lowest
reporting threshold, Inf where the moment diverges.
Examples
product_limit(c(100, 200, 300, 400))
#> x at_risk events survival
#> 1 100 4 1 0.75
#> 2 200 3 1 0.50
#> 3 300 2 1 0.25
#> 4 400 1 1 0.00
y <- c(120, 300, 450, 800, 1500, 2600)
goodness_of_fit(severity_fit("lognormal", y)$distribution, y)$max_distance
#> [1] 0.1456557