Dear all,
I am trying to fit a multi-group CFA model with ordinal indicators. I would like to know if I got all lavaan specifications right for this kind of model. Therefore, I first tried my hand on the HS data. I fitted the basic multi-group model (ML estimator), then the multi-group CFA model with ordinal indicators, and then the multi-group LAVAAN model with ordinal indicators. When I fit the last two models (cfa and lavaan for ordinal indicators), I get exactly the same output (df, statistics, indexes, number of estimated/non-estimated parameters, values of the parameters, etc.). However, as a lavaan newbie, I do not want to take any chances and thus thought it would be wise to get confirmation (especially about potential redundancies in the syntax). Here are the syntaxes:
MULTI-GROUP MODEL (ML)
HS.model <-
'visual =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
speed =~ x7 + x8 + x9'
fit <- cfa(HS.model, data = HolzingerSwineford1939, group = "school")
MULTIGROUP-MODEL (WLSMV) - CFA
#create 4 categories for each continuous variable
DF=HolzingerSwineford1939 #copy data frame into new object
#recode in categorical variables
vec=c("x1","x2","x3","x4","x5","x6","x7","x8","x9")#vector of variables names
MinusSD=function(x){mean(x)-sd(x)}#functions to simplify recoding
PlusSD=function(x){mean(x)+sd(x)}
#create 4 categories
library(car)
for (i in vec)
{ DF[,i]=recode(DF[,i],"lo:MinusSD(DF[,i])=0;MinusSD(DF[,i]):mean(DF[,i])=1;
mean(DF[,i]):PlusSD(DF[,i])=2;PlusSD(DF[,i]):hi=3")}
for (i in vec) {DF[,i]<-ordered(DF[,i])}#order
table(DF$x1);class(DF$x1)
HS.model <-
'visual =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
speed =~ x7 + x8 + x9'
fit <- cfa(HS.model, data = DF, group = "school",estimator="WLSMV")
summary(fit)
fit <- cfa(HS.model, data = DF, group = "school",estimator="WLSMV",group.equal="thresholds")
MULTIGROUP-MODEL (WLSMV) - LAVAANHS.model <-
'visual =~ 1*x1 + x2 + x3
textual =~ 1*x4 + x5 + x6
speed =~ 1*x7 + x8 + x9
#
cov.lv.
visual ~~ textual
visual ~~ speed
textual ~~ speed
#
var.lv.
visual ~~ visual
speed ~~ speed
textual ~~ textual
#scales y
x1 ~*~ x1
x2 ~*~ x2
x3 ~*~ x3
x4 ~*~ x4
x5 ~*~ x5
x6 ~*~ x6
x7 ~*~ x7
x8 ~*~ x8
x9 ~*~ x9'
fit <- lavaan(HS.model,
auto.th=TRUE,data=DF,group="school",estimator="WLSMV",group.equal="thresholds")
Thanks in advance,
Jeffrey Henry