0
$\begingroup$

I am running a model using CFA (laavan package) in R. Three-factor model fits the data well (for both female and male groups), the correlation between latent variables are different though, I'd like to constrain the correlation? Does anyone know the code for this? I know it is possible through Mplus but I am not sure how to do this in R. I would really appreciate it if you can help.

Thanks,

$\endgroup$

2 Answers 2

1
$\begingroup$

Constraining a parameter to equality across groups can be accomplished by giving them the same label:

https://lavaan.ugent.be/tutorial/groups.html

To ensure you are constraining the correlation (not unstandardized covariance), it is easiest if you fit the multigroup cfa() using the argument std.lv=TRUE, so that the factor variances are fixed to 1 for identification. That means the estimated factor covariances are correlations.

Providing your syntax when you post a question like this would allow responders to provide an exact solution. Here is an example using the data from the ?cfa help page:

HS.model <- ' visual  =~ x1 + x2 + x3
              textual =~ x4 + x5 + x6
              speed   =~ x7 + x8 + x9
  visual  ~~ c(cor.vt, cor.vt)*textual
  visual  ~~ c(cor.vs, cor.vs)*speed
  textual ~~ c(cor.ts, cor.ts)*speed
'
fit <- cfa(HS.model, data = HolzingerSwineford1939,
           group = "school", std.lv = TRUE)
## notice identical correlation estimates for 2 groups
summary(fit)
$\endgroup$
0
$\begingroup$

Yes fixing latent variable correlations is possible using R. See the code below where I do this with a simulated data set using the lavaan package's sem function. Model 1 allows correlations to be freely estimated, and model 2 fixes the latent variable correlation to 0.7.

# Package(s)
library(lavaan)

# Population Model
population.model <- ' f1 =~ 1*x1 + 1*x2 + 1*x3 + 1*x4 + 1*x5 + 1*x6
                      f2 =~ 1*x7 + 1*x8 + 1*x9 + 1*x10 + 1*x11 + 1*x12
                      
                      f1 ~~ 1*f1
                      f2 ~~ 1*f2
                    '
# Simulating Data
set.seed(1234)
myData <- simulateData(population.model,sample.nobs=1000)

# Model where the correlation between f1 and f2 is freely estimated
model1 <- ' f1 =~ x1 + x2 + x3 + x4 + x5 + x6
             f2 =~ x7 + x8 + x9 + x10 + x11 + x12
                    
             f1 ~~ 1*f1
             f2 ~~ 1*f2
             
             f1 ~~ 0.7*f2
'
# Model where the correlation between f1 and f2 is fixed to 0.7
model2 <- ' f1 =~ x1 + x2 + x3 + x4 + x5 + x6
             f2 =~ x7 + x8 + x9 + x10 + x11 + x12
                    
             f1 ~~ 1*f1
             f2 ~~ 1*f2
             
             f1 ~~ 0.7*f2
'

# Fitting models to the simulated data
fit1 <- sem(model1, data=myData)
fit2 <- sem(model2, data=myData)

# Results 
summary(fit1)
summary(fit2)
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.