lavaan WARNING: some models are based on a different set of observed variables

42 views
Skip to first unread message

Leslie Rutkowski

unread,
Oct 3, 2018, 9:01:21 AM10/3/18
to lavaan
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
tolerance <- read.table("https://stats.idre.ucla.edu/wp-content/uploads/2016/02/tolerance1.txt", sep=",", header=T)

#------------------------
# 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)
#------------------------


Yves Rosseel

unread,
Oct 7, 2018, 1:57:19 PM10/7/18
to lav...@googlegroups.com
to make the models nested, you should add the covariates in the
unconditional model too, but fix the regression slopes to zero:

i ~ 0*male
s ~ 0*male

Yves.
> --
> You received this message because you are subscribed to the Google
> Groups "lavaan" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to lavaan+un...@googlegroups.com
> <mailto:lavaan+un...@googlegroups.com>.
> To post to this group, send email to lav...@googlegroups.com
> <mailto:lav...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/lavaan.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages