I want to reduce typing-load in lavaan.

Imagine that you have 50 manisfest variables: var1, var2, var3, ... var50. In Mplus it is possible to assign a multitude of variables to a factor with the minus '-' sign like this:

Factor BY var1-var50;

Basically saying that Factor is defined by all 50 variables.

Is there a similar way to define the factor in lavaan? It seems that I need to state all 50 variable names:

model <- ' factor =~ var1 + var2 + var3 + var4 and so on...
有帮助吗?

解决方案

Try this :

lvmodel <- 
paste('factor',paste(paste0('var',1:50),collapse='+'),sep='=~')
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top