t2 {galamm}R Documentation

Set up smooth term with factor loading

Description

This is a very thin wrapper around mgcv::t2. 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

t2l(..., factor = NULL)

Arguments

...

Arguments passed on to mgcv::t2.

factor

Optional character of length one specifying the loading variable. Case sensitive.

Details

The documentation of the function mgcv::t2 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::t2.

Value

An object of class xx.smooth.spec, where xx is a basis identifying code given by the bs argument of t2. 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(), 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 cubic regression splines as basis functions
mod <- galamm(
  formula = y ~ 0 + item + t2l(x, k = 4, factor = "loading"),
  data = dat,
  load.var = "item",
  lambda = loading_matrix,
  factor = "loading"
)

# Model with four thin-plate regression splines as basis functions
mod <- galamm(
  formula = y ~ 0 + item +
    t2l(x, bs = "tp", k = 4, factor = "loading"),
  data = dat,
  load.var = "item",
  lambda = loading_matrix,
  factor = "loading"
)


[Package galamm version 0.2.0 Index]