library(lavaan)
data(cfa_dat_mg)
mod <-
"
f1 =~ x1 + x2 + x3
f2 =~ x4 + x5 + x6
"
fit1 <- cfa(mod, cfa_dat_mg, group = "gp")
fit2 <- cfa(mod, cfa_dat_mg, group = "gp",
group.equal = "loadings")
fit3 <- cfa(mod, cfa_dat_mg, group = "gp",
group.equal = c("loadings", "intercepts"))
lavTestLRT(fit1, fit2, fit3)
lavTestLRT(fit1, fit3)
# Drop the first case
cfa_dat_mgb <- cfa_dat_mg[-1, ]
fit1b <- cfa(mod, cfa_dat_mgb, group = "gp")
fit2b <- cfa(mod, cfa_dat_mgb, group = "gp",
group.equal = "loadings")
fit3b <- cfa(mod, cfa_dat_mgb, group = "gp",
group.equal = c("loadings", "intercepts"))
lavTestLRT(fit1b, fit2b, fit3b)
lavTestLRT(fit1b, fit3b)
Run the code above in your browser using DataLab