Coerce a data.frame to a minimal Experience object for loss ratio
analysis.
This function checks that the input contains the minimum required
columns, attempts to coerce them to the expected classes, optionally
derives standard period variables via add_experience_period(), and
prepends class "Experience".
The function intentionally performs only minimal coercion. Other columns such as grouping variables or presentation variables are left unchanged and should be cleaned by the user in advance.
Arguments
- df
A data.frame containing experience data.
- add_period
Logical; if
TRUE, derive additional period variables usingadd_experience_period(). Default isTRUE.
Details
Minimum required columns are:
cym: Calendar year-month (Dateor coercible toDate)uym: Underwriting year-month (Dateor coercible toDate)loss: Incurred loss amount (numericor coercible)rp: Risk premium (numericor coercible)
If add_period = TRUE, additional period variables such as uy,
uyh, uyq, cy, cyh, cyq, elap_y, elap_h, and elap_q may be
added, depending on the available source columns.
Examples
if (FALSE) { # \dontrun{
x <- as_experience(df)
class(x)
} # }
