2017-06-17 285 views
2

我想知道如何使用semPlotlavaan的SEM模型設置不同節點的不同節點。semPaths - lavaan不同大小的節點SEM

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給

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

enter image description here

不過,我想這enter image description here

+1

不是最佳的,但你可以手動改變尺寸:分配semPlot:單曲< - semPaths(...',然後改變節點的高度和寬度,s $ graphAttributes $ Nodes $ height [1:3] < - 8; s $ graphAttributes $ Nodes $ width [1:3] < - 8; plot( s)' – user20650

回答

1

我這樣做是爲了我的論文

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") 

完全醜陋但結果很好!

完整的SEM分析是在這裏https://github.com/pachamaltese/thesis

我也寫了一個完整的教程分爲兩個部分爲我的博客:http://pacha.hk/tag/structural-equation-modelling-sem.html

+0

你好,你的代碼似乎沒有與這個例子一起工作嗎?你能提供'onefactormeasures'從哪裏來?謝謝 – giacomo