tidy_basis {gratia} | R Documentation |
A tidy basis representation of a smooth object
Description
Takes an object of class mgcv.smooth
and returns a tidy representation
of the basis.
Usage
tidy_basis(smooth, data = NULL, at = NULL, coefs = NULL, p_ident = NULL)
Arguments
smooth |
a smooth object of or inheriting from class |
data |
a data frame containing the variables used in |
at |
a data frame containing values of the smooth covariate(s) at which the basis should be evaluated. |
coefs |
numeric; an optional vector of coefficients for the smooth |
p_ident |
logical vector; only used for handling |
Value
A tibble.
Author(s)
Gavin L. Simpson
Examples
load_mgcv()
df <- data_sim("eg1", n = 400, seed = 42)
# fit model
m <- gam(y ~ s(x0) + s(x1) + s(x2) + s(x3), data = df, method = "REML")
# tidy representaition of a basis for a smooth definition
# extract the smooth
sm <- get_smooth(m, "s(x2)")
# get the tidy basis - need to pass where we want it to be evaluated
bf <- tidy_basis(sm, at = df)
# can weight the basis by the model coefficients for this smooth
bf <- tidy_basis(sm, at = df, coefs = smooth_coefs(sm, model = m))
[Package gratia version 0.9.2 Index]