Syntax for correlation between residual variances of a latent factor and an observed variable

117 views
Skip to first unread message

Rob R

unread,
Jul 9, 2019, 3:07:40 PM7/9/19
to lavaan
Hi all,

I am looking for any advice on how to include correlated residuals in a model, such that the residual variance of a latent variable is correlated with one of an observed measure. 

I am aware that the double tilda (i.e. ~~) can be used to include residual covariances in a model. However, when I attempt to correlate a latent factor from the model with an observed measure that loads on to a different latent factor, I encounter an error.

Here is some sample syntax, and the exact error message that is received when running the code:

HS.model <- ' visual  =~ x1 + x2 + x3
                       textual =~ x4 + x5 + x6
                       speed   =~ x7 + x8 + x9
                       visual ~~ x4 '
fit <- cfa(HS.model, data=HolzingerSwineford1939)

Error in lav_model(lavpartable = lavpartable, lavoptions = lavoptions,  : 
  lavaan ERROR: parameter is not defined: visual ~~ x4

If anybody is able to point out or provide advice on what syntax can be used to add the correlation between residual variances of a latent factor and an observed variable, your input would be very highly appreciated.

Thanks, 
Rob

Andy Supple

unread,
Jul 9, 2019, 3:35:14 PM7/9/19
to lav...@googlegroups.com
Hi Rob,

I'm not sure what you're trying to do makes sense. Given that visual is a latent variable, correlating it to another item for another factor is odd. If you wanted to specify them as related, you probably would just add a cross-loading so that x4 loads on visual as well. In addition, in the syntax you posted, VISUAL wouldn't have a residual because there isn't anything predicting it. Typically one would be attempting to correlate the uniquenesses/residuals of the items in a measurement model. 

--
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 post to this group, send email to lav...@googlegroups.com.
Visit this group at https://groups.google.com/group/lavaan.
To view this discussion on the web visit https://groups.google.com/d/msgid/lavaan/b383df83-1802-4041-9729-711c215eb3c9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--

Rob R

unread,
Jul 9, 2019, 4:28:09 PM7/9/19
to lavaan
Hi Andy,

Thanks for your response and your explanation. Your advice on using a cross-loading is well-taken, however I would like to provide a more complete picture of the kind of model I am aiming to construct, to see whether or not any additional insight on the matter can be gleaned. 

I now understand that, at least with the example I provided, there wouldn't be a residual for the latent factor ('visual'). However, I believe that the error still occurs even when the latent factor in question is indeed being predicted by something. To get more precise, I am attempting to construct a model similar to the one seen below (source is below as well). This model is reported as including a correlation between the residual variances of Extraversion (latent factor) and attractiveness (observed variable). Is there any apparent reason as to why a measurement model such as this one could include a correlation between residual variances of a latent factor and an observed factor in a way that makes sense?

Model with ~~.png


Thanks again for your help,
Rob

Source for model:

Anusic, I., Schimmack, U., Pinkus, R. T., & Lockwood, P. (2009). The nature and structure of correlations among Big Five ratings: The halo-alpha-beta model. Journal of Personality and Social Psychology, 97(6), 1142–1156. https://doi.org/10.1037/a0017159

On Tuesday, July 9, 2019 at 3:35:14 PM UTC-4, Andy Supple wrote:
Hi Rob,

I'm not sure what you're trying to do makes sense. Given that visual is a latent variable, correlating it to another item for another factor is odd. If you wanted to specify them as related, you probably would just add a cross-loading so that x4 loads on visual as well. In addition, in the syntax you posted, VISUAL wouldn't have a residual because there isn't anything predicting it. Typically one would be attempting to correlate the uniquenesses/residuals of the items in a measurement model. 

On Tue, Jul 9, 2019 at 3:07 PM Rob R <redf...@gmail.com> wrote:
Hi all,

I am looking for any advice on how to include correlated residuals in a model, such that the residual variance of a latent variable is correlated with one of an observed measure. 

I am aware that the double tilda (i.e. ~~) can be used to include residual covariances in a model. However, when I attempt to correlate a latent factor from the model with an observed measure that loads on to a different latent factor, I encounter an error.

Here is some sample syntax, and the exact error message that is received when running the code:

HS.model <- ' visual  =~ x1 + x2 + x3
                       textual =~ x4 + x5 + x6
                       speed   =~ x7 + x8 + x9
                       visual ~~ x4 '
fit <- cfa(HS.model, data=HolzingerSwineford1939)

Error in lav_model(lavpartable = lavpartable, lavoptions = lavoptions,  : 
  lavaan ERROR: parameter is not defined: visual ~~ x4

If anybody is able to point out or provide advice on what syntax can be used to add the correlation between residual variances of a latent factor and an observed variable, your input would be very highly appreciated.

Thanks, 
Rob

--
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 lav...@googlegroups.com.

To post to this group, send email to lav...@googlegroups.com.
Visit this group at https://groups.google.com/group/lavaan.
To view this discussion on the web visit https://groups.google.com/d/msgid/lavaan/b383df83-1802-4041-9729-711c215eb3c9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Edward Rigdon

unread,
Jul 9, 2019, 6:04:22 PM7/9/19
to lav...@googlegroups.com
Rob--
    You *can* do this, but I also have the graest reservations about the model you picture, because I believe there will be numerous equivalent models, making it hard to make a case for this model in comparison.
     However, the key to doing what you want is to convert the observed variable residual to a factor, then correlate the new factor with the other residual variance. Here is your syntax: 
HS.model <- ' visual  =~ x1 + x2 + x3
                       textual =~ x4 + x5 + x6
                       speed   =~ x7 + x8 + x9
                       visual ~~ x4 '
Create a new factor named RES. Force the residual variance of x4 to 0. Let x4 load on RES, with a fixed loading of 1. Make RES orthogonal to all other factors, as a residual should be. Then RES must be the residual variance of x4. Then enable the covariance:
HS.model <- ' visual  =~ x1 + x2 + x3
                       textual =~ x4 + x5 + x6
                       speed   =~ x7 + x8 + x9
                       RES =~ 1*x4                         # create the new factor with loading 1 on x4
                       x4 ~~ 0*x4                             # fix x4's residual variance to 0
                      textual + speed ~~ 0*RES      # Res orthogonal to other factors
                       visual ~~ RES '

Run the model with visual ~~ 0*RES, instead, and results should be identical to those for the original model for the HS9 data. 
You may need to provide a starting value for the variance of RES, or maybe not.
 --Ed Rigdon



To unsubscribe from this group and stop receiving emails from it, send an email to lavaan+un...@googlegroups.com.

To post to this group, send email to lav...@googlegroups.com.
Visit this group at https://groups.google.com/group/lavaan.

Rob R

unread,
Jul 9, 2019, 8:37:51 PM7/9/19
to lavaan
Hi Ed,

After applying your advice to my own syntax, the model is able to be fit with the desired parameter included. 

Thank you very much for your help on this topic!

Rob

Reply all
Reply to author
Forward
0 new messages