我正在尝试向(semPlot 1.1.2)提供一个 lavaan.mi 对象(使用runMI()
semTools 0.5-2 的 SEM 建模多重估算数据。 )。semPaths()
这样做会返回错误:
Error in (function (classes, fdef, mtable) :
unable to find an inherited method for function ‘semPlotModel_S4’ for signature ‘"lavaan.mi"’
这在GitHub 上被标记为“问题” ,但我将不胜感激建议的解决方法。这是一个例子:
# Libraries
library(mice)
library(semTools)
library(lavaan)
library(semPlot)
# Create DF
HSMiss <- HolzingerSwineford1939[,paste("x", 1:9, sep="")]
randomMiss <- rbinom(prod(dim(HSMiss)), 1, 0.1)
randomMiss <- matrix(as.logical(randomMiss), nrow=nrow(HSMiss))
HSMiss[randomMiss] <- NA
# Specify model
HS.model <- ' visual =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
speed =~ x7 + x8 + x9 '
# Fit the model
model_fit <- runMI(HS.model,
data=HSMiss,
m = 5,
miPackage="mice",
fun="sem")
# Attempt to create SEM plot
semPaths(model_fit)