陈涛涛的博客分享 http://blog.sciencenet.cn/u/ttchen86

博文

利用R lavaan包进行通径分析并绘制路径图

已有 11907 次阅读 2020-4-27 23:18 |个人分类:R学习|系统分类:科研笔记| SEM, 结构方程模型

library(tidyverse)

library(agricolae)

library(semPlot)

library(lavaanPlot)

library(lavaan)

data(haynes)


# 结构模型

model <- "

WI ~ FL + MI + ME

"

# FL~~MI

# FL~~ME

# MI~~ME

# MI~~MI

# FL~~FL

# ME~~ME


fit <- sem(model, data = haynes)

tiff(filename = "1.tiff",width = 17.5,height = 17.5,units = "cm",res = 900,compression = "lzw")

semPaths(

  fit,

  what = "stand",

  style = "lisrel",

  whatLabels = "stand",

  layout = "circle2",

  curveAdjacent = TRUE,

  # structural=TRUE,structural

  edge.label.cex = 0.8,

  # exoVar = FALSE,

  #exoCov = FALSE,

  esize  = 2,

  nDigits = 3,

  residuals = TRUE,

  intercepts = TRUE

)

dev.off()

shell.exec(file.path(getwd(),"1.tiff"))


结果如下:(同上篇博文结果基本一致。http://blog.sciencenet.cn/blog-3427939-1230425.html

1.jpg



https://blog.sciencenet.cn/blog-3427939-1230492.html

上一篇:利用R进行通径分析
下一篇:利用R 计算不同时间尺度的Z指数、SPI指数和SPEI指数
收藏 IP: 112.39.82.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (3 个评论)

数据加载中...
扫一扫,分享此博文

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-11-23 00:16

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部