View source: R/gam_construct_tariff_classes.R
| add_tariff_segments | R Documentation |
Adds the tariff segments derived by derive_tariff_segments() as a new factor
column to a portfolio data set. The stored boundaries are applied to the
original continuous risk-factor column, so the result does not depend on the
row order used when the GAM was fitted.
The helper does not re-estimate the GAM or derive new boundaries. It can be used after filtering or reordering the original portfolio and on new data whose risk-factor values remain within the range used to derive the segmentation.
add_tariff_segments(data, segments, name = NULL, overwrite = FALSE)
data |
A data frame to which the tariff segments should be added. |
segments |
Object of class |
name |
Character string. Name of the new output column. If |
overwrite |
Logical. If |
The risk-factor name and optional rounding increment are taken from
segments. The risk-factor column in data must be numeric and contain only
finite, non-missing values. Values outside the original segmentation range
produce an error because their tariff treatment has not been supported by
the fitted GAM. The resulting factor can be used in a GLM or retained as a
candidate grouping for further actuarial review.
A data frame with the derived tariff segment column added.
Martin Haringa
risk_factor_gam(), derive_tariff_segments()
## Not run:
age_segments <- risk_factor_gam(
MTPL,
risk_factor = "age_policyholder",
claim_count = "nclaims",
exposure = "exposure"
) |>
derive_tariff_segments()
MTPL |>
add_tariff_segments(age_segments, name = "age_policyholder_segment")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.