3

I want to set different sizes for different nodes using semPlot for a SEM model with lavaan.

library(lavaan)
library(semPlot)

model <- '
  # measurement model
    ind60 =~ x1 + x2 + x3
    dem60 =~ y1 + y2 + y3 + y4
    dem65 =~ y5 + y6 + y7 + y8
  # regressions
    dem60 ~ ind60
    dem65 ~ ind60 + dem60
  # residual correlations
    y1 ~~ y5
    y2 ~~ y4 + y6
    y3 ~~ y7
    y4 ~~ y8
    y6 ~~ y8
'
fit <- sem(model, data=PoliticalDemocracy)

semPlot gives:

semPaths(fit, whatLabels="std", style="lisrel", exoCov = T, curvePivot = TRUE, sizeMan = 3, sizeInt = 5, 
     residuals=F) 

enter image description here

However, I would like this: enter image description here

L. Bakker
  • 147
  • 1
  • 13
giac
  • 4,261
  • 5
  • 30
  • 59
  • 2
    not optimal, but you can alter the sizes manually : assign semPlot: `s <- semPaths(...` , and then alter node hieght and width , `s$graphAttributes$Nodes$height[1:3] <- 8 ; s$graphAttributes$Nodes$width[1:3] <- 8 ; plot(s)` – user20650 Jun 17 '17 at 15:35

1 Answers1

3

I did this for my thesis

semPaths(fit, style="lisrel", 
        whatLabels = "std", edge.label.cex = .6, node.label.cex = .6, 
        label.prop=0.9, edge.label.color = "black", rotation = 4, 
        equalizeManifests = FALSE, optimizeLatRes = TRUE, node.width = 1.5, 
        edge.width = 0.5, shapeMan = "rectangle", shapeLat = "ellipse", 
        shapeInt = "triangle", sizeMan = 4, sizeInt = 2, sizeLat = 4, 
        curve=2, unCol = "#070b8c")

Totally ugly but good result in the end !

The full SEM analysis is here https://github.com/pachamaltese/thesis

I also wrote a full tutorial in two parts for my blog: http://pacha.hk/tag/structural-equation-modelling-sem.html

pachadotdev
  • 3,345
  • 6
  • 33
  • 60
  • 1
    hi, your code does not seem to be working with the example? can you provide where does `onefactormeasures` comes from? thanks – giac Jun 18 '17 at 23:15