Skip to contents

recommend_portfolio_grid() sizes one grid for the sum of independent compound units, as aggregate sizes a Portfolio: recommend_grid()'s steps on the total, the single big jump taken on whichever unit needs the most room.

Usage

audit_grid(
  frequency,
  severity,
  step = NULL,
  log2 = NULL,
  eps = 1e-04,
  power = 2,
  good_enough = 0.5,
  max_doublings = 4,
  log2_cap = 20,
  log2_floor = 8
)

validate_grid(frequency, severity, step, points, eps = 1e-04)

dyadic_lattice_step(atoms, depth = 16)

lattice_candidates(h)

lattice_bucket(atoms, extent, log2)

audit_portfolio_grid(
  units,
  step = NULL,
  log2 = NULL,
  eps = 1e-04,
  power = 2,
  good_enough = 0.5,
  max_doublings = 4,
  log2_cap = 20,
  log2_floor = 8
)

recommend_portfolio_grid(units, log2 = 16, p = 1 - 1e-05, p_star = 1 - 1e-12)

Arguments

frequency

A claim count.

severity

Any severity but a sampled distribution.

step

The center's step; by default recommend_grid()'s (or recommend_portfolio_grid()'s) at log2.

log2

The center's 2^log2 points (16 by default); with no step, the most points the recommended grid may use.

eps

The validation tolerance.

power

The power mean of the terms.

good_enough

The target score.

max_doublings

Steps doubled or halved at most this many times each way.

log2_cap

log2 never grows past it.

log2_floor

The half-size row is tried only above it.

points

The number of points of the grid validate_grid() checks.

atoms

A discrete severity's values.

depth

Binary levels searched below the largest atom.

h

A lattice step.

extent

The span the grid must cover.

units

A list of units, each list(frequency, severity).

p, p_star

As recommend_grid().

Value

recommend_portfolio_grid(): a list as recommend_grid()'s. audit_grid() and audit_portfolio_grid(): a list with cells (a data frame, the center first: d_step and d_log2, the moves from the center in doublings, step, log2, score, the six terms severity_mean to aggregate_skew (NaN when skipped), tail_mass, aliasing_error, defective, selected, note), selected (the chosen row), step, log2 and score of the chosen cell, probed (FALSE when the center met the target), grew and reason. validate_grid(): a list with passes, flags (the failures by aggregate's names), description, terms (the six, NaN when skipped), convolution_residual and tail_mass.

Details

audit_grid() audits a grid as aggregate 1.2.0's sharpen does. It builds the compound distribution at the center and, unless that meets the target, at doubled and halved steps on the same and half the points, until the score stops improving. Each cell is scored by six moment errors (the severity's and the aggregate's mean, cv and skewness against their exact values, divided by eps, 10 eps and 100 eps) combined by a power mean, so a score of 1 is aggregate's validation boundary. The best sound cell (one that loses no mass off the grid) is chosen, preferring fewer points; twice the points is tried only when nothing smaller meets the target. audit_portfolio_grid() does the same for a sum of units: the severity terms score the claim-weighted mixture of the units' severities, the aggregate terms the total.

validate_grid() is the verdict on one grid, aggregate 2.1.0's valid: the six terms above 1 fail as SEV_MEAN to AGG_SKEW, ALIASING when the aggregate's mean differs from E[N] times the discretized severity's by more than 1e-5 with no mass beyond the grid, and DEFECTIVE when more than 1e-4 lies beyond it. A pass says the grid is "not unreasonable".

dyadic_lattice_step(), lattice_candidates() and lattice_bucket() are aggregate 2.1.0's lattice rule for a discrete severity: the dyadic step the atoms lie on (c(step, residual), NULL without one), the buckets tried for it (the largest nice one dividing it, then the step), and the first that holds extent within 2^log2 points, or a coarser bucket with a warning naming the log2_required.

Examples

a <- audit_grid(poisson_count(50), gamma_distribution(4, 2.5), step = 0.5, log2 = 10)
c(a$step, a$log2)
#> [1]  1 11
a$reason
#> [1] "no cell meets the target, so the best was taken; audit again from it to go on"
validate_grid(poisson_count(50), gamma_distribution(4, 2.5), 0.25, 2^10)$flags
#> [1] "AGG_MEAN"  "AGG_CV"    "AGG_SKEW"  "DEFECTIVE"
dyadic_lattice_step(c(3, 6, 9))
#>     step residual 
#>        3        0 
lattice_bucket(c(1000, 3000, 7000), 300000, 8)$warning
#> [1] "the severity atoms are on the lattice of step 1000 and the grid needs log2 >= 9 at bs 1000; log2 8 was given, so bs 2000 is used and the atoms do not sit on the grid"
units <- list(list(poisson_count(10), gamma_distribution(2, 50)),
              list(poisson_count(2), gamma_distribution(0.5, 1000)))
recommend_portfolio_grid(units, log2 = 12)$points
#> [1] 4096
audit_portfolio_grid(units, log2 = 12)$score
#> [1] 0.2894893