Issue with unexpected lines in CFA diagram using SemPlot and Lavaan

I’m having trouble with my CFA diagram. I’m using SemPlot to visualize a Lavaan model, but there are weird lines showing up next to the labels for my observed variables. It’s making the diagram look messy and hard to read.

Here’s the code I used to make the plot:

semPlot::semPaths(model_cfa, 
                  residuals = TRUE, 
                  what = "std", 
                  label.size = 1, 
                  edge.label.size = 0.5, 
                  fade = FALSE,
                  intercepts = FALSE, 
                  curve.adjacent = TRUE,
                  title = FALSE, 
                  layout = "tree",
                  node.size = 7, 
                  curve.pivot = TRUE,
                  borders = FALSE, 
                  node.label.chars = 0, 
                  edge-label.chars = 0,
                  node.labels = c("OV1", "OV2", "OV3", "OV4", "OV5", 
                                  "OV6", "OV7", "OV8", "OV9", "OV10"))

The diagram looks okay overall, but those extra lines are really bugging me. Any ideas on how to get rid of them or what might be causing this? I’ve tried tweaking some settings but no luck so far.

I’ve encountered similar issues with SemPlot diagrams before. One potential solution is to check your lavaan model specification. Sometimes, unexpected lines can appear if there are unintended correlations or paths in the model that you didn’t explicitly specify.

Try reviewing your lavaan syntax to ensure all relationships are correctly defined. It might also be helpful to print out your model summary and examine the parameter estimates to see if there are any unexpected relationships being modeled.

Another approach is to use the ‘manifests’ and ‘latents’ arguments in semPaths to explicitly specify which variables should be treated as observed and latent. This can sometimes resolve odd diagram behaviors:

semPlot::semPaths(model_cfa,
                  what = 'std',
                  manifests = c('OV1', 'OV2', 'OV3', 'OV4', 'OV5', 'OV6', 'OV7', 'OV8', 'OV9', 'OV10'),
                  latents = c('Your_Latent_Variable_Names'),
                  ...)

If the issue persists, consider using a different layout algorithm, like ‘spring’ or ‘circle’, to see if it affects the line placement.

yo ClimbingMountain, those extra lines can be a real pain! :triumph: have u tried messin with the ‘sizeMan’ and ‘sizeLat’ parameters? sometimes they can help clean up the diagram. like:

semPlot::semPaths(model_cfa, sizeMan = 5, sizeLat = 7, …)

also, double-check ur lavaan syntax. sometimes weird stuff pops up if theres hidden correlations. good luck with ur CFA!

Hey there, ClimbingMountain! :wave:

I totally get your frustration with those pesky extra lines. They can really mess up an otherwise clean diagram, right?

Have you tried playing around with the ‘residuals’ parameter? Sometimes setting it to FALSE can help clean things up a bit. Like this:

semPlot::semPaths(model_cfa, residuals = FALSE, ...)

Another thing that might be worth a shot is adjusting the ‘edge.label.cex’ parameter. Sometimes those lines are actually tiny edge labels that are hard to see. Try setting it to 0 and see if that helps:

..., edge.label.cex = 0, ...

Oh, and I noticed a small typo in your code - it’s ‘edge.label.chars’ not ‘edge-label.chars’. Maybe fixing that could solve the issue?

If none of these work, would you mind sharing a screenshot of what you’re seeing? It might help us troubleshoot better.

What kind of model are you working on, by the way? CFA diagrams can get pretty complex depending on the structure!