Hi all,
I'm putting together an unconditional vs. conditional growth curve model example and the two models - that only differ in terms of the time invariant covariates - produce the "different set of observed variables" error. But there is no missing data on the covariates. And I am dealing with nested models (unconditional is nested within conditional). Also, the sample sizes are the same between the two models. I can't figure out what might be generating this error. When I comment out the covariates, the model fit is identical.
Here is a replicable example:
library(lavaan)
library(reshape2)
#--------------------------
# Using Singer & Willett tolerance
# toward deviant behavior data
#--------------------------
# Wide data
#------------------------
# U-LGCM
ulgcm <- 'i =~ 1*tol11 + 1*tol12 + 1*tol13 + 1*tol14 + 1*tol15
s =~ 0*tol11 + 1*tol12 + 2*tol13 + 3*tol14 + 4*tol15
tol11 ~~ a*tol11
tol12 ~~ a*tol12
tol13 ~~ a*tol13
tol14 ~~ a*tol14
tol15 ~~ a*tol15
'
# Model fit and summary
ulgcm.fit <- growth(ulgcm, data = tolerance)
summary(ulgcm.fit)
#------------------------
#------------------------
# C-LGCM
clgcm <- '# The "growth" model
i =~ 1*tol11 + 1*tol12 + 1*tol13 + 1*tol14 + 1*tol15
s =~ 0*tol11 + 1*tol12 + 2*tol13 + 3*tol14 + 4*tol15
tol11 ~~ a*tol11
tol12 ~~ a*tol12
tol13 ~~ a*tol13
tol14 ~~ a*tol14
tol15 ~~ a*tol15
# Model to predict growth
i ~ male
s ~ male
i ~~ s
'
# Model fit and summary
clgcm.fit <- growth(clgcm, data = tolerance)
summary(clgcm.fit)
# Model comparison
lavTestLRT(ulgcm.fit, clgcm.fit)
#------------------------