autoplot.riskfactor {insurancerating} | R Documentation |
Automatically create a ggplot for objects obtained from rating_factors()
Description
Takes an object produced by univariate()
, and plots the
available input.
Usage
## S3 method for class 'riskfactor'
autoplot(
object,
risk_factors = NULL,
ncol = 1,
labels = TRUE,
dec.mark = ",",
ylab = "rate",
fill = NULL,
color = NULL,
linetype = FALSE,
...
)
Arguments
object |
riskfactor object produced by |
risk_factors |
character vector to define which factors are included. Defaults to all risk factors. |
ncol |
number of columns in output (default is 1) |
labels |
show labels with the exposure (default is TRUE) |
dec.mark |
control the format of the decimal point, as well as the mark between intervals before the decimal point, choose either "," (default) or "." |
ylab |
modify label for the y-axis |
fill |
color to fill histogram |
color |
color to plot line colors of histogram (default is "skyblue") |
linetype |
use different linetypes (default is FALSE) |
... |
other plotting parameters to affect the plot |
Value
a ggplot2 object
Author(s)
Martin Haringa
Examples
library(dplyr)
df <- MTPL2 %>%
mutate(across(c(area), as.factor)) %>%
mutate(across(c(area), ~biggest_reference(., exposure)))
mod1 <- glm(nclaims ~ area + premium, offset = log(exposure),
family = poisson(), data = df)
mod2 <- glm(nclaims ~ area, offset = log(exposure), family = poisson(),
data = df)
x <- rating_factors(mod1, mod2, model_data = df, exposure = exposure)
autoplot(x)
[Package insurancerating version 0.7.4 Index]