I´m testing the capabilities of the new DiagrammeR-package for visualisation of structural equation models.
My goal is, to get a plot like this:
Perhaps I need to find a ressource on how to specify the orientation of edges and nodes, because - with DiagrammeR
- I can only do a plot like this right now:
devtools::install_github('rich-iannone/DiagrammeR')
library('DiagrammeR')
#----------
test<-grViz("
digraph CFA{
# latent variables
node [shape=circle]
latent_a [group='a'];
latent_b [group='b'];
#regressions
latent_a -> latent_b [label='0.279'];
#measurement model for latent a
subgraph A{
node [shape=box]
ind_1;
ind_2;
ind_3;
latent_a -> ind_1 [label='0.636'];
latent_a -> ind_2 [label='0.825'];
latent_a -> ind_3 [label='0.829'];
}
#measurement model for latent b
subgraph B{
node [shape=box]
ind_4 ;
ind_5 ;
latent_b -> ind_4 [label='1.027'];
latent_b -> ind_5 [label='0.626'];
}
#residuals
node [shape=circle]
e1 ;
e4 ;
e5 ;
e6 ;
e1 -> ind_1;
e4 -> ind_4;
e5 -> ind_5;
e6 -> latent_b;
#residual covariances
ind_1 -> ind_2 [dir=both];
}
")
test
I would be thankful for any hints.
PS: Perhaps my DiagrammeR
-Code looks funny. I´ve tried to write it the same way, a model is specified in lavaan. Perhaps there will be a way to translate between both packages in the future. I think, this could be possible.