Creates a basis expansion from a definition of a smoother using the syntax
of mgcv's smooths via mgcv::s()
., mgcv::te()
, mgcv::ti()
, and
mgcv::t2()
, or from a fitted GAM(M).
basis(object, ...)# S3 method for gam
basis(
object,
select = NULL,
term = deprecated(),
data = NULL,
n = 100,
n_2d = 50,
n_3d = 16,
n_4d = 4,
partial_match = FALSE,
...
)
# S3 method for scam
basis(
object,
select = NULL,
term = deprecated(),
data = NULL,
n = 100,
n_2d = 50,
n_3d = 16,
n_4d = 4,
partial_match = FALSE,
...
)
# S3 method for gamm
basis(
object,
select = NULL,
term = deprecated(),
data = NULL,
n = 100,
n_2d = 50,
n_3d = 16,
n_4d = 4,
partial_match = FALSE,
...
)
# S3 method for list
basis(
object,
select = NULL,
term = deprecated(),
data = NULL,
n = 100,
n_2d = 50,
n_3d = 16,
n_4d = 4,
partial_match = FALSE,
...
)
# S3 method for default
basis(
object,
data,
knots = NULL,
constraints = FALSE,
at = NULL,
diagonalize = FALSE,
...
)
A tibble.
a smooth specification, the result of a call to one of
mgcv::s()
., mgcv::te()
, mgcv::ti()
, or mgcv::t2()
, or a fitted
GAM(M) model.
other arguments passed to mgcv::smoothCon()
.
character; select smooths in a fitted model
a data frame containing the variables used in smooth
.
numeric; the number of points over the range of the covariate at which to evaluate the smooth.
numeric; the number of new observations for each dimension of a
bivariate smooth. Not currently used; n
is used for both dimensions.
numeric; the number of new observations to generate for the third dimension of a 3D smooth.
numeric; the number of new observations to generate for the
dimensions higher than 2 (!) of a kD smooth (k >= 4). For example, if
the smooth is a 4D smooth, each of dimensions 3 and 4 will get n_4d
new observations.
logical; in the case of character select
, should
select
match partially against smooths
? If partial_match = TRUE
,
select
must only be a single string, a character vector of length 1.
a list or data frame with named components containing
knots locations. Names must match the covariates for which the basis
is required. See mgcv::smoothCon()
.
logical; should identifiability constraints be applied to
the smooth basis. See argument absorb.cons
in mgcv::smoothCon()
.
a data frame containing values of the smooth covariate(s) at which the basis should be evaluated.
logical; if TRUE
, reparameterises the smooth such that
the associated penalty is an identity matrix. This has the effect of
turning the last diagonal elements of the penalty to zero, which highlights
the penalty null space.
Gavin L. Simpson
load_mgcv()
# \dontshow{
op <- options(pillar.sigfig = 3, cli.unicode = FALSE)
# }
df <- data_sim("eg4", n = 400, seed = 42)
bf <- basis(s(x0), data = df)
bf <- basis(s(x2, by = fac, bs = "bs"), data = df, constraints = TRUE)
# \dontshow{
options(op)
# }
Run the code above in your browser using DataLab