Dataframe as model syntax (CFA)

12 views
Skip to first unread message

Chiel Mues

unread,
Jan 8, 2020, 10:08:39 AM1/8/20
to lavaan
Say I have a dataframe such as this:

Factor:        Item:
Factor_A     Item_1
Factor_A     Item_2
Factor_B     Item_3
Factor_B     Item_4

So just the factor, and the name of the Item that belongs to that factor.
Is it possible to feed this into lavaan as model syntax?

Mauricio Garnier-Villarreal

unread,
Jan 8, 2020, 11:40:17 AM1/8/20
to lavaan
If it is for a CFA, stating which item goes in which factor, yes, you can do something like this

dd <- data.frame(factor=rep(c("f1","f2","f3"),4), item=paste0("it_",1:12))
dd
paste(dd$factor, dd$item, sep="=~") ### lavaan will take this as syntax

Reply all
Reply to author
Forward
0 new messages