R/model_rating_factors.R
autoplot.riskfactor.Rd
Takes an object produced by univariate()
, and plots the
available input.
# S3 method for riskfactor
autoplot(
object,
risk_factors = NULL,
ncol = 1,
labels = TRUE,
dec.mark = ",",
ylab = "rate",
fill = NULL,
color = NULL,
linetype = FALSE,
...
)
riskfactor object produced by rating_factors()
character vector to define which factors are included. Defaults to all risk factors.
number of columns in output (default is 1)
show labels with the exposure (default is TRUE)
control the format of the decimal point, as well as the mark between intervals before the decimal point, choose either "," (default) or "."
modify label for the y-axis
color to fill histogram
color to plot line colors of histogram (default is "skyblue")
use different linetypes (default is FALSE)
other plotting parameters to affect the plot
a ggplot2 object
library(dplyr)
#>
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’:
#>
#> filter, lag
#> The following objects are masked from ‘package:base’:
#>
#> intersect, setdiff, setequal, union
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)
#> Significance levels: *** p < 0.001; ** p < 0.01;
#> * p < 0.05; . p < 0.1
autoplot(x)