| autoplot.factor_analysis | R Documentation |
Visualise the exposure and observed actuarial metrics calculated by
factor_analysis(). The plots support assessment of portfolio composition,
observed frequency, severity, risk premium and loss ratio across risk-factor
levels.
The observed patterns are descriptive. They do not adjust for correlations with other risk factors and should therefore not be interpreted as multivariate tariff relativities.
## S3 method for class 'factor_analysis'
autoplot(
object,
metrics = NULL,
ncol = 1,
legend_position = c("right", "bottom", "top", "left", "none"),
show_exposure = TRUE,
show_exposure_labels = TRUE,
sort_by_exposure = FALSE,
level_order = NULL,
decimal_mark = ",",
line_color = NULL,
bar_fill = NULL,
abbreviate_labels = TRUE,
label_width = 20,
label_abbreviations = NULL,
flip_bars = FALSE,
show_total = FALSE,
total_color = NULL,
total_name = NULL,
rotate_angle = NULL,
custom_theme = NULL,
remove_underscores = FALSE,
compact_x_axis = TRUE,
show_plots = NULL,
background = NULL,
labels = NULL,
sort = NULL,
sort_manual = NULL,
dec.mark = NULL,
color = NULL,
color_bg = NULL,
coord_flip = NULL,
remove_x_elements = NULL,
...
)
object |
A |
metrics |
Numeric or character vector specifying which metrics to plot (default is all available metrics). The numeric positions are:
Character values can be |
ncol |
Positive whole number. Number of columns in the plot composition. |
legend_position |
Character string specifying the legend position.
Supported values are |
show_exposure |
Show exposure as background bars behind line plots (default = TRUE). |
show_exposure_labels |
Show labels with the exposure bars (default = TRUE). |
sort_by_exposure |
Sort risk factor levels into descending order by exposure (default = FALSE). |
level_order |
Custom order for risk factor levels; character vector (default = NULL). |
decimal_mark |
Decimal mark; defaults to |
line_color |
Optional override for line/point color. If NULL (default), colors are taken from the internal palette. If specified, the chosen color is applied to all line-based plots. |
bar_fill |
Optional override for background bar color. If NULL (default), the background color is taken from the internal palette. If specified, the chosen color is applied to all background bars. |
abbreviate_labels |
Logical. If |
label_width |
Positive whole number of at least 2. Maximum number of characters in automatically shortened level labels. |
label_abbreviations |
Optional named character vector with explicit
display labels, for example
|
flip_bars |
Logical. If |
show_total |
Show line for total if |
total_color |
Color for total line (default = |
total_name |
Legend name for total line (default = NULL). |
rotate_angle |
Numeric value for angle of labels on the x-axis (degrees). |
custom_theme |
List with customized theme options. |
remove_underscores |
Logical; remove underscores from labels (default = FALSE). |
compact_x_axis |
Logical. When
This prevents duplicated x-axes in vertically stacked patchwork plots.
Defaults to |
show_plots |
Deprecated. Use |
background |
Deprecated alias for |
labels |
Deprecated alias for |
sort |
Deprecated alias for |
sort_manual |
Deprecated alias for |
dec.mark |
Deprecated alias for |
color |
Deprecated alias for |
color_bg |
Deprecated alias for |
coord_flip |
Deprecated alias for |
remove_x_elements |
Deprecated alias for |
... |
Currently unused. |
For rate-based metrics, exposure can be shown as background bars so that observed level differences can be interpreted together with portfolio volume. Levels with little exposure or few claims can produce volatile observed metrics and should be assessed accordingly.
When the factor analysis contains one or more by variables, separate
observed series are shown. show_total = TRUE adds the aggregate portfolio
series for comparison. Sorting and manual level ordering affect only the
presentation; the underlying summaries are unchanged.
A rate or ratio is not shown for a risk-factor level when its denominator is
zero or missing. For example, average severity is undefined when claim count
is zero, and loss ratio is undefined when premium is zero. autoplot() gives
one combined warning identifying the affected metrics and levels. Other valid
metrics and exposure information remain in the figure.
A patchwork composition containing the requested ggplot panels.
Marc Haine, Martin Haringa
factor_analysis(), add_portfolio_experience()
# Plot observed frequency and risk premium
x <- factor_analysis(MTPL2,
x = "area",
severity = "amount",
nclaims = "nclaims",
exposure = "exposure")
autoplot(x, metrics = c("frequency", "risk_premium"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.