Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

semPaths - different size nodes for lavaan SEM

Tags:

graph

r

r-lavaan

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

like image 427
giac Avatar asked Oct 19 '25 14:10

giac


1 Answers

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

like image 67
pachadotdev Avatar answered Oct 21 '25 03:10

pachadotdev