sl function

Set up smooth term with factor loading

Set up smooth term with factor loading

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.

sl(..., factor = NULL)

Arguments

  • ...: Arguments passed on to mgcv::s.
  • factor: Optional character argument specifying the loading variable. Case sensitive.

Returns

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.

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.

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" )

References

\insertRef woodThinPlateRegression2003galamm

\insertRef woodGeneralizedAdditiveModels2017agalamm

See Also

Other modeling functions: galamm(), t2()