Reputation: 135
How can I calculate the estimate of factor loading for latent variables between different data frames?
I have 3 data frames related to 1 latent variable (the same variables A B C D) but in different intervals.
package (lavaan)
model1 <- 'latent_variable1 =~ A + B + C + D
A~~B'
output1 <- cfa(model1, data=datafram1, std.lv=TRUE)
output2 <- cfa(model1, data=datafram2, std.lv=TRUE)
output3 <- cfa(model1, data=datafram3, std.lv=TRUE)
Now I would like to calculate the difference on the estimate between the 3 latent variables using SEM. Someone could help me?
example:
model<- 'latent_variable1 ~ latent_variable2 ~ latent_variable3'
output4<-sem(model, dataframe =????, std.lv=TRUE)
Upvotes: 1
Views: 352
Reputation: 856
If I understood correctly, your aim is mainly to test the differences on the factor loadings on these 3 datasets. And, in fact, you do not have 3 latent variables, but just one, but applied in 3 different contexts. This is a specific type of the assessment for measurement invariance for latent variable.
So, what you need is:
datafram1$group<-"G1"
datafram2$group<-"G2"
datafram3$group<-"G3"
df<-rbind(datafram1,datafram2)
df<-rbind(df,datafram3)
output1 <- cfa(model1, data=df, std.lv=TRUE, group="group")
This will return 3 outputs, one per group, similar to assessing in the 3 different dataframes.
output2 <- cfa(model1, data=df, std.lv=TRUE, group="group",group.equal="loadings")
anova(output1, output2)
Upvotes: 1