autoplot.constructtariffclasses: Automatically create a ggplot for objects obtained from...

View source: R/gam_construct_tariff_classes.R View source: R/construct_tariff_classes.R

autoplot.constructtariffclassesR Documentation

Automatically create a ggplot for objects obtained from construct_tariff_classes()

Description

Takes an object produced by construct_tariff_classes(), and plots the fitted GAM. In addition the constructed tariff classes are shown.

Takes an object produced by construct_tariff_classes(), and plots the fitted GAM. In addition the constructed tariff classes are shown.

Usage

## S3 method for class 'constructtariffclasses'
autoplot(
  object,
  conf_int = FALSE,
  color_gam = "steelblue",
  show_observations = FALSE,
  color_splits = "grey50",
  size_points = 1,
  color_points = "black",
  rotate_labels = FALSE,
  remove_outliers = NULL,
  ...
)

## S3 method for class 'constructtariffclasses'
autoplot(
  object,
  conf_int = FALSE,
  color_gam = "steelblue",
  show_observations = FALSE,
  color_splits = "grey50",
  size_points = 1,
  color_points = "black",
  rotate_labels = FALSE,
  remove_outliers = NULL,
  ...
)

Arguments

object

constructtariffclasses object produced by construct_tariff_classes

conf_int

determines whether 95 percent confidence intervals will be plotted. The default is conf_int = FALSE

color_gam

a color can be specified either by name (e.g.: "red") or by hexadecimal code (e.g. : "#FF1234") (default is "steelblue")

show_observations

add observed frequency/severity points for each level of the variable for which tariff classes are constructed

color_splits

change the color of the splits in the graph ("grey50" is default)

size_points

size for points (1 is default)

color_points

change the color of the points in the graph ("black" is default)

rotate_labels

rotate x-labels 45 degrees (this might be helpful for overlapping x-labels)

remove_outliers

do not show observations above this number in the plot. This might be helpful for outliers.

...

other plotting parameters to affect the plot

Value

a ggplot object

a ggplot object

Author(s)

Martin Haringa

Examples

## Not run: 
library(ggplot2)
library(dplyr)
fit_gam(MTPL, nclaims = nclaims, x = age_policyholder, exposure = exposure) %>%
   construct_tariff_classes(.) %>%
   autoplot(., show_observations = TRUE)

## End(Not run)

## Not run: 
library(ggplot2)
library(dplyr)
fit_gam(MTPL, nclaims = nclaims, x = age_policyholder,
        exposure = exposure) %>%
   construct_tariff_classes(.) %>%
   autoplot(., show_observations = TRUE)

## End(Not run)


MHaringa/actuarialpricing documentation built on Jan. 11, 2024, 1:13 a.m.