Skip to contents

goodness_of_fit()'s ks_p_value assumes a distribution fixed in advance, and a fitted one lies closer to its own data, so that p-value is too large. ks_bootstrap() fits family, draws replicates samples from the fit under the same reporting thresholds, bounds from above and policy limits, refits each with the same family (and t), and returns (1 + k) / (B + 1), k the replicates whose distance is at least the data's among the B that refitted. Its Monte Carlo error is about sqrt(p (1 - p) / B).

Usage

ks_bootstrap(
  family,
  losses,
  reporting_thresholds = NULL,
  censored = NULL,
  weights = NULL,
  truncated_above = NULL,
  t = NULL,
  limits = NULL,
  replicates = 999,
  seed = 0
)

Arguments

family

"lognormal", "gamma", "weibull", "loglogistic", "exponential", "burr", "lomax", "pareto" or "gen_pareto".

losses

Numeric vector of losses at or above t (t[1]).

reporting_thresholds

Per-loss reporting thresholds, or NULL.

censored

Logical vector, TRUE where a loss was capped, or NULL.

weights

Whole numbers of losses, each drawn on its own.

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); Inf means none.

t

The threshold of "pareto" and "gen_pareto", required for them; NULL for the others.

limits

Each loss's policy limit: a replicate loss above it is censored there. At least the loss, and equal to it where the loss is censored. NULL: a censored loss's limit is its own value and an uncensored loss has none; give it when uncensored losses had limits too.

replicates

The number of bootstrap samples.

seed

Generator seed: a non-negative whole number below 2^53. Replicate b draws from stream b, so the result does not depend on the number of threads.

Value

A list: max_distance (the fit's), p_value, distances (each refitted replicate's) and failed (replicates whose refit failed, left out).

Examples

y <- c(120, 300, 450, 800, 1500, 2600, 4000, 650, 90, 2100)
ks_bootstrap("exponential", y, replicates = 199, seed = 1)$p_value
#> [1] 0.975