How to define a latent variable by substracting two other latent variables in SEM

117 views
Skip to first unread message

Solène Frileux

unread,
Aug 4, 2022, 5:40:25 AM8/4/22
to lavaan
Dear all,

I would like to write a SEM model in which a latent variable corresponds to the substraction of two others latent variables, as follows :

Model1    <- ' a =~ z1 + z2 + z3 + z4
                        b  =~ z5 + z6 + z7 + z8
                        c  =~ a - b '

z1 to z8 are z-scores of tests results

Is it possible to use lavaan to define such a model ?

Do you know how to write it ?

Right now I have the following error message : 
"Error in lav_syntax_parse_rhs(rhs = rhs.formula[[2L]], op = op) :
  lavaan ERROR: I'm confused parsing this line: -ab"

Thanks a lot

Edward Rigdon

unread,
Aug 4, 2022, 9:42:37 AM8/4/22
to lav...@googlegroups.com
Solene--
     If you want to create a model where variable c is the difference between variables a and b, you will need to create c as a dummy factor (with no variables loading on it, and then use a and b to predict c (not load on it) and give c zero residual variance. Something like this:

Model1    <- '   a =~ z1 + z2 + z3 + z4
                        b  =~ z5 + z6 + z7 + z8
                        c  =~ 0*z1
                        c ~ 1*a + -1*b
                         c ~~ 0*c '

The single ~ says that a and b predict c. The double ~~ for dependent variable c refers to c's residual variance. You might try using a different observed variable to not load on c.
--Ed Rigdon


--
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/367393ea-89dd-4c3b-812b-fd73d6e81a4dn%40googlegroups.com.

Solène Frileux

unread,
Aug 10, 2022, 11:24:54 AM8/10/22
to lav...@googlegroups.com
Dear Edward,

Thank you so much for your answer, it is very clear.
Best,

Solène
Solène Frileux Nadal


You received this message because you are subscribed to a topic in the Google Groups "lavaan" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/lavaan/O8ZsQgNK9YM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to lavaan+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lavaan/CAHxMgedu866i9AWwoodP81%2Bz2NdC%3DFARZYK9-CQpOSRpN1hJNQ%40mail.gmail.com.

Michael Zyphur

unread,
Aug 11, 2022, 3:25:44 AM8/11/22
to lavaan
That's a fun solution Ed!

Another approach would be to residualize as per latent difference score/latent change score models:

a ~ 1*b
a ~~ 0*a
c =~ 1*a

Here, c is what's left after differencing with b, because a ~ 1*b is the same as a - b, which is the basis for all the latent difference score/latent change score models.

If anyone is interested, in my upcoming Longitudinal SEM seminar in R, I'm covering a similar approach in the cross-lagged panel model case. Check it out at Instats now -- it's filling up fast though, so get in quick!


Best wishes
Mike

Solène Frileux

unread,
Sep 12, 2022, 8:59:16 AM9/12/22
to lav...@googlegroups.com
Dear Michael,

Sorry for my delayed answer, I am reading your message right now and it is very interesting as well. I will try this solution and come back to you if I have any questions.
Thanks a lot and have a good day,

Solène



Solène Frileux

unread,
Sep 21, 2022, 11:15:18 AM9/21/22
to lav...@googlegroups.com
Dear Edward,

I am coming back to this subject since I have been experiencing composite models since last time, with cSEM for instance.
What do you think concerning  this specific case of subtraction (where c is defined by a-b, a and b being constructs) , would you rather recommend using a composite variable for c or staying on your method ?
I am having some troubles defining substractions within composite models as well.
Thanks a lot,

Solène


Le jeu. 4 août 2022 à 15:42, Edward Rigdon <edward...@gmail.com> a écrit :
You received this message because you are subscribed to a topic in the Google Groups "lavaan" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/lavaan/O8ZsQgNK9YM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to lavaan+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lavaan/CAHxMgedu866i9AWwoodP81%2Bz2NdC%3DFARZYK9-CQpOSRpN1hJNQ%40mail.gmail.com.

Edward Rigdon

unread,
Sep 21, 2022, 4:51:47 PM9/21/22
to lav...@googlegroups.com
     I don't know what you will gain either way. We can infer the variance of the difference from the variance and covariances of the original variables, and we can also infer the relationship of the difference to any other variable based on that variable's relationships to the original variables. Modeling all of that won't tell you anything new, though it might be convenient, say, to have lavaan derive some standard errors for you.
     Yes, the original variables likely will be different if they are modeled as composites rather than as common factors, and so then the difference will probably be different, too. It depends on your goals and philosophy whetehr the difference is "good" or "bad." 
--Ed Rigdon

Solène Frileux

unread,
Sep 22, 2022, 8:30:05 AM9/22/22
to lav...@googlegroups.com
Thanks a lot for your advice.

The solution you reckoned 

Model1    <- '   a =~ z1 + z2 + z3 + z4
                        b  =~ z5 + z6 + z7 + z8
                        c  =~ 0*z1
                        c ~ 1*a + -1*b
                         c ~~ 0*c '

works perfectly well.

I wish you a pleasant day,


Solène 


Solène Frileux

unread,
Oct 7, 2022, 11:01:21 AM10/7/22
to lav...@googlegroups.com
Dear Edward,

In this example, when one creates c as a dummy factor (with no variables loading on it), does the variable that does not load on c has to be quoted in the model ?
Because when I use another variable than z1 (used in your example), the model fails.
Indeed, I wanted to use a random variable, that is not used at all in the regressions or correlations, to not load on c.
What do you think ?
Thanks a lot,

Solène


Le jeu. 4 août 2022 à 15:42, Edward Rigdon <edward...@gmail.com> a écrit :
You received this message because you are subscribed to a topic in the Google Groups "lavaan" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/lavaan/O8ZsQgNK9YM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to lavaan+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lavaan/CAHxMgedu866i9AWwoodP81%2Bz2NdC%3DFARZYK9-CQpOSRpN1hJNQ%40mail.gmail.com.

Edward Rigdon

unread,
Oct 7, 2022, 3:13:13 PM10/7/22
to lav...@googlegroups.com
Solene--
You would not want to use a variable that is not otherwise used in your model. Doing that causes that other variable to be one of the observed variables represented in the empirical and model-implied covariance matrices--but the model would say that the variable is orthogonal to everything else in the model, which is probably far from true. Re-using an observed variable, or using no variable as in Keith's example, changes nothing about the data in your model. All you are trying to do here is to tell lavaan to add a new unobserved variable to its internal list. If there were directly a list of unobserved variables, then you could just add it there. But lavaan infers the list of unobserved variables from the model syntax.

I suppose one could argue that it might be good practice to declare all of your common factors in this way, at the start of your syntax--
'
# Unobserved common factors
A + B + C + ... =~0
...
'
so that a reader would have a clear idea, before getting bogged down reading syntax. This might be useful in a textbook or tutorial piece.
--Ed Rigdon




Keith Markus

unread,
Oct 8, 2022, 2:59:21 PM10/8/22
to lavaan
Solene,
I am redirecting back to the original thread.  You asked about analyzing z scores.  As I am sure you are aware, a correlation matrix is a covariance matrix of z scores.  However, there is an important difference.  In a covariance matrix, there is sampling error down the main diagonal.  In a correlation matrix, this is not true, the values are fixed by definition.  I cannot locate it at the moment but I believe that Robert Cudek described this issue in one of his articles and also at one time had SEM software with built in features to apply the required constraints to correctly analyze a correlation matrix.  So, it is possible to correctly analyze z scores if need be but it seems to me that it is much easier to analyze raw scores and not have to worry about imposing the required constraints.

Keith
------------------------
Keith A. Markus
John Jay College of Criminal Justice, CUNY
http://jjcweb.jjay.cuny.edu/kmarkus
Frontiers of Test Validity Theory: Measurement, Causation and Meaning.
http://www.routledge.com/books/details/9781841692203/

Solène Frileux

unread,
Oct 19, 2022, 4:58:10 AM10/19/22
to lav...@googlegroups.com
Thanks a lot Ed, it is really clear now.

I have another question about absolute values inside the model syntax, but will open another question on the forum then .

Best,

Solène Frileux 


Solène Frileux

unread,
Oct 19, 2022, 5:00:36 AM10/19/22
to lav...@googlegroups.com
Thanks a lot for all your explanation, they really helped me.

Do you know whether it is possible to declare absolute values inside the syntax model ?

For instance : 

' cog_obj =~ sqrt(x^2) '

Indeed, it does not work that way and I have not found a solution for it on the forum.

Thanks a lot,

Solène




--
You received this message because you are subscribed to a topic in the Google Groups "lavaan" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/lavaan/O8ZsQgNK9YM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to lavaan+un...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages