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 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,
...
)A patchwork composition containing the requested ggplot panels.
A factor_analysis or univariate object produced by
factor_analysis() or univariate().
Numeric or character vector specifying which metrics to plot (default is all available metrics). The numeric positions are:
1. Frequency (nclaims / exposure)
2. Average severity (claim_amount / claim_count)
3. Risk premium (claim_amount / exposure)
4. Loss ratio (claim_amount / premium)
5. Average premium (premium / exposure)
6. Exposure
7. Severity
8. Number of claims
9. Premium
Character values can be "frequency", "average_severity",
"risk_premium", "loss_ratio", "average_premium", "exposure",
"claim_amount", "claim_count", and "premium".
Positive whole number. Number of columns in the plot composition.
Character string specifying the legend position.
Supported values are "right", "bottom", "top", "left" and
"none". A legend is present only when the factor_analysis object was
created with group_by, because the resulting group-specific series are
distinguished by colour. Without group_by, colours are fixed plot styles
and no legend is drawn; in that case this argument has no visible effect.
Show exposure as background bars behind line plots (default = TRUE).
Show labels with the exposure bars (default = TRUE).
Sort risk factor levels into descending order by exposure (default = FALSE).
Custom order for risk factor levels; character vector (default = NULL).
Decimal mark; defaults to ",".
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.
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.
Logical. If TRUE, long risk-factor level labels
are shortened to label_width characters. A shortened label ends in one
period; for example, "Bouwnijverheid" becomes "Bouwn." when
label_width = 6. Only the displayed axis labels are changed.
Positive whole number of at least 2. Maximum number of characters in automatically shortened level labels.
Optional named character vector with explicit
display labels, for example
c("Bouwnijverheid" = "Bouwn.", "Onroerend goed" = "Onr. goed").
Explicit labels take precedence over automatic shortening.
Logical. If TRUE, flip cartesian coordinates for bar plots
(metrics 6 to 9). This option does not affect the line-based plots for
metrics 1 to 5.
Show line for total if by is used (default = FALSE).
Color for total line (default = "black").
Legend name for total line (default = NULL).
Numeric value for angle of labels on the x-axis (degrees).
List with customized theme options.
Logical; remove underscores from labels (default = FALSE).
Logical. When TRUE and ncol == 1,
x-axis components are removed from all plots except the last one.
The following elements are suppressed:
axis.title.x
axis.text.x
axis.ticks.x
This prevents duplicated x-axes in vertically stacked patchwork plots.
Defaults to TRUE.
Deprecated. Use metrics instead.
Deprecated alias for show_exposure.
Deprecated alias for show_exposure_labels.
Deprecated alias for sort_by_exposure.
Deprecated alias for level_order.
Deprecated alias for decimal_mark.
Deprecated alias for line_color.
Deprecated alias for bar_fill.
Deprecated alias for flip_bars.
Deprecated alias for compact_x_axis.
Currently unused.
Marc Haine, Martin Haringa
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.
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"))
Run the code above in your browser using DataLab