View source: R/model_calibration.R
| calibrate_model | R Documentation |
Adjust the overall prediction level of a fitted model returned by refit()
without re-estimating its relative tariff structure. Calibration is a final
model-level operation: all refinement decisions must be completed before
calling calibrate_model().
calibrate_model(model, factor)
model |
A fitted refined GLM returned by |
factor |
Positive finite numeric scalar. |
For a refined GLM with a log link, calibration adds log(factor) to the
intercept. Consequently, every response-scale prediction is multiplied by
factor, while all non-intercept coefficients and tariff relativities remain
unchanged.
The returned object is a copied, internally consistent fitted model. Its coefficients, linear predictors, fitted values, working residuals, deviance and AIC are updated to the calibrated level. The original refined model is not modified. Calibration metadata store the factor, log shift, original and calibrated intercept, creation time and call.
Model refinement changes or constrains the relative tariff structure and is
evaluated through prepare_refinement(), one or more add_*() operations,
and refit(). Model calibration changes only the final overall level. A
calibrated model cannot be calibrated again or used as the starting point
for further refinement. Retain the rating_refinement specification and
recalibrate a newly refitted model if earlier decisions need to be revised.
A fitted glm that also inherits from calibrated_model. Attributes
calibration_factor, calibration_original_intercept,
calibration_intercept, calibration_log_shift, calibration_call and
calibrated_at record the calibration.
refit(), rating_table(), add_prediction(),
audit_refinement()
restrictions <- data.frame(
zip = c(0, 1, 2, 3),
zip_restricted = c(0.90, 1.00, 1.05, 1.10)
)
mod_initial <- glm(
nclaims ~ zip + offset(log(exposure)),
family = poisson(),
data = MTPL
)
mod_refined <- mod_initial |>
prepare_refinement() |>
add_restriction(restrictions) |>
refit(intercept_only = TRUE)
mod_calibrated <- calibrate_model(mod_refined, factor = 1.05)
rating_table(mod_calibrated)
data_final <- mod_refined$data |>
add_prediction(
mod_calibrated,
predictions = "net_risk_premium"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.