Learn R Programming

gratia (version 0.9.0)

add_sizer: Add indicators of significant change after SiZeR

Description

Add indicators of significant change after SiZeR

Usage

add_sizer(object, type = c("change", "sizer"), ...)

# S3 method for derivatives add_sizer(object, type = c("change", "sizer"), ...)

# S3 method for smooth_estimates add_sizer(object, type = c("change", "sizer"), derivatives = NULL, ...)

Arguments

object

an R object. Currently supported methods are for classes "derivatives".

type

character; "change" adds a single variable to object indicating where the credible interval on the derivative excludes 0. "sizer" adds two variables indicating whether the derivative is postive or negative.

...

arguments passed to other methods

derivatives

an object of class "derivatives", resulting from a call to derivatives().

Examples

Run this code
load_mgcv()
# \dontshow{
op <- options(pillar.sigfig = 3, cli.unicode = FALSE)
# }
df <- data_sim("eg1", n = 400, dist = "normal", scale = 2, seed = 42)
m <- gam(y ~ s(x0) + s(x1) + s(x2) + s(x3), data = df, method = "REML")

## first derivatives of all smooths using central finite differences
d <- derivatives(m, type = "central") |>
  add_sizer()

# default adds a .change column
names(d)

Run the code above in your browser using DataLab