View source: R/gam_riskfactor.R
| risk_factor_gam | R Documentation |
Fits a generalized additive model (GAM) to a continuous risk factor in one of three insurance pricing contexts: claim frequency, claim severity, or pure premium. The fitted curve helps assess non-linear rating effects before a continuous variable is grouped into tariff segments or used in a GLM workflow.
risk_factor_gam(
data,
risk_factor = NULL,
claim_count = NULL,
exposure = NULL,
claim_amount = NULL,
pure_premium = NULL,
model = "frequency",
round_risk_factor = NULL,
x = NULL,
nclaims = NULL,
amount = NULL,
round_x = NULL
)
data |
A data.frame containing the insurance portfolio. |
risk_factor |
Character, name of column in |
claim_count |
Character, name of column in |
exposure |
Character, name of column in |
claim_amount |
(Optional) Character, column name in |
pure_premium |
(Optional) Character, column name in |
model |
Character string specifying the model type. One of
|
round_risk_factor |
(Optional) Numeric value to round the risk factor to
a multiple of |
x, nclaims, amount, round_x |
Deprecated argument names. Use |
Frequency model: Fits a Poisson GAM to the number of claims. The log of the exposure is used as an offset so the expected number of claims is proportional to exposure.
Severity model: Fits a Gamma GAM with log link to the average claim size (total amount divided by number of claims). The number of claims is included as a weight.
Pure premium model: Fits a Gamma GAM with log link to the pure premium
(risk premium). Implemented by aggregating exposure-weighted pure premiums.
The deprecated model value "burning" is still accepted for backward
compatibility.
fit_gam()The function fit_gam() is deprecated as of version 0.8.0 and replaced by
risk_factor_gam(). In addition to the name change, the interface has also
changed:
fit_gam() used non-standard evaluation (NSE), so column names could be
passed unquoted (e.g. x = age_policyholder).
risk_factor_gam() uses standard evaluation (SE), so column names must
be passed as character strings (e.g. risk_factor = "age_policyholder").
This makes the function easier to use in programmatic workflows.
riskfactor_gam() and fit_gam() are still available for backward
compatibility but will emit deprecation warnings.
A list of class "riskfactor_gam" with the following elements:
prediction |
A data frame with predicted values and confidence intervals. |
x |
Name of the continuous risk factor. |
model |
The model type: |
data |
Merged data frame with predictions and observed values. |
x_obs |
Observed values of the continuous risk factor. |
Martin Haringa
Antonio, K. and Valdez, E. A. (2012). Statistical concepts of a priori and a posteriori risk classification in insurance. Advances in Statistical Analysis, 96(2):187–224.
Henckaerts, R., Antonio, K., Clijsters, M. and Verbelen, R. (2018). A data driven binning strategy for the construction of insurance tariff classes. Scandinavian Actuarial Journal, 2018:8, 681–705.
Wood, S.N. (2011). Fast stable restricted maximum likelihood and marginal likelihood estimation of semiparametric generalized linear models. Journal of the Royal Statistical Society (B) 73(1):3–36.
## --- Recommended new usage (SE) ---
# Column names must be passed as strings
risk_factor_gam(MTPL,
risk_factor = "age_policyholder",
claim_count = "nclaims",
exposure = "exposure")
## --- Deprecated usage (NSE) ---
# This still works but will show a warning
fit_gam(MTPL,
nclaims = nclaims,
x = age_policyholder,
exposure = exposure)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.