s {galamm} | R Documentation |
Set up smooth term with factor loading
Description
This is a very thin wrapper around mgcv::s
. It enables
the specification of loading variables for smooth terms. The last letter "l",
which stands for "loading", has been added to avoid namespace conflicts with
mgcv
and gamm4
.
Usage
sl(..., factor = NULL)
Arguments
... |
Arguments passed on to |
factor |
Optional character argument specifying the loading variable. Case sensitive. |
Details
The documentation of the function mgcv::s
should be consulted
for details on how to properly set up smooth terms. In particular, note
that these terms distinguish between ordered and unordered factor terms
in the by
variable, which can be provided in ...
and is
forwarded to mgcv::s
.
Value
An object of class xx.smooth.spec
, where xx
is a basis
identifying code given by the bs
argument of s
. It differs
from the smooth returned by mgcv::s
in that it has an additional
attribute named "factor"
which specifies any factor loading which
this smooth term should be multiplied with in order to produce the observed
outcome.
References
Wood SN (2003). “Thin Plate Regression Splines.” Journal of the Royal Statistical Society. Series B (Statistical Methodology), 65(1), 95–114. ISSN 1369-7412.
Wood SN (2017). Generalized Additive Models: An Introduction with R, 2 edition. Chapman and Hall/CRC.
See Also
Other modeling functions:
galamm()
,
t2()
Examples
# Linear mixed model with factor structures
dat <- subset(cognition, domain == 1 & timepoint == 1)
loading_matrix <- matrix(c(1, NA, NA), ncol = 1)
# Model with four thin-plate regression splines as basis functions
mod <- galamm(
formula = y ~ 0 + item + sl(x, k = 4, factor = "loading"),
data = dat,
load.var = "item",
lambda = loading_matrix,
factor = "loading"
)
# Model with four cubic regression splines as basis functions
mod <- galamm(
formula = y ~ 0 + item +
sl(x, bs = "cr", k = 4, factor = "loading"),
data = dat,
load.var = "item",
lambda = loading_matrix,
factor = "loading"
)