Learn R Programming

insurancerating (version 0.7.5)

autoplot.fitgam: Automatically create a ggplot for objects obtained from fit_gam()

Description

Takes an object produced by fit_gam(), and plots the fitted GAM.

Usage

# S3 method for fitgam
autoplot(
  object,
  conf_int = FALSE,
  color_gam = "steelblue",
  show_observations = FALSE,
  x_stepsize = NULL,
  size_points = 1,
  color_points = "black",
  rotate_labels = FALSE,
  remove_outliers = NULL,
  ...
)

Value

a ggplot object

Arguments

object

fitgam object produced by fit_gam()

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

x_stepsize

set step size for labels horizontal axis

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

Author

Martin Haringa

Examples

Run this code
if (FALSE) {
library(ggplot2)
library(dplyr)
fit_gam(MTPL, nclaims = nclaims, x = age_policyholder,
        exposure = exposure) |>
   autoplot(show_observations = TRUE)
}

Run the code above in your browser using DataLab