Latent Growth Model

147 views
Skip to first unread message

Kaloyan Mitev

unread,
Jun 21, 2022, 4:11:07 AM6/21/22
to lavaan
Hi everyone,

I am trying to run a latent growth model using data from three time-points. However, I also have three different groups (1 control and 2 experimental). 

I've seen it is possible to do a multi group analysis with lavaan, however, when I try to do this with my code I seem to get an error message

I use the following code:

model <- 'i =~ 1*Food_waste + 1*Food_waste_2 + 1*Food_waste_3
s =~ 0*Food_waste + 1*Food_waste_2 + 2*Food_waste_3'

fit1 <- growth(model, data = data, missing='fiml', group = Condition)

I get this message: Error in lavaan::lavaan(model = model, data = data, group = Condition,  : 
  object 'Condition' not found

If I use an identical code but just have condition in quotation marks (group = "Condition") I get another error message: Error in `vec_equal()`:
! Can't combine `..1` <character> and `..2` <double>. 

I would be very grateful for any tips or advice on how to resolve this!

Thank you so much!

Best
Kaloyan

ryan chesnut

unread,
Jun 21, 2022, 9:36:09 AM6/21/22
to lavaan
The grouping variable does need to be in quotation marks. I think this error is saying that you have both character and numeric data. I've had this happen before when using the haven package to import data from SPSS. Not sure if that is the root cause here, but one potential solution would be to save your data in a .csv or .xlsx file, which should by default switch everything to numeric, and import that data file.
Reply all
Reply to author
Forward
0 new messages