## Specify unidimensional model
# Model syntax
Unidim <- '
empathy =~ sympathetic + empathic + compassionate + softhearted + tender
'
# Fit the model
UnidimModel <- as.character(measEq.syntax(configural.model = Unidim,
data = data,
ordered = c(
"compassionate",
"sympathetic",
"empathic",
"softhearted",
"tender"),
parameterization = "delta",
ID.fac = "auto.fix.first",
ID.cat = "Wu",
group = "SexCode",
group.equal = "configural"))
# Model fit
UnidimFit <- cfa(as.character(UnidimModel),
data = data,
group = "SexCode",
group.label = c("Male", "Female"),
ordered = c(
"compassionate",
"sympathetic",
"empathic",
"softhearted",
"tender"),
test = "Satorra-Bentler")
summary(UnidimFit,
fit.measures = TRUE)
Warning messages:
1: In lav_model_vcov(lavmodel = lavmodel2, lavsamplestats = lavsamplestats, :
lavaan WARNING:
Could not compute standard errors! The information matrix could
not be inverted. This may be a symptom that the model is not
identified.
2: In lav_test_satorra_bentler(lavobject = NULL, lavsamplestats = lavsamplestats, :
lavaan WARNING: could not invert information matrix needed for robust test statistic
Warning message:
In lav_model_vcov(lavmodel = lavmodel2, lavsamplestats = lavsamplestats, :
lavaan WARNING:
The variance-covariance matrix of the estimated parameters (vcov)
does not appear to be positive definite! The smallest eigenvalue
(= 1.027876e-18) is close to zero. This may be a symptom that the
model is not identified
devtools::install_github("simsem/semTools/semTools")
library("semTools")
## Specify unidimensional model
# Model syntax
Unidim <-
'
empathy =~ sympathetic + empathic + compassionate + softhearted + tender
'
# Fit the model specifying that "sympathetic" serves as the marker variable
UnidimModel <- measEq.syntax(configural.model = Unidim,
data = data,
ordered = c(
"compassionate",
"sympathetic",
"empathic",
"softhearted",
"tender"),
parameterization = "delta",
ID.fac = "auto.fix.first",
ID.cat = "Wu",
group = "SexCode",
group.equal = "configural")
# fix an arbitrary threshold of the specified marker variable to zero
UnidimModelUpdated <- update(UnidimModel,
change.syntax = c('sympathetic | 0*t1'))
# Print syntax to see if the syntax changed. I didn't notice any change in my code
cat(mod.metric <- as.character(UnidimModelUpdated))
# Model fit
UnidimFit <- cfa(as.character(UnidimModelUpdated),
data = data,
group = "SexCode",
group.label = c("Male", "Female"),
ordered = c(
"compassionate",
"sympathetic",
"empathic",
"softhearted",
"tender"),
test = "Satorra-Bentler")
# Summary
summary(dddUnidimFit,
fit.measures = TRUE)
> cat(mod.metric <- as.character(UnidimModelUpdated)) # print syntax first
## LOADINGS:
empathy =~ c(1, 1)*sympathetic + c(lambda.1_1.g1, lambda.1_1.g2)*sympathetic
empathy =~ c(NA, NA)*empathic + c(lambda.2_1.g1, lambda.2_1.g2)*empathic
empathy =~ c(NA, NA)*compassionate + c(lambda.3_1.g1, lambda.3_1.g2)*compassionate
empathy =~ c(NA, NA)*softhearted + c(lambda.4_1.g1, lambda.4_1.g2)*softhearted
empathy =~ c(NA, NA)*tender + c(lambda.5_1.g1, lambda.5_1.g2)*tender
## THRESHOLDS:
sympathetic | c(NA, NA)*t1 + c(sympathetic.thr1.g1, sympathetic.thr1.g2)*t1
sympathetic | c(NA, NA)*t2 + c(sympathetic.thr2.g1, sympathetic.thr2.g2)*t2
sympathetic | c(NA, NA)*t3 + c(sympathetic.thr3.g1, sympathetic.thr3.g2)*t3
sympathetic | c(NA, NA)*t4 + c(sympathetic.thr4.g1, sympathetic.thr4.g2)*t4
sympathetic | c(NA, NA)*t5 + c(sympathetic.thr5.g1, sympathetic.thr5.g2)*t5
sympathetic | c(NA, NA)*t6 + c(sympathetic.thr6.g1, sympathetic.thr6.g2)*t6
empathic | c(NA, NA)*t1 + c(empathic.thr1.g1, empathic.thr1.g2)*t1
empathic | c(NA, NA)*t2 + c(empathic.thr2.g1, empathic.thr2.g2)*t2
empathic | c(NA, NA)*t3 + c(empathic.thr3.g1, empathic.thr3.g2)*t3
empathic | c(NA, NA)*t4 + c(empathic.thr4.g1, empathic.thr4.g2)*t4
empathic | c(NA, NA)*t5 + c(empathic.thr5.g1, empathic.thr5.g2)*t5
empathic | c(NA, NA)*t6 + c(empathic.thr6.g1, empathic.thr6.g2)*t6
compassionate | c(NA, NA)*t1 + c(compassionate.thr1.g1, compassionate.thr1.g2)*t1
compassionate | c(NA, NA)*t2 + c(compassionate.thr2.g1, compassionate.thr2.g2)*t2
compassionate | c(NA, NA)*t3 + c(compassionate.thr3.g1, compassionate.thr3.g2)*t3
compassionate | c(NA, NA)*t4 + c(compassionate.thr4.g1, compassionate.thr4.g2)*t4
compassionate | c(NA, NA)*t5 + c(compassionate.thr5.g1, compassionate.thr5.g2)*t5
compassionate | c(NA, NA)*t6 + c(compassionate.thr6.g1, compassionate.thr6.g2)*t6
softhearted | c(NA, NA)*t1 + c(softhearted.thr1.g1, softhearted.thr1.g2)*t1
softhearted | c(NA, NA)*t2 + c(softhearted.thr2.g1, softhearted.thr2.g2)*t2
softhearted | c(NA, NA)*t3 + c(softhearted.thr3.g1, softhearted.thr3.g2)*t3
softhearted | c(NA, NA)*t4 + c(softhearted.thr4.g1, softhearted.thr4.g2)*t4
softhearted | c(NA, NA)*t5 + c(softhearted.thr5.g1, softhearted.thr5.g2)*t5
softhearted | c(NA, NA)*t6 + c(softhearted.thr6.g1, softhearted.thr6.g2)*t6
tender | c(NA, NA)*t1 + c(tender.thr1.g1, tender.thr1.g2)*t1
tender | c(NA, NA)*t2 + c(tender.thr2.g1, tender.thr2.g2)*t2
tender | c(NA, NA)*t3 + c(tender.thr3.g1, tender.thr3.g2)*t3
tender | c(NA, NA)*t4 + c(tender.thr4.g1, tender.thr4.g2)*t4
tender | c(NA, NA)*t5 + c(tender.thr5.g1, tender.thr5.g2)*t5
tender | c(NA, NA)*t6 + c(tender.thr6.g1, tender.thr6.g2)*t6
## INTERCEPTS:
sympathetic ~ c(0, 0)*1 + c(nu.1.g1, nu.1.g2)*1
empathic ~ c(0, 0)*1 + c(nu.2.g1, nu.2.g2)*1
compassionate ~ c(0, 0)*1 + c(nu.3.g1, nu.3.g2)*1
softhearted ~ c(0, 0)*1 + c(nu.4.g1, nu.4.g2)*1
tender ~ c(0, 0)*1 + c(nu.5.g1, nu.5.g2)*1
## SCALING FACTORS:
sympathetic ~*~ c(1, 1)*sympathetic
empathic ~*~ c(1, 1)*empathic
compassionate ~*~ c(1, 1)*compassionate
softhearted ~*~ c(1, 1)*softhearted
tender ~*~ c(1, 1)*tender
## LATENT MEANS/INTERCEPTS:
empathy ~ c(NA, NA)*1 + c(alpha.1.g1, alpha.1.g2)*1
## COMMON-FACTOR VARIANCES:
empathy ~~ c(NA, NA)*empathy + c(psi.1_1.g1, psi.1_1.g2)*empathy
I also could not get the code that you linked in github to work
# fix an arbitrary threshold of the specified marker variable to zero
UnidimModelUpdated <- update(UnidimModel,
change.syntax = c('sympathetic | 0*t1'))
As for my selection of the mark variable method: I want to use the marker variable method because I am unsure whether it is reasonable to assume that the latent factor variances are equal for the groups in my data.
So a data driven identification method seems to be the most principled way to go about making decisions, and the marker variable method appears to offer that.
But the reason it didn't work was a silly bug I just found, where I switched the lhs and rhs of the parameter label (i.e., it was looking to update a parameter 't1 | sympathetic' rather than 'sympathetic | t1'). This is fixed in the latest semTools (0.5-2.925), so your code should work after installing and restarting.
You don't assume that when you use the fixed-factor approach. Those are arbitrary identification constraints, which get released once they are no longer needed (i.e., when loadings are constrained to equality). The estimated variances are not comparable in a configural model just because a reference indicator is used, unless you can somehow verify that the reference indicator is indeed invariant. But by doing that, you will have gone beyond the configural model anyway, and you can draw your inferences about differences in latent variance from a more restrictive model.
--
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/9nvVozLbBng/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/0bd6028b-75e5-4169-8c87-0947eb55aed4o%40googlegroups.com.