在R中绘制简单的中介图

在R中绘制简单的中介图

本文介绍了在R中绘制简单的中介图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种(最好是简单易懂的)方式来绘制具有R中的调解系数的简单路径图?

我一直在寻找 DiagrammeR 软件包,但这看起来像是一个过大的杀伤力(老实说,我未能弄清楚如何绘制剧情).

我知道的其他选项是

解决方案

虽然

对于可重现的示例,请使用:

 库(图)数据<-c(0,'.47 *'",0,0、0、0,'.36 *'",'.33 *(.16)'",0)M<-矩阵(nrow = 3,ncol = 3,byrow = TRUE,data = data)情节<-情节(M,pos = c(1,2),name = c(数学自我效能感",数学能力",数学专业兴趣"),box.type ="rect",box.size = 0.12,box.prop = 0.5,curve = 0) 

Is there a (preferably easy and straightforward) way to draw simple path diagrams with mediation coefficients in R?

I've been looking to DiagrammeR package but that looks like an overkill (and to be honest I failed to figure out how to make a plot).

Other options I know of are Dia or Inkscape but those require manual positioning, connecting paths etc.

mediation package has a plot option but that draws bootstrapped CIs and what I'd like to achieve is a simple path with coefficients like this one:

解决方案

While @baptiste solution might work as well, I was looking for a publishable format.

Function plotmat from library(diagram) is the one that got me the closest to my example:

For a reproducible example use:

library(diagram)
data <- c(0, "'.47*'", 0,
          0, 0, 0,
          "'.36*'", "'.33* (.16)'", 0)
M<- matrix (nrow=3, ncol=3, byrow = TRUE, data=data)
plot<- plotmat (M, pos=c(1,2),
                name= c( "Math self-efficacy","Math ability", "Interest in the math major"),
                box.type = "rect", box.size = 0.12, box.prop=0.5,  curve=0)

这篇关于在R中绘制简单的中介图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 05:22