Skip to contents

Refit a GLM on repeated bootstrap samples of the estimation portfolio and retain the coefficient estimates from every successful refit. The resulting distribution describes how sensitive individual model coefficients are to sampling variation in the observed portfolio.

Usage

coefficient_stability(
  object,
  n_resamples = 500,
  seed = NULL,
  show_progress = interactive(),
  method = c("bootstrap", "period"),
  data = NULL,
  period = NULL,
  confidence = 0.95
)

Arguments

object

A fitted glm object. Refined GLMs are accepted when their estimation data can be recovered from the model object.

n_resamples

Positive whole number. Number of bootstrap samples. Default is 500.

seed

Optional single numeric seed for reproducible resampling.

show_progress

Logical. If TRUE, display a text progress bar.

method

"bootstrap" (default) or "period" for independent period fits.

data

Optional estimation data for period fits. If omitted, recover the original estimation rows from the model.

period

For period fits, a column of numeric periods, dates or factor levels in their declared chronological order.

confidence

Level of the period-specific Wald intervals, or NULL to omit them.

Value

An object of class "bootstrap_coefficients". It contains the original coefficients, a coefficient matrix with one row per requested resample, indicators for successful model fits, recorded failure messages, and the resampling settings. Use summary.bootstrap_coefficients() for a coefficient-level data frame, autoplot() for an interval plot and as_gt() for a formatted table. With method = "period", a period_coefficients object contains estimates and period-level diagnostics.

Details

Each resample contains the same number of portfolio rows as the original estimation data and is drawn with replacement. The function recovers these data from object; a separate data argument is deliberately not required. Rows omitted during the original model fit are excluded so the resampling population remains aligned with the fitted GLM.

Refits use the original model specification, including its formula, offsets and weights. A bootstrap sample can omit factor levels. If the original reference is absent or the factor contrasts have changed, estimates affected by the change in coding are stored as NA, even when the refit converges. This prevents the summary from mixing estimates of different effects.

A failed or non-converged GLM refit does not stop the procedure. The failed replicate is recorded and the function continues. After resampling, an informative message reports how many requested refits produced usable model objects. summary.bootstrap_coefficients() reports the number of finite, comparable estimates separately for each coefficient. Read the interval alongside this count: a narrow interval based on few estimates is less informative than one based on most of the requested resamples.

Actuarial interpretation

The bootstrap distribution can identify tariff effects that are sensitive to the particular portfolio sample. Wide intervals, material bootstrap bias or a low number of estimable replicates often indicate sparse levels, correlated model terms or limited claim information. These diagnostics should be considered alongside exposure, claim counts, coefficient interpretation and stability across calendar periods.

The row bootstrap represents sampling variation in the observed estimation portfolio. It does not include future trend, parameter uncertainty caused by model selection, structural changes in portfolio composition or dependence between repeated records for the same policy. Where such dependence is material, a cluster-level bootstrap would require a different resampling design that draws whole policies, retaining all their records together. This function does not perform that cluster-level resampling.

Period fits reuse the original coefficient coding and fit each period separately. Effects affected by rank deficiency are NA, rather than changing the reference category. Intervals use period-specific standard errors on the link scale. Period differences reflect sampling variation, portfolio mix and model specification as well as any underlying change.

Author

Martin Haringa

Examples

model <- glm(
  nclaims ~ age_policyholder + zip + offset(log(exposure)),
  family = poisson(),
  data = MTPL
)

if (FALSE) { # \dontrun{
boot <- coefficient_stability(
  model,
  n_resamples = 25,
  seed = 123,
  show_progress = FALSE
)

summary(boot, scale = "link")
summary(boot, scale = "exponentiated")
summary(boot, scale = "relativity")
autoplot(boot, scale = "relativity")

if (requireNamespace("gt", quietly = TRUE)) {
  as_gt(boot, scale = "relativity")
}
} # }