Moderator in LGC

55 views
Skip to first unread message

constanze

unread,
Jun 5, 2020, 5:11:36 AM6/5/20
to lavaan
Hi everyone, 

I fitted a growth mixture model on my data across 15 time points. According to the fit indices a 3 class model seems to be the best way to go. Yet, only 2 of the 3 classes are of interest. Now I would like to add several predictors with class membership as a moderator (M; dummy coded).  Unfortunately, I can't really figure out how to implement the moderator. For now, I did it the following way, but I am pretty sure this is not correct (the code is presented in an condensed form )

base<- ' i =~ 1*TP_1 + .... + 1*TP_15
         s
=~ 0*TP_1 + .... + 14*TP_15

#residual variance
TP_1~~r*
TP_1
...
TP_15~~
r*TP_15

#autocorrelated
TP_1~~s*TP_2
...
TP_14~~s*TP_15

# intercept & slope
i~ M*pred.1 + M*pred.2 + M*pred.3
s~ M*pred.1 + M*pred.2 + M*pred.3

'


I've been looking for answers on the group already, hope I haven't missed something, but it seems they deal with slightly different things, and I can't work out how to apply it to my own model.

Thanks you very much. 

Terrence Jorgensen

unread,
Jun 5, 2020, 6:29:07 AM6/5/20
to lavaan
I would like to add several predictors with class membership as a moderator (M; dummy coded). 

lavaan ?model.syntax is not a ?formula object, for which asterisks are used very differently.  You need to include the lower-order effects, and specify a product term with the colon operator.

i~ M + pred.1 + pred.2 + pred.3 + M:pred.1 + M:pred.2 + M:pred.3

Terrence D. Jorgensen
Assistant Professor, Methods and Statistics
Research Institute for Child Development and Education, the University of Amsterdam
 

constanze

unread,
Jun 5, 2020, 7:06:38 AM6/5/20
to lavaan
Dear Terrence, 

thanks a lot for the speedy reply and the information. 

I fitted it accordingly, but it  seems there are problems with the predictor gender. 

                         Age          2   48 numeric   1    0  47.5416667 1.670195e+02    0     
18               Gender          3   48  factor      1    0          NA           NA    2  0|1
19             Duration          4   48 numeric   1    0 113.7916667 1.631349e+04    0     
20            class:Age     317   48 numeric   1    0  61.8333333 1.412652e+03     0     
21***      class:Gender  318    0 logical      1    0          NA           NA    0     
22       class:Duration    319   48 numeric  1    0 128.2916667 1.635310e+04    0     


Further, I do fit different so called "predictor families" to avoid the problem of multicollinearity. I am doing this, by including all predictors at once setting them at 0 (variance and covariance structure is already present). Then in several models I regress each predictor family solely on the intercept and the slope. 

Unfortunately, it seems that some predictor families show too little variance, or do I interpret the error message the wrong way? 

Error in chol.default(S) : 
  the leading minor of order 34 is not positive definite
In addition: Warning message:
In computeOmega(Sigma.hat = Sigma.hat, Mu.hat = Mu.hat, lavsamplestats = lavsamplestats,  :
  lav_model_gradient: Sigma.hat is not positive definite

Thanks again, and all the best, 
Constanze 

Message has been deleted

constanze

unread,
Jun 8, 2020, 8:56:05 AM6/8/20
to lavaan
Hi again, 

thank you very much for the help concerning the moderator implementation. Unfortunately, I get a several different error messages. I went through older post in this group, and as far as I understood it, as long as lavaan has to handle an exogenous binary predictor/ moderator, such as gender or class membership in my case as well, one does not need to specifically specify this during model fit. (moderator and gender are numeric, defined by 0/1)

M_3 <- growth(m.3, data=data, missing = "fiml", estimator = "mlr",check.gradient = FALSE) 

Error in chol.default(S) :
  the leading minor of order 34 is not positive definite
In addition: There were 21 warnings (use warnings() to see them)
> use warnings(M_3)
Error: unexpected symbol in "use warnings"

I would really appreciate help both on how to specify the fit appropriately and avoid the error message. 

Thank you very much. 

All the best, 

Constanze 

Patrick (Malone Quantitative)

unread,
Jun 8, 2020, 9:01:11 AM6/8/20
to lav...@googlegroups.com
The error is from taking "use warnings" too literally!

Try a line with just

warnings()

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/lavaan/72f103ff-4de8-45f5-a8d4-2b48081404fco%40googlegroups.com.


--
Patrick S. Malone, Ph.D., Malone Quantitative
NEW Service Models: http://malonequantitative.com

He/Him/His

Patrick (Malone Quantitative)

unread,
Jun 8, 2020, 9:01:53 AM6/8/20
to lav...@googlegroups.com
Sorry, just the second error. But it still might help.
Message has been deleted

constanze

unread,
Jun 8, 2020, 9:05:50 AM6/8/20
to lavaan
I am sinking into the ground, this is quiet embarrassing... Thank you nevertheless!!

Unfortunately, this is what I have to face now: 

1: In names(out)[1L] <- NAME :
  number of items to replace is not a multiple of replacement length Error in cat("1: In names(out)[1L] <- NAME :\n  number of items to replace is not a multiple of replacement length",  : 
  argument 2 (type 'S4') cannot be handled by 'cat'

Any thoughts? 

Thanks to every 1 or 2 cents on that concern. 
To unsubscribe from this group and stop receiving emails from it, send an email to lav...@googlegroups.com.


--
Patrick S. Malone, Ph.D., Malone Quantitative
NEW Service Models: http://malonequantitative.com

He/Him/His
Reply all
Reply to author
Forward
0 new messages