T1.CFA <- '
T1 =~
X1.T1 +
X2.T1 +
X3.T1 +
X4.T1 +
X5.T1 +
X6.T1 +
X7.T1 +
X8.T1 +
X9.T1 +
X10.T1 +
X11.T1 +
X12.T1 +
X13.T1 +
X14.T1
'
fitT1.CFA <- cfa(T1.CFA, data=data,
ordered=c( "X1.T1" ,
"X2.T1" ,
"X3.T1" ,
"X4.T1" ,
"X5.T1" ,
"X6.T1" ,
"X7.T1" ,
"X8.T1" ,
"X9.T1" ,
"X10.T1" ,
"X11.T1" ,
"X12.T1" ,
"X13.T1" ,
"X14.T1"))
summary(fitT1.CFA, fit.measures=TRUE, standardized=TRUE)
1: In lav_model_estimate(lavmodel = lavmodel, lavpartable = lavpartable, :
lavaan WARNING: the optimizer warns that a solution has NOT been found!
L.cfa <- '
T1 =~
X1.T1 +
X2.T1 +
X3.T1 +
X4.T1 +
X5.T1 +
X6.T1 +
X7.T1 +
X8.T1 +
X9.T1 +
X10.T1 +
X11.T1 +
X12.T1 +
X13.T1 +
X14.T1
T2 =~
X1.T2 +
X2.T2 +
X3.T2 +
X4.T2 +
X5.T2 +
X6.T2 +
X7.T2 +
X8.T2 +
X9.T2 +
X10.T2 +
X11.T2 +
X12.T2 +
X13.T2 +
X14.T2
T3 =~
X1.T3 +
X2.T3 +
X3.T3 +
X4.T3 +
X5.T3 +
X6.T3 +
X7.T3 +
X8.T3 +
X9.T3 +
X10.T3 +
X11.T3 +
X12.T3 +
X13.T3 +
X14.T3 '
longFacNames <- list(X = c("T1", "T2", "T3"))
# test for longitudinal measurement invariance with help from semTools
test.seq <- list(strong = c("thresholds","loadings","intercepts"),
means = "means",
strict = "residuals")
meq.list <- list()
for (i in 0:length(test.seq)) {
if (i == 0L) {
meq.label <- "configural"
group.equal <- ""
long.equal <- ""
} else {
meq.label <- test.seq[i]
group.equal <- test.seq[1:i]
long.equal <- test.seq[1:i]
}
meq.list[[meq.label]] <- measEq.syntax(configural.model = L.cfa,
data = data,
ordered=c( "X1.T1" ,
"X2.T1" ,
"X3.T1" ,
"X4.T1" ,
"X5.T1" ,
"X6.T1" ,
"X7.T1" ,
"X8.T1" ,
"X9.T1" ,
"X10.T1" ,
"X11.T1" ,
"X12.T1" ,
"X13.T1" ,
"X14.T1" ,
"X1.T2" ,
"X2.T2" ,
"X3.T2" ,
"X4.T2" ,
"X5.T2" ,
"X6.T2" ,
"X7.T2" ,
"X8.T2" ,
"X9.T2" ,
"X10.T2" ,
"X11.T2" ,
"X12.T2" ,
"X13.T2" ,
"X14.T2" ,
"X1.T3" ,
"X2.T3" ,
"X3.T3" ,
"X4.T3" ,
"X5.T3" ,
"X6.T3" ,
"X7.T3" ,
"X8.T3" ,
"X9.T3" ,
"X10.T3" ,
"X11.T3" ,
"X12.T3" ,
"X13.T3" ,
"X14.T3"),
parameterization = "theta",
#ID.fac = "std.lv",
ID.cat = "Mplus",
group = NULL,
#group.equal = NULL,
longFacNames = longFacNames,
long.equal = long.equal,
return.fit = TRUE)
}
compareFit(meq.list)
1) Is my code correct for how to treat dichotomously scored items?
2) Under the Variances heading in the output, there are Estimates but no Standard Errors. What does that mean?
3) What does it mean the below warning message disappeared when I added meanstructure=TRUE, std.lv=TRUE?
lavaan WARNING: the optimizer warns that a solution has NOT been found!
4) When trying to do longitudinal CFA to test for measurement invariance across time, I got these warning messages:1: In lav_samplestats_step2(UNI = FIT, wt = wt, ov.names = ov.names, : lavaan WARNING: correlation between variables X4.T2 and X3.T2 is (nearly) 1.0
2: In lav_model_vcov(lavmodel = lavmodel, lavsamplestats = lavsamplestats, : lavaan WARNING: The variance-covariance matrix of the estimated parameters (vcov) does not appear to be positive definite! The smallest eigenvalue (= -8.874240e-4) is smaller than zero. This may be a symptom that the model is not identified.It only warns that neighboring items at the same measurement occasion are highly correlated in the longitudinal CFA, not in the individual CFA for that measurement occasion. This makes me wonder if it's due to programming errors on my part.
lavInspect(fitT2.CFA, "sampstat")
lavInspect(meq.list[[1]], "sampstat")I'm also wondering if warning 2 (non positive-definite variance-covariance matrix) has to do with the large amount of parameters it's estimating with 3 measurement occasions * 14 items each?
Could this be a numerical integration problem?
Warning 1 was absent in the individual CFA for T2, which makes me wonder if both longitudinal CFA warning messages were a symptom of the same thing
I will be grateful for any advice on what I should be doing differently!
Not sure why that would only happen when setting the first factor loading to 1. What does your summary() output look like when you set std.lv=TRUE? Are the loadings all positive?
Yes, all loadings are positive. Under the Estimate column they are somewhat higher without std.lv=TRUE, and the Std.lv and Std.all columns look identical. When std.lv=TRUE, all 3 columns look identical.
2) Thank you so much for your advice to check the estimated polychoric correlations from the longitudinal model and compare them to the estimates from the Time-2 model. Further, thank you so much for providing such helpful code to run diagnostics! For the Time 2 non-longitudinal CFA, lavInspect(fitT2.CFA, "sampstat"), under$cov, the relation is .960 between the two items implicated in the longitudinal CFA's warning message of a correlation of nearly 1.
For the longitudinal CFA, lavInspect(meq.list[[1]], "sampstat"), the relation was .991.
In both, there are other inter-item correlations of .9, though those two items appear to have the highest correlation. How high is too high? I’m considering item parceling but am unsure of the implications of doing that at just one measurement occasion when testing for longitudinal measurement invariance.
3) With no missing data treatment, the sample size is under 300 at each measurement occasion and is 117 for the longitudinal CFA. Is this too small for a model with 3 measurement occasions and 14 items per measurement occasion?
I would be very grateful for thoughts and advice.
How high is too high?
I’m considering item parceling but am unsure of the implications of doing that at just one measurement occasion when testing for longitudinal measurement invariance.
table(data$X4.T1, data$X3.T1)
table(data$X4.T2, data$X3.T2)
table(data$X4.T3, data$X3.T3)3) With no missing data treatment, the sample size is under 300 at each measurement occasion and is 117 for the longitudinal CFA.
Is this too small for a model with 3 measurement occasions and 14 items per measurement occasion?