plot_gam_1d: Plot smooth parameters estimated from Generalized Additive...

Description Usage Arguments Value Author(s)

View source: R/plot_gam_1d.R

Description

From a one dimensional GAM model produced by mgcv::gam(), produces a ggplot2 based plot of selected smooth parameters in a multi-panel display.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
plot_gam_1d(
  gam_model = NULL,
  select_smooth_terms = NULL,
  columns = 2,
  col_width = 4,
  row_height = 4,
  n_points = 100,
  se = TRUE,
  se_fill = NA,
  se_color = "red",
  title = NULL,
  subtitle = NULL,
  center_titles = FALSE,
  x_limits = NULL,
  x_major_breaks = waiver(),
  y_limits = NULL,
  y_major_breaks = waiver(),
  line_width = 1,
  line_color = "black"
)

Arguments

gam_model

A gam one dimensional model produced after fitting data from the mgcv::gam() function.

select_smooth_terms

A string vector of one or more data variables from the GAM model to be plotted. If NULL the all the smooth parameters are plotted.

columns

An integer that sets the number of columns for the multi-panel display.

col_width

An integer that sets the width of each plot column in inches.

row_height

An integer that sets the height of each plot column in inches.

n_points

An integer that sets the number of points used for each 1-d plot.

se

A logical which if TRUE upper and lower lines are plotted at 2 standard errors above and below the the smooth being plotted.

se_fill

A string that sets the fill color between the standard error lines.

se_color

A string that sets the color of the standard error lines.

title

A string that sets the plot title.

subtitle

A string that sets the plot subtitle.

center_titles

A logical which if TRUE centers both the title and subtitle.

x_limits

Depending on the class of aes_x, a numeric/Date/POSIXct 2 element vector that sets the minimum and maximum for the x axis.

x_major_breaks

A numeric vector that defines the exact major tic locations along the x axis for all smooth parameters. If not set then each smooth parameter has their own x axis scaling using ggplot2 defaults. In addition the argument may be assigned to a named list (e.g. list(x1 = seq(-3, 4, 1.0), x3 = seq(-2, 2, 0.5))) of numeric vectors.

y_limits

A numeric 2 element vector that sets the minimum and maximum for the y axis for all smooth parameters.

y_major_breaks

A numeric vector that defines the exact major tic locations along the y axis for all smooth parameters. If not set then each smooth parameter has their own y axis scaling using ggplot2 defaults. In addition the argument may be assigned to a named list (e.g. list(x1 = seq(-3, 4, 1.0), x3 = seq(-2, 2, 0.5))) of numeric vectors.

line_width

A numeric value that sets the width of lines.

line_color

A string that sets the color of the lines.

Value

A ggplot2 plot object

Author(s)

Rick Dean


deandevl/RgamPkg documentation built on Sept. 17, 2021, 2:02 p.m.