This function estimates splines in vglmer, similar to s(...) in
mgcv albeit with many fewer options than mgcv. It allows for
truncated (linear) splines (type="tpf"), O'Sullivan splines
(type="o"), or kernel ridge regression (type="gKRLS"). Please
see vglmer for more discussion and examples. For information on kernel
ridge regression, please consult gKRLS.
v_s(
...,
type = "tpf",
knots = NULL,
by = NA,
xt = NULL,
by_re = TRUE,
force_vector = FALSE,
outer_okay = FALSE
)This function returns a list of class of vglmer_spline that is
passed to unexported functions. It contains the arguments noted above where
... is parsed into an argument called term.
Variable name, e.g. v_s(x)
Default ("tpf") uses truncated linear splines for the
basis. "o" uses O'Sullivan splines (Wand and Ormerod 2008).
Smoothing across multiple covariates, e.g. v_s(x,x2,type="gKRLS"),
can be done using kernel ridge regression. Chang and Goplerud (2024)
provide a detailed discussion. Note that "gKRLS" by default uses
random sketching to create the relevant bases and thus a seed would need to
be set to ensure exact replicability.
Default (NULL) uses \(K=min(N/4,35)\) knots evenly
spaced at quantiles of the covariate x. A single number specifies a
specific number of knots; a vector can set custom locations for knots.
A categorical or factor covariate to interact the spline with; for
example, v_s(x, by = g).
Arguments passed to xt from mgcv; at the moment, this
is only used for type="gKRLS" to pass the function gKRLS().
Please see the documentation of gKRLS for more
details.
Default (TRUE) regularizes the interactions between the
categorical factor and the covariate. See "Details" in vglmer for
more discussion.
Force that argument to knots is treated as vector.
This is usually not needed unless knots is a single integer that
should be treated as a single knot (vs. the number of knots).
Default (FALSE) does not permit values in x
to exceed the outer knots.
Chang, Qing, and Max Goplerud. 2024. "Generalized Kernel Regularized Least Squares." Political Analysis 32(2):157-171.
Wand, Matt P. and Ormerod, John T. 2008. "On Semiparametric Regression with O'Sullivan Penalized Splines". Australian & New Zealand Journal of Statistics. 50(2): 179-198.
Wood, Simon N. 2017. Generalized Additive Models: An Introduction with R. Chapman and Hall/CRC.