- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 R 绘制 sem 路径。
我正在使用来自 Mplus 的 OUT 文件和 semPaths {semPLot}。
显然它似乎有效,但我想删除一些潜在变量,但我不知道如何。
我正在使用以下语法:
从 Mplus 输出:https://www.dropbox.com/s/vo3oa5fqp7wydlg/questedMOD2.out?dl=0
outfile1 <- "questedMOD.out"
```
semPaths(outfile1,what="est", intercepts=FALSE, rotation=4, edge.color="black", sizeMan=5, esize=TRUE, structural="TRUE", layout="tree2", nCharNodes=0, intStyle="multi" )
最佳答案
可能有一种更简单的方法来执行此操作(如果这样做是明智的则忽略)- 一种方法是在绘图之前从对象中删除节点。
使用问题中的 Mplus 示例 Rotate Edges in semPaths/qgraph
library(qgraph)
library(semPlot)
library(MplusAutomation)
# This downloads an output file from Mplus examples
download.file("http://www.statmodel.com/usersguide/chap5/ex5.8.out",
outfile <- tempfile(fileext = ".out"))
# Unadjusted plot
s <- semPaths(outfile, intercepts = FALSE)
在上面对 semPaths
的调用中,outfile
属于 character
类,因此行(靠近 代码的开头) semPaths
)
if (!"semPlotModel" %in% class(object))
object <- do.call(semPlotModel, c(list(object), modelOpts))
从 semPlot:::semPlotModel.mplus.model(outfile)
返回对象。这是 "semPlotModel"
类。
所以想法是先创建这个对象,修改它,然后将这个对象传递给semPaths
。
# Call semPlotModel on your Mplus file
obj <- semPlot:::semPlotModel.mplus.model(outfile)
# obj <- do.call(semPlotModel, list(outfile)) # this is more general / not just for Mplus
# Remove one factor (F1) from object@Pars - need to check lhs and rhs columns
idx <- apply(obj@Pars[c("lhs", "rhs")], 1, function(i) any(grepl("F1", i)))
obj@Pars <- obj@Pars[!idx, ]
class(obj)
obj
现在属于 "semPlotModel"
类,可以直接传递给 semPaths
s <- semPaths(obj, intercepts = FALSE)
您可以使用str(s)
来查看此返回对象的结构。
关于r - 在 semPaths {semPlot} 中排除节点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26214531/
我想为带有 lavaan 的 SEM 模型使用 semPlot 为不同的节点设置不同的大小。 library(lavaan) library(semPlot) model <- ' # measu
我正在尝试使用 R 绘制 sem 路径。 我正在使用来自 Mplus 的 OUT 文件和 semPaths {semPLot}。 显然它似乎有效,但我想删除一些潜在变量,但我不知道如何。 我正在使用以
当我使用 sempaths(包 semplots)绘制 SEM 模型时,我无法摆脱路径。该路径看起来是两个观察变量(V1_1 和 V1_2)之间的协方差。 这是我的模型和输出图的代码: #specif
我是一名优秀的程序员,十分优秀!