matlab残差协方差检验,DiagrammeR - create_graph和残差协方差

我发现了一个非常棒的post,关于使用DiagrammeR转换lavaan输出。但是,这篇文章中使用的DiagrammeR版本是0.6版本,在尝试复制版本0.8(http://rich-iannone.github.io/DiagrammeR/docs.html)的代码时遇到了一些麻烦。

随着一些非常小的变化,代码就像这样

先用lavaan填写SEM

library("stringr")

library("lavaan")

library("DiagrammeR")

library("dplyr")

library("semPlot")

model

# latent variables

ind60 =~ x1 + x2 + x3

dem60 =~ y1 + y2 + y3 + y4

dem65 =~ y5 + y6 + y7 + y8

# regressions

dem60 ~ ind60

dem65 ~ ind60 + dem60

# residual covariances

y1 ~~ y5

y2 ~~ y4 + y6

y3 ~~ y7

y4 ~~ y8

y6 ~~ y8

'

fit

semPaths(fit, intercept = FALSE, whatLabel = "est",

residuals = FALSE, exoCov = FALSE)现在这是post中提出的代码

paths %

parameterestimates %>%

select(lhs, op, rhs, est)

# Latent variables are left-hand side of "=~" lines

latent %

filter(op == "=~") %>%

select(nodes = lhs) %>%

distinct %>%

mutate(shape = "circle")

# Manifest variables are not latent variables

`%not_in%`

manifest %

filter(op != "~1", lhs %not_in% latent$nodes) %>%

select(nodes = lhs) %>%

distinct %>%

mutate(shape = "square")

# Nodes are prepared

node_set

# Edges will be labeled by the parameter estimates

all_paths %

filter(op != "~1") %>%

mutate(label = round(est, 2)) %>%

select(-est)

# Factor loadings are the paths in the "=~" lines

loadings %

filter(op == "=~") %>%

mutate(edge_from = lhs, edge_to = rhs, style = "dashed") %>%

select(edge_from, edge_to, style, label)

regressions %

filter(op == "~") %>%

rename(edge_to = lhs, edge_from = rhs) %>%

mutate(style = "solid") %>%

select(edge_from, edge_to, style, label)

edge_set

错误来到这里

# Combine edges and nodes

my_graph

nodes = node_set,

edges_df = edge_set,

graph_attrs = c("ranksep = 1"))

# We can plot the graph directly

graphviz_render(my_graph)在DiagrammeR的文档中,据说“重命名了graphviz_graph和graphviz_render到create_graph和render_graph”。

但是,进行此更改不起作用

my_graph

nodes = node_set,

edges_df = edge_set,

graph_attrs = c("ranksep = 1"))任何想法为什么?

其他问题。在这篇文章中,这段代码似乎没有绘制残差协方差。任何想法如何绘制DiagrammeR的残差共变量?

谢谢

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值