library(modsem)
set.seed(2938472)modsem implements a Monte-Carlo correction for LMS and QML models with ordinal data. Here we refer to these informally as MC-LMS-ORD and MC-QML-ORD.
The MC-LMS-ORD and MC-QML-ORD algorithms are based on Slupphaug, Mehmetoglu, and Mittner (2026) For a more direct implementation of the original algorithm, we recommend checking out the plssem package.
Here we ordinalize the data in the oneInt dataset.
ordinalize <- function(x, probs = c(0, 0.35, 0.7, 1)) {
x <- (x - mean(x)) / sd(x)
cut(
x,
breaks = stats::quantile(x, probs = probs),
include.lowest = TRUE,
ordered_result = TRUE
)
}
oneIntOrd <- as.data.frame(lapply(oneInt, ordinalize))Now we can estimate our model, indicating which variables are ordinal, using the ordered= argument.
model <- "
X =~ x1 + x2 + x3
Z =~ z1 + z2 + z3
Y =~ y1 + y2 + y3
Y ~ X + Z + X:Z
"
fit_lms_ord <- modsem(
model,
data = oneIntOrd,
method = "lms",
ordered = colnames(oneIntOrd)
)
summary(fit_lms_ord)