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 |
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 |
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,
|
length_out |
An integer indicating how many values to use along the
numeric variables for predicting the response (the default is |
ci_z |
The z-value for calculating the CIs (the default is |
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")))