alishinski / lavaanPlot

R package for plotting lavaan path models with DiagrammeR
http://alexlishinski.com/lavaanPlot/
39 stars 4 forks source link

remove covariances between exogenous set to 0 #40

Open dpagliaccio opened 2 years ago

dpagliaccio commented 2 years ago

Is it possible to remove edges for covariances between exogenous that have been set to 0, e.g. a ~~ 0*b (showing up as NA when covs=T)

WillemSleegers commented 2 years ago

I have the same question.

alishinski commented 2 years ago

This will be addressed in the coming versions of the package as I continue to develop the new approach which should enable full node and edge customization, more on that here.

For now unfortunately the best I can offer is to use the manual method:

If you need to modify a lavaanPlot diagram to omit some paths, you can always manually modify the diagram specification and get rid of paths you don't want. E.g.:

model <- " wt ~~ disp
  mpg ~ cyl + disp + hp
  qsec ~ disp + hp + wt"

fit <- sem(model, data = mtcars)
plo <- lavaanPlot(model = fit, coefs = TRUE, stand = TRUE, covs = TRUE)

# gives you the diagram specification
plo$x$diagram

# modify that and put into this function
grViz()