a) When i use a second-order-factor in my SEM. How does "group.equal=c(...)) behave?
Additional-Question: If it´s possible to use group.equal for second-order-factors, is the loading of the first first-order factor on the second order factor fixed to 1 or is the second order factor-mean fixed to 0 and the variance fixed to 1 for supplying a metric to the second order factor?
#--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#----------------------------------------------------
#model 1 - configural invariance
model.configural<-'
#measurement model
a =~ c(1,1)*F09_a + c(a11,a12)*F09_b + c(a21,a22)*F09_c
b =~ c(1,1)*F10_a + c(b11,b12)*F10_b + c(b21,b22)*F10_c
c =~ c(1,1)*F10_d + c(c11,c12)*F10_e
lat1 =~ NA*a + NA*b + c(1,1)*c
lat2 =~ c(1,1)*F12_a + c(d11,d12)*F12_b
lat3 =~ c(1,1)*F12_d + c(e11,e12)*F12_e
lat4 =~ c(1,1)*F12_c
lat5 =~ c(1,1)*F12_g
lat6 =~ c(1,1)*F12_f
#single-indicator errorterm variances
F12_c ~~ 0.1581*F12_c
F12_f ~~ 0.1246*F12_f
F12_g ~~ 0.1068*F12_g
'
lavaan.fit_configural<-cfa(model.configural, data=datensatz, group="gender")
survey.fit_configural<-lavaan.survey(lavaan.fit_configural, svy.df)
summary(survey.fit_configural,fit.measures=TRUE,standardized=TRUE)
######################################################################################
# model2 - weak invariance 1st order factor loadings
model.weak1<-'
#measurement
a =~ c(1,1)*F09_a + c(a1,a1)*F09_b + c(a2,a2)*F09_c
b =~ c(1,1)*F10_a + c(b1,b1)*F10_b + c(b2,b2)*F10_c
c =~ c(1,1)*F10_d + c(c1,c1)*F10_e
lat1 =~ c(lat21,lat22)*a + c(lat31,lat32)*b + c(1,1)*c
lat2 =~ c(1,1)*F12_a + c(d1,d1)*F12_b
lat3 =~ c(1,1)*F12_d + c(e1,e1)*F12_e
lat4 =~ c(1,1)*F12_c
lat5 =~ c(1,1)*F12_g
lat6 =~ c(1,1)*F12_f
#errorterm variances
F12_c ~~ c(0.1581,0.1581)*F12_c
F12_f ~~ c(0.1246,0.1246)*F12_f
F12_g ~~ c(0.1068,0.1068)*F12_g
'
lavaan.fit_weak1<-cfa(model.weak1, data=datensatz, group="gender")
survey.fit_weak1<-lavaan.survey(lavaan.fit_weak1, svy.df)
summary(survey.fit_weak1,fit.measures=TRUE,standardized=TRUE)
# invariance test accounting for survey design
lavTestLRT( survey.fit_configural , survey.fit_weak1 , SB.classic = TRUE )
fit.configural<-fitMeasures(survey.fit_configural, c("chisq","df", "pvalue","cfi"))
fit.weak1<-fitMeasures(survey.fit_weak1, c("chisq","df", "pvalue","cfi"))
fit.configural
fit.weak1
#------------------------------------------------------------------------
# model2 - weak invariance 1st and 2nd order factor loadings
model.weak2<-'
#measurement
a =~ c(1,1)*F09_a + c(a1,a1)*F09_b + c(a2,a2)*F09_c
b =~ c(1,1)*F10_a + c(b1,b1)*F10_b + c(b2,b2)*F10_c
c =~ c(1,1)*F10_d + c(c1,c1)*F10_e
lat1 =~ c(lat2,lat2)*a + c(lat3,lat3)*b + c(1,1)*c
lat2 =~ c(1,1)*F12_a + c(d1,d1)*F12_b
lat3 =~ c(1,1)*F12_d + c(e1,e1)*F12_e
lat4 =~ c(1,1)*F12_c
lat5 =~ c(1,1)*F12_g
lat6 =~ c(1,1)*F12_f
#errorterm variances
F12_c ~~ 0.1581*F12_c
F12_f ~~ 0.1246*F12_f
F12_g ~~ 0.1068*F12_g
'
lavaan.fit_weak2<-cfa(model.weak2, data=datensatz, group="gender")
survey.fit_weak2<-lavaan.survey(lavaan.fit_weak2, svy.df)
summary(survey.fit_weak2,fit.measures=TRUE,standardized=TRUE)
# invariance test accounting for survey design
lavTestLRT( survey.fit_configural , survey.fit_weak2 , SB.classic = TRUE )
lavTestLRT( survey.fit_weak1 , survey.fit_weak2 , SB.classic = TRUE )
fit.configural<-fitMeasures(survey.fit_configural, c("chisq","df", "pvalue","cfi"))
fit.weak1<-fitMeasures(survey.fit_weak1, c("chisq","df", "pvalue","cfi"))
fit.weak2<-fitMeasures(survey.fit_weak2, c("chisq","df", "pvalue","cfi"))
fit.configural
fit.weak1
fit.weak2
#------------------------------------------------------------------------
#model4 - strong invariance 1st & 2nd order loadings + item intercepts
model.strong1<-'
#measurement
a =~ c(1,1)*F09_a + c(a1,a1)*F09_b + c(a2,a2)*F09_c
b =~ c(1,1)*F10_a + c(b1,b1)*F10_b + c(b2,b2)*F10_c
c =~ c(1,1)*F10_d + c(c1,c1)*F10_e
lat1 =~ c(lat2,lat2)*a + c(lat3,lat3)*b + c(1,1)*c
lat2 =~ c(1,1)*F12_a + c(d1,d1)*F12_b
lat3 =~ c(1,1)*F12_d + c(e1,e1)*F12_e
lat4 =~ c(1,1)*F12_c
lat5 =~ c(1,1)*F12_g
lat6 =~ c(1,1)*F12_f
#errorterm variances
F12_c ~~ 0.1581*F12_c
F12_f ~~ 0.1246*F12_f
F12_g ~~ 0.1068*F12_g
#intercepts
F09_a ~ c(int11, int11)*1
F09_b ~ c(int21, int21)*1
F09_c ~ c(int31, int31)*1
F10_a ~ c(int41, int41)*1
F10_b ~ c(int51, int51)*1
F10_c ~ c(int61, int61)*1
F10_d ~ c(int71, int71)*1
F10_e ~ c(int81, int81)*1
F12_a ~ c(int13, int13)*1
F12_b ~ c(int23, int23)*1
F12_c ~ c(int33, int33)*1
F12_d ~ c(int43, int43)*1
F12_e ~ c(int53, int53)*1
F12_f ~ c(int63, int63)*1
F12_g ~ c(int73, int73)*1
'
lavaan.fit_strong1<-cfa(model.strong1, data=datensatz, group="gender")
survey.fit_strong1<-lavaan.survey(lavaan.fit_strong1, svy.df)
summary(survey.fit_strong1,fit.measures=TRUE,standardized=TRUE)
# invariance test accounting for survey design
lavTestLRT( survey.fit_configural , survey.fit_strong1 , SB.classic = TRUE )
lavTestLRT( survey.fit_weak2 ,survey.fit_strong1, SB.classic = TRUE )
fit.configural<-fitMeasures(survey.fit_configural, c("chisq","df", "pvalue","cfi"))
fit.weak1<-fitMeasures(survey.fit_weak1, c("chisq","df", "pvalue","cfi"))
fit.weak2<-fitMeasures(survey.fit_weak2, c("chisq","df", "pvalue","cfi"))
fit.strong1<-fitMeasures(survey.fit_strong1, c("chisq","df", "pvalue","cfi"))
fit.configural
fit.weak1
fit.weak2
fit.strong1
#------------------------------------------------------------------------
#model5 - strong invariance 1st & 2nd order loadings + item intercepts & intercepts of first order factor intercepts (a,b,c)
model.strong2<-'
#measurement
a =~ c(1,1)*F09_a + c(a1,a1)*F09_b + c(a2,a2)*F09_c
b =~ c(1,1)*F10_a + c(b1,b1)*F10_b + c(b2,b2)*F10_c
c =~ c(1,1)*F10_d + c(c1,c1)*F10_e
lat1 =~ c(lat2,lat2)*a + c(lat3,lat3)*b + c(1,1)*c
lat2 =~ c(1,1)*F12_a + c(d1,d1)*F12_b
lat3 =~ c(1,1)*F12_d + c(e1,e1)*F12_e
lat4 =~ c(1,1)*F12_c
lat5 =~ c(1,1)*F12_g
lat6 =~ c(1,1)*F12_f
#errorterm variances
F12_c ~~ 0.1581*F12_c
F12_f ~~ 0.1246*F12_f
F12_g ~~ 0.1068*F12_g
#1st order factor intercepts / mean
a ~ c(inta,inta)*1
b ~ c(intb,intb)*1
c ~ c(intc,intc)*1
#intercepts
F09_a ~ c(int11, int11)*1
F09_b ~ c(int21, int21)*1
F09_c ~ c(int31, int31)*1
F10_a ~ c(int41, int41)*1
F10_b ~ c(int51, int51)*1
F10_c ~ c(int61, int61)*1
F10_d ~ c(int71, int71)*1
F10_e ~ c(int81, int81)*1
F12_a ~ c(int13, int13)*1
F12_b ~ c(int23, int23)*1
F12_c ~ c(int33, int33)*1
F12_d ~ c(int43, int43)*1
F12_e ~ c(int53, int53)*1
F12_f ~ c(int63, int63)*1
F12_g ~ c(int73, int73)*1
'
lavaan.fit_strong2<-cfa(model.strong2, data=datensatz, group="gender")
survey.fit_strong2<-lavaan.survey(lavaan.fit_strong2, svy.df)
summary(survey.fit_strong2,fit.measures=TRUE,standardized=TRUE)
# invariance test accounting for survey design
lavTestLRT( survey.fit_configural , survey.fit_strong2 , SB.classic = TRUE )
lavTestLRT( survey.fit_strong1 ,survey.fit_strong2, SB.classic = TRUE )
fit.configural<-fitMeasures(survey.fit_configural, c("chisq","df", "pvalue","cfi","rmsea"))
fit.weak1<-fitMeasures(survey.fit_weak1, c("chisq","df", "pvalue","cfi","rmsea"))
fit.weak2<-fitMeasures(survey.fit_weak2, c("chisq","df", "pvalue","cfi","rmsea"))
fit.strong1<-fitMeasures(survey.fit_strong1, c("chisq","df", "pvalue","cfi","rmsea"))
fit.strong2<-fitMeasures(survey.fit_strong2, c("chisq","df", "pvalue","cfi","rmsea"))
fit.configural
fit.weak1
fit.weak2
fit.strong1
fit.strong2
Errror on Model 5:
> lavTestLRT( survey.fit_strong1 ,survey.fit_strong2, SB.classic = TRUE )
Scaled Chi Square Difference Test (method = "satorra.bentler.2001")
# Df AIC BIC Chisq Chisq diff Df diff Pr(>Chisq)
# survey.fit_strong2 172 15264 15651 287.45
# survey.fit_strong1 175 15258 15633 287.45 3
# Warning message:
# In lav_test_diff_SatorraBentler2001(mods[[m]], mods[[m + 1]]) :
# lavaan WARNING: scaling factor is negative
I don´t think, i will test strict invariance.
- General comments on my code - did i do this right?
- Should i test i.e. the strong invariance model against the configural model or against the weak invariance model?
- I´m not sure if i should use the marker variable apporach oder the fixed factor mean@0 / @1 approach for supplying a scale to my factors?
- If i use the marker variable appoach- when i set the first order factor interecepts equal (model 5), how do i prevent lavaan from giving a mean of zero to the factor? (that seems to be the lavaan-default) Should i use std.lv = FALSE and fix every other latent to zero? I get an error on model 5 (please see below)
- How do i handle single-indicator items? I can´t test any invariance for them, so they are the same for both groups anyway? I´ve fixed them to 10% of the observed variables´ variance (whole sample). Or should i estimate the variance for group A / group B seperatly?
"Error in getModifier(rhs[[2L]]) :
lavaan ERROR: can not parse modifier:cNANA"
####################################################
# Code for Configural model / lavaan 0.5-18
####################################################
model.configural<-'
#measurement model
lata =~ c(NA, NA)*F09_a + c(a11,a12)*F09_a + c(a21,a22)*F09_b + c(a31,a32)*F09_c
latb =~ c(NA, NA)*F10_a + c(b11,b12)*F10_a + c(b21,b22)*F10_b + c(b31,b32)*F10_c
latc =~ c(NA, NA)*F10_d + c(c11,c12)*F10_d + c(c21,c22)*F10_e
lat1 =~ c(NA, NA)*latc + c(l1,l2)*latc + (l3,l4)*lata + (l5,l6)*latb
lat2 =~ c(NA, NA)*F12_a + c(d11,d12)*F12_a + c(d21,d22)*F12_b
lat3 =~ c(NA, NA)*F12_d + c(e11,e12)*F12_d + c(e21,e22)*F12_e
lat4 =~ c(1,1)*F12_c
lat5 =~ c(1,1)*F12_g
lat6 =~ c(1,1)*F12_f
#single-indicator errorterm variances
F12_c ~~ 0.1581*F12_c
F12_f ~~ 0.1246*F12_f
F12_g ~~ 0.1068*F12_g
# latent means (fixed to zero in both groups until strong invariance)
a ~ c(0,0)*1
b ~ c(0,0)*1
c ~ c(0,0)*1
lat1 ~ c(0,0)*1
lat2 ~ c(0,0)*1
lat3 ~ c(0,0)*1
lat4 ~ c(0,0)*1
lat5 ~ c(0,0)*1
lat6 ~ c(0,0)*1
#latent variances (fixed to zero in both groups until strong invariance)
lata ~ c(1,1)*lata
latb ~ c(1,1)*latb
latc ~ c(1,1)*latc
lat1 ~~ c(1,1)*lat1
lat2 ~~ c(1,1)*lat2
lat3 ~~ c(1,1)*lat3
lat4 ~~ c(1,1)*lat4
lat5 ~~ c(1,1)*lat5
lat6 ~~ c(1,1)*lat6
'
lavaan.fit_configural<-cfa(model.configural, data=datensatz, group="gender")
survey.fit_configural<-lavaan.survey(lavaan.fit_configural, svy.df)
summary(survey.fit_configural,fit.measures=TRUE,standardized=TRUE)
"Error in getModifier(rhs[[2L]]) :
lavaan ERROR: can not parse modifier:cNANA"
Hi Terrance, i hope i´m not asking too much, but could you have a second look on this? I tried to make myself clear, how i should specify my model to test multigroup invariance with the second order factor (lat1) and reference group scaling. Especially with model 4 and 5 (strong invariance) i´m not completely sure. best regards, Niels #----------------------------------------------------------------------------------------------------------------------------------- Multigroup Invariance (reference group method) |
|||
Modell 1 | parameter | Group A | Group B |
configural model | |||
Item loadings | free | free | |
Item intercepts | free | free | |
second-order loadings | free | free | |
first order factor means | 0 | 0 | |
first order factor variance | 1 | 1 | |
second-order-factor mean | 0 | 0 | |
second-order-factor variance | 1 | 1 | |
Modell 2 | parameter | Group A | Group B |
weak 1 model | |||
Item loadings | = | = | |
Item intercepts | free | free | |
second-order loadings | free | free | |
first order factor means | 0 | 0 | |
first order factor variance | 1 | free | |
second-order-factor mean | 0 | 0 | |
second-order-factor variance | 1 | 1 (or also free?) | |
Modell 3 | parameter | Group A | Group B |
weak 2 model | |||
Item loadings | = | = | |
Item intercepts | free | free | |
second-order loadings | = | = | |
first order factor means | 0 | 0 | |
first order factor variance | 1 | free | |
second-order-factor mean | 0 | 0 | |
second-order-factor variance | 1 | free | |
Modell 4 | parameter | Group A | Group B |
strong 1 model | |||
Item loadings | = | = | |
Item intercepts | = | = | |
second-order loadings | = | = | |
first order factor means | 0 | free | |
first order factor variance | 1 | free | |
second-order-factor mean | 0 | 0 | |
second-order-factor variance | 1 | free | |
Modell 5 | parameter | Group A | Group B |
strong 2 model | |||
Item loadings | = | = | |
Item intercepts | = | = | |
second-order loadings | = | = | |
first order factor means | 0 | 0 | |
first order factor variance | 1 | free | |
second-order-factor mean | 0 | 0 | |
second-order-factor variance | 1 | free |
I don't understand why the latent variances for group 2 need to be freed in the weak invariance model. What is accomplished by doing this?
Am 29.10.2020 um 11:49 schrieb Julia X <studen...@gmail.com>:
Hi Niels,
--
You received this message because you are subscribed to a topic in the Google Groups "lavaan" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/lavaan/i3ysXhrbgPU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to lavaan+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lavaan/46f895a2-d6ce-452f-96b7-8076ca4302efn%40googlegroups.com.