Troubleshooting CFA diagram: Unwanted lines and overlapping values

I’m having trouble with my CFA path diagram in R. The output looks messy. There are weird black lines going through the boxes for observed variables. Also, the residual values are printed on top of each other, making it hard to read.

I used the semPlot package and the semPaths function to create this diagram. Here’s a simplified version of my code:

semPaths(my_model, 
  style = "tree", 
  residuals = TRUE, 
  whatLabels = "std",
  sizeMan = 8, 
  sizeLat = 11)

Does anyone know how to clean this up? I want to get rid of those lines and fix the overlapping numbers. Any tips would be really helpful!

I’ve encountered similar issues with CFA diagrams in R. The semPlot package can be tricky sometimes. Here are a few suggestions that might help:

For the unwanted lines, try adding ‘nCharNodes = 0’ to your semPaths function. This often eliminates those pesky lines through the boxes.

To address the overlapping residuals, you can adjust their position using ‘residuals = TRUE, residScale = 10’. Play around with the residScale value until you find a good fit.

Also, consider using ‘layout = “tree2”’ instead of ‘style = “tree”’. It often produces a cleaner layout.

Lastly, if you’re still having trouble, the lavaan package with its lavaanPlot function can be a good alternative for creating CFA diagrams. It tends to produce cleaner results out of the box.

Hope this helps you clean up your diagram!

Hey there, Ethan85! Those CFA diagrams can be a real pain sometimes, right? :sweat_smile:

I’m curious, have you tried tweaking the ‘edge.label.cex’ parameter in your semPaths function? It might help with those overlapping residuals. Something like this could work:

semPaths(my_model, 
  style = "tree", 
  residuals = TRUE, 
  whatLabels = "std",
  sizeMan = 8, 
  sizeLat = 11,
  edge.label.cex = 0.5)

The smaller value for edge.label.cex should shrink those pesky residual numbers.

As for those weird black lines, have you considered using a different layout? The ‘circle’ style sometimes works better for me:

semPaths(my_model, layout = "circle", ...)

Just a thought! What other packages have you tried for CFA diagrams? I’m always on the lookout for better options. Maybe there’s something out there that could solve both our problems! :thinking:

yo ethan, i feel ur pain with those messy diagrams! have u tried the ‘rotation’ parameter in semPaths? It can sometimes help with overlapping stuff. Like:

semPaths(my_model, rotation = 2, …)

might do the trick. for those weird lines, try ‘curve = 1.5’ to make em curve instead of going straight thru. good luck mate!