I would like to calculate the correlation between latent and observed variables using lavaan in R.
Here's a simple example of what I'm trying to do. We have some data and a lavaan model.
data(bfi)
names(bfi) <- tolower(names(bfi))
mod <- "
agree =~ a1 + a2 + a3 + a4 + a5
consc =~ c1 + c2 + c3 + c4 + c5
age ~~ agree
age ~~ consc
"
lavaan::cfa(mod, bfi)
agree
is a latent variable with 5 indicators. Age is an observed variable and I want to get the correlation between the observed variable age
and the latent variable agree
. The general way of specify covariance in lavaan is by putting ~~
in between the variables. But this doesn't seem to work when one of the variables is observed.
When I run the above, I get the following error:
Error in lav_model(lavpartable = lavpartable, representation = lavoptions$representation, :
lavaan ERROR: parameter is not defined: agree ~~ age
In other SEM software, such as Amos, you'd just draw a double headed arrow between the latent and observed variable.
How do you include correlations between latent and observed variables in lavaan?