Moderated-Mediation with SEM

123 views
Skip to first unread message

Thomas Trebilco

unread,
Aug 4, 2022, 2:19:57 AM8/4/22
to lavaan
I'm attempting to run the following moderated-mediation model in lavaan


Screenshot 2022-08-04 142548.png

Y is an ordinal outcome variable with two levels. Samples are either classified as 0's or 1's. X, M and W are all continuous/numeric. All variables are observed variables.

After having written and run my code, I get the following output with an error:
fjnw.png
For search engines, the error is: "Error in lav_data_full(data = data, group = group, cluster = cluster, : lavaan ERROR: some variables have no values (only missings) or no variance"

Based on the output, the issue looks to be with the third factor, the interaction between W and M - for some reason I cannot understand it is not being indexed in the model. 

When I check for missing values and variance estimates on this variable, it shows no missing values and shows that it has substantial variance.

wejnw.png

It doesn't matter whether I create this interaction term within lavaan (i.e. "term := W:M") or within R (i.e., "Interaction <- W*M), the same error comes up.

The code I wrote for this can be found here:


Please note that I have intentionally changed the variable names.

Thomas Trebilco

unread,
Aug 4, 2022, 2:35:20 AM8/4/22
to lavaan
I seem to be also getting this same error in a simple moderation model.

Terrence Jorgensen

unread,
Aug 24, 2022, 8:22:39 AM8/24/22
to lavaan
Without data, it will be difficult to track down the problem.  But in your GitHub syntax, you do not add McxWc to the data.frame  ModMed_Data.  Perhaps lavaan does not find the variable?

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

 
Reply all
Reply to author
Forward
0 new messages