Skip to content

insurancerating 0.8.2

Latest

Choose a tag to compare

@MHaringa MHaringa released this 01 Sep 13:46

Changes since 0.8.1

  • rating_table() gains estimate_name for assigning exact names to fitted
    coefficient or relativity columns. It accepts one name for one model, a
    vector in model order, or a named vector for multi-model comparisons;
    autoplot() and as_gt() retain the custom columns.
  • edit_smoothing() gains slope_adjustment, using from as its anchor, for
    changing the remaining development of an effective smoothing after a selected
    anchor. Values before the anchor remain unchanged and the edited curve is
    continuous at the anchor. The default slope_adjustment = 1 leaves the
    smoothing unchanged.
  • calibrate_model() adds a final multiplicative calibration step for refined
    log-link GLMs. It changes only the overall fitted level, records the applied
    factor and intercept shift, and remains compatible with rating_table() and
    add_prediction().
  • add_restriction() now warns when a newly added numeric interval overlaps
    the existing interval classification. The message identifies the conflicting
    levels and explains how a separate replacement variable can be supplied with
    replaces when the intention is to replace the original classification.
  • autoplot.rating_refinement() gains show_segments = FALSE for inspecting
    a continuous smoothing curve without displaying the proposed tariff
    segments.
  • premium_change() interprets the effective smoothing in a refinement using
    either the existing doubling comparison or a fixed increment supplied with
    increment. Current and historical refinement states can be selected with
    steps and compared with print and as_gt() methods. The default
    basis = "curve" evaluates the continuous effective smoothing;
    basis = "segments" compares the implemented tariff-interval relativities.
  • add_restriction() gains replaces, which allows a new fixed tariff factor
    to explicitly replace an existing standalone model term during refit().
    The replacement is retained in refinement summaries and audits. The default
    replaces = NULL preserves the existing additive behaviour for new factors.
  • rating_grid_db() and merge_date_ranges_db() add lazy database variants
    for portfolios that should be reduced before they are imported into R.
    rating_grid_db() translates grouped counts and sums through dbplyr, while
    merge_date_ranges_db() implements temporal gaps-and-islands reduction in
    DuckDB. A new large-portfolio vignette compares local and database workflows
    and illustrates lazy reduction of portfolios with 10 and 50 million records.
  • rating_grid() and merge_date_ranges() are now documented together as
    portfolio-reduction functions. Both use grouped data.table operations
    internally and return ordinary data.frame objects for downstream use.
  • split_periods_to_months() and active_rows_by_date() are now documented as
    portfolio time operations. Their calculations use local data.table objects
    internally, while their public output is always a regular data.frame.
    split_periods_to_months() now uses data as its first argument (df remains
    available as a deprecated named argument) and expands periods without a
    row-wise R loop. active_rows_by_date() replaces the technical nomatch and
    mult arguments with unmatched and multiple_matches; the old names remain
    available with deprecation warnings.
  • merge_date_ranges() now uses merge_gap_days = 1 by default, so only
    overlapping and directly adjacent coverage periods are merged unless a wider
    administrative gap is selected explicitly. The interval reduction is now
    performed as a grouped data.table calculation, avoiding row-wise R loops
    for large portfolios. Empty inputs, nested intervals and aggregation
    functions without a na.rm argument are handled explicitly. The deprecated
    reduce() wrapper retains its historical default for compatibility. The
    first argument is now named data (df remains available as a deprecated
    named argument), and the result is a regular data.frame subclass while
    data.table remains an internal implementation detail. Together with
    rating_grid(), the function is documented as part of the portfolio
    reduction workflow.
  • rating_table() now distinguishes structural and comparative level order.
    Pure numeric levels and numeric intervals are ordered from low to high,
    explicitly ordered factors retain their declared level sequence, and nominal
    factors are ordered from the highest to the lowest fitted effect by default.
    Numeric and ordinal order are not displaced by the fitted reference level.
    The new level_order_by_risk_factor argument can preserve model order or
    select alphabetical or estimate-based ordering for individual factors.
    Risk factors can retain formula order or be sorted alphabetically, and
    comparisons with several models can select the model that determines the
    estimate ordering. The resulting order is retained by as_gt() and
    autoplot().
  • add_rebasing() can rescale the current relativities of a categorical tariff
    factor so that an explicit reference level equals 1. When no level is
    supplied, the level with the largest portfolio weight is selected. Rebasing
    preserves every ratio between factor levels and can be applied after
    restrictions, shrinkage or sublevel relativities.
  • add_shrinkage() can reduce differences between categorical tariff
    relativities before refitting. Relativities are blended with a weighted
    centre on the log scale and rescaled to preserve their weighted arithmetic
    mean. Explicit GLM weights or a simple exposure offset are detected when
    possible; a column name or weights = "equal" can be supplied directly.
    The selected credibility, weighting basis and before/after relativities are
    retained in the ordered refinement specification.
  • audit_refinement() now provides a reproducible comparison between the
    unrestricted and refined GLM on common observed model points. It records the
    package version, formulas and ordered refinement steps, and reports the
    portfolio and exposure-weighted level effects before and after refinement.
    summary() on a pre-refit rating_refinement object now gives a structured
    review of the proposed specification, while as_gt() formats the fitted
    audit for reporting.
  • bootstrap_coefficients() now assesses GLM coefficient stability by
    resampling the estimation portfolio rows and refitting the model. Individual
    failed fits are retained as missing replicates instead of stopping the full
    run. summary() reports link-scale or exponentiated results, with
    "relativity" available as an alias, and as_gt() provides a formatted
    coefficient table.
  • The function documentation, README and vignettes now use a consistent,
    practical actuarial style. The documentation distinguishes observed portfolio
    experience, fitted model effects, explicit tariff assumptions and model
    diagnostics, and states relevant interpretation limits more clearly.
    Experimental documentation badges have been removed, and the low-level
    rmse() helper is listed with the package utilities in the reference index.
  • add_smoothing() keeps "spline" as its general-purpose default and fits it
    as an unconstrained penalized cubic regression spline. Polynomial smoothing
    is selected explicitly with "poly", while "gam" provides a thin-plate GAM
    comparison. degree is limited to polynomial fits, k is limited to spline
    methods, and an omitted k is adapted to the available grouped model points.
    Its arguments now follow the modelling sequence of variables, required
    breaks, smoothing method, complexity and weights. Shape-constrained methods
    now use readable values such as "increasing", "decreasing",
    "increasing_convex" and "increasing_concave"; the former short SCOP codes
    remain accepted as compatibility aliases. add_smoothing() now focuses only
    on the initial smoothing and its structural shape. The former global
    strength adjustment has been removed. edit_smoothing() now supports
    a multiplicative local adjustment, such as 1.05 for an increase of up to
    5 percent, together with continuous inherited or linear transitions and an
    explicit discontinuous "step" transition. Relative adjustments are
    anchored to the unchanged smoothing at both interval boundaries and remain
    separate from explicit target-value edits. Each edit_smoothing() call is
    stored as a separate cumulative refinement step. In
    addition, edit_smoothing() now supports slope_adjustment, with from as
    its anchor. This leaves the curve unchanged through the anchor
    and scales only its remaining change, allowing a continuous effect to become
    steeper or flatter above a selected source-variable value.
    In
    autoplot.rating_refinement(), step selects the cumulative smoothing state
    and show_initial_smoothing = TRUE overlays the original add_smoothing()
    curve for comparison.
  • add_restriction() recognises a split variable created by an earlier
    add_relativities() step without requiring
    allow_new_risk_factors = TRUE. A partial restriction changes the supplied
    levels and fixes all remaining levels at their current derived relativities.
  • add_relativities() now validates sublevels against the observed
    split_variable and parent categories against model_variable before
    storing a refinement step. Closely matching observed values are suggested
    for likely spelling or spacing errors. The resulting hybrid tariff factor is
    now named with output_variable; its default is the model variable followed
    by _refined, while application-specific names such as
    sbi_tariff_segment can be supplied explicitly.
  • split_level() and relativities() are now the primary helpers for defining
    named sublevel splits and share one reference page describing their combined
    use. The low-level split_relativities() constructor is deprecated because
    it does not record the parent model level required by add_relativities().
  • Spline, GAM and shape-constrained smoothing validate the requested basis
    dimension against the number of unique grouped covariate values before model
    fitting.
  • autoplot.rating_table() and autoplot.factor_analysis() abbreviate long
    risk-factor level labels by default. Shortened labels use one terminal period,
    can be disabled, and can be replaced by explicitly supplied display labels.
    Both methods now also provide legend_position for consistent legend
    placement.
  • autoplot.riskfactor_gam() and autoplot.tariff_segments() now use one
    shared plotting implementation and are documented on one reference page.
    Segment plots retain their boundaries by default and can show the underlying
    GAM curve alone with show_segments = FALSE.
  • derive_tariff_segments() now uses segmentation_penalty as its primary
    split-control argument; complexity remains available as a deprecated alias.
    The method divides the fitted GAM curve without applying a second exposure or
    claim-volume weight; these quantities have already informed the GAM estimate
    and remain available through summary() as diagnostics. Validation now
    covers malformed GAM objects, non-finite values and whole-number search
    controls. Tree splits are read from the fitted tree structure rather than
    parsed from printed rules.
    add_tariff_segments() reapplies stored boundaries to the continuous risk
    factor, so filtering or reordering rows no longer misaligns assignments and
    unsupported values outside the fitted range fail explicitly.