biggest_reference | R Documentation |
This function specifies the first level of a factor to the level with the largest exposure. Levels of factors are sorted using an alphabetic ordering. If the factor is used in a regression context, then the first level will be the reference. For insurance applications it is common to specify the reference level to the level with the largest exposure.
biggest_reference(x, weight)
x |
an unordered factor |
weight |
a vector containing weights (e.g. exposure). Should be numeric. |
a factor of the same length as x
Martin Haringa
Kaas, Rob & Goovaerts, Marc & Dhaene, Jan & Denuit, Michel. (2008). Modern Actuarial Risk Theory: Using R. doi:10.1007/978-3-540-70998-5.
## Not run: library(dplyr) df <- chickwts %>% mutate(across(where(is.character), as.factor)) %>% mutate(across(where(is.factor), ~biggest_reference(., weight))) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.