Test multiple models with different observed

8 views
Skip to first unread message

Fernando Cesario

unread,
Jun 18, 2019, 10:00:16 AM6/18/19
to lavaan
Hello all,
there is an lavaan tools to test multiple models with multiple observed?
Suppose I  have a simple model:
A ~  B + C
C ~ B

but for B + C I have two observed variables, that is B1 and B2; and C1 and C2. I do not want use latent, but instead test all combinations of observed variables.
There is a tool by lavaan to test it, for instance a loop. Or I must construct all models by hand one by one.
model1 <- "A  ~ B1 + C1
C1 ~ B1"
model2 <- "A ~ B2 + C1
C1 ~ B1"
model3 <- "A ~ B1 + C2
C1 ~B1"
and so on... 

Thanks in advance
Fernando 

Terrence Jorgensen

unread,
Jun 19, 2019, 7:44:39 AM6/19/19
to lavaan
but for B + C I have two observed variables, that is B1 and B2; and C1 and C2. I do not want use latent, but instead test all combinations of observed variables.

In one model?  

A  ~ B1 + B2 + C1 + C2
C1 + C2 ~ B1 + B2

 
model1 <- "A  ~ B1 + C1
C1 ~ B1"
model2 <- "A ~ B2 + C1
C1 ~ B1"
model3 <- "A ~ B1 + C2
C1 ~B1"
and so on...  

You can't compare models that are fit to different variables.  But if this is really what you want, you can use paste() in for-loop(s) to construct the model syntax.

for (BB in c("B1","B2")) {
 
for (CC in c("C1","C2")) {
    model
<- paste("A ~", BB, "+", CC, "\n", CC, "~", BB)
    fit
<- sem(model, data, ...)
 
}
}

Terrence D. Jorgensen
Assistant Professor, Methods and Statistics
Research Institute for Child Development and Education, the University of Amsterdam


Reply all
Reply to author
Forward
0 new messages