get_difference {tidygam}R Documentation

Get difference between two smooths

Description

Get difference between two smooths

Usage

get_difference(
  model,
  series,
  compare,
  values = NULL,
  exclude_terms = NULL,
  length_out = 25,
  ci_z = 1.96
)

Arguments

model

A gam or bam model object.

series

A string specifying the variable that corresponds to the series to be plotted on the $x$-axis. If a string is given, the other numeric variables in the model are set to their mean value, unless specific values are given in values. If a character vector of two strings is given, the two variables will be taken as the elements of a tensor product smooth. This allows the user to plot 2D raster plots.

compare

A named list of factor levels to compare.

values

User supplied values for specific variables as a named list.

exclude_terms

Terms to be excluded from the prediction. Term names should be given as they appear in the model summary (for example, "s(x0,x1)").

length_out

An integer indicating how many values to use along the numeric variables for predicting the response (the default is 10).

ci_z

The z-value for calculating the CIs (the default is 1.96 for 95 percent CI).

Value

A tibble with the difference smooth.

Examples

library(mgcv)
set.seed(10)
data <- gamSim(4)
model <- gam(y ~ s(x2, by = fac) + s(x0), data = data)

get_difference(model, "x2", list(fac = c("1", "2")))

[Package tidygam version 0.2.0 Index]