It returns a tibble with difference of the specified levels of a smooth from a gam or bam. The sig_diff column states whether the CI includes 0.

get_smooths_difference(
  model,
  series,
  difference,
  conditions = NULL,
  exclude_random = TRUE,
  series_length = 100,
  time_series
)

Arguments

model

A gam or bam model object.

series

An unquoted expression indicating the model term that defines the series on which smoothing is applied. This is the term that is displayed on the x-axis when plotting.

difference

A named list with the levels to compute the difference of.

conditions

A named list specifying the levels to plot from the model terms not among series or difference. Notice the difference with plot_smooths, which uses quos.

exclude_random

Whether to exclude random smooths (the default is TRUE).

series_length

An integer indicating how many values along the time series to use for predicting the outcome term.

time_series

Deprecated, use series instead.

Value

A tibble.

Examples

library(mgcv) set.seed(10) data <- gamSim(4)
#> Factor `by' variable example
model <- gam(y ~ fac + s(x2) + s(x2, by = fac) + s(x0), data = data) get_smooths_difference(model, x2, list(fac = c("1", "2")))
#> # A tibble: 100 x 9 #> x2 x0 difference SE CI CI_upper CI_lower sig_diff group #> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <lgl> <dbl> #> 1 0.00134 0.501 3.82 0.748 1.47 5.28 2.35 TRUE 1 #> 2 0.0114 0.501 3.79 0.707 1.39 5.18 2.40 TRUE 1 #> 3 0.0215 0.501 3.76 0.668 1.31 5.07 2.45 TRUE 1 #> 4 0.0316 0.501 3.73 0.632 1.24 4.97 2.50 TRUE 1 #> 5 0.0417 0.501 3.71 0.598 1.17 4.88 2.54 TRUE 1 #> 6 0.0518 0.501 3.68 0.567 1.11 4.79 2.57 TRUE 1 #> 7 0.0619 0.501 3.66 0.539 1.06 4.71 2.60 TRUE 1 #> 8 0.0719 0.501 3.63 0.514 1.01 4.64 2.62 TRUE 1 #> 9 0.0820 0.501 3.61 0.492 0.965 4.57 2.64 TRUE 1 #> 10 0.0921 0.501 3.58 0.473 0.928 4.51 2.66 TRUE 1 #> # … with 90 more rows
# For details, see vignette if (FALSE) { vignette("plot-smooths", package = "tidymv") }