# 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"
)
Run the code above in your browser using DataLab