if (FALSE) {
library("dplyr")
# Load data:
data(StarWars)
# Originally a partial measurement invariance model in
# https://psychonetrics.org/files/Epskampetal2017.pdf:
mod1 <- lvm(StarWars, lambda = matrix(1, 10), vars = paste0("Q", 1:10),
identification = "variance", latents = "Force",
estimator = "MLM") %>% runmodel
# A model fixing two prequel loadings to zero:
mod2 <- mod1 %>% fixpar("lambda", row = "Q4", col = "Force") %>%
fixpar("lambda", row = "Q5", col = "Force") %>% runmodel
# Compare with the scaled (Satorra-Bentler 2001) difference test:
compare(full = mod1, restricted = mod2)
}
Run the code above in your browser using DataLab