sem.mi还是runMI

sem.mi还是runMI,r,imputation,structural-equation-model,ordinal-indicator,R,Imputation,Structural Equation Model,Ordinal Indicator,我正在Lavan(使用ordinal)进行路径分析,并希望使用插补数据 但无论是单独输入数据并使用runMI,还是将原始数据作为sem.mi命令的一部分输入,我都会得到相同的错误: Error: evaluation nested too deeply: infinite recursion / options(expressions=)? Error during wrapup: evaluation nested too deeply: infinite recursion / option

我正在Lavan(使用ordinal)进行路径分析,并希望使用插补数据

但无论是单独输入数据并使用runMI,还是将原始数据作为sem.mi命令的一部分输入,我都会得到相同的错误:

Error: evaluation nested too deeply: infinite recursion / options(expressions=)?
Error during wrapup: evaluation nested too deeply: infinite recursion / options(expressions=)?
如果我跑步: 选项(表达式=100000) 错误消息更改为:error:protect():保护堆栈溢出

我试图改变

--max-ppsize=500000 
但是在命令行中,我无法访问rstudio.exe(说明:系统找不到指定的路径,-即使我仔细检查了路径:

C:\Program Files\RStudio\bin\rstudio.exe --max-ppsize=500000)
我该如何使用插补数据进行分析,或将其作为路径分析估计的一部分进行插补

这是我的密码:

imp <- mice(dat2,m=5,print=F)
imputedData <- NULL
for(i in 1:5) {
  imputedData[[i]] <- complete(x=imp, action=i, include=FALSE) 
}
model5 <- 'ceadiff ~ mompa + cdpea + momabhx
mompa ~ b1*peadiff + c*momabhx + cdpea + b2*mommhpsi
peadiff ~ a1*momabhx + mommhpsi
cdpea ~ momabhx + mommhpsi
mommhpsi ~ a2*momabhx
peadiff ~~ cdpea
direct := c
indirect1 := a1 * b1
indirect1 := a2 * b2
total    := c + (a1 * b1) + (a2 * b2)'

fit5 <- runMI(model5, data = imputedData, fun="sem", ordered = "mompa")
summary(fit5, standardized = TRUE, fit = TRUE, ci = T)

# or: 

fit5 <- sem.mi(model5, data = dat2, m=5, ordered = "mompa")
summary(fit5, standardized = TRUE, fit = TRUE, ci = T)

您的代码工作正常。中的问题由您正在使用的
lavan
semTools
版本给出。 按照Terrence D.Jorgensen(semTools的作者之一)的建议,启动R的新会话,并按如下方式重新安装两个软件包:

install.packages("lavaan", repos = "http://www.da.ugent.be", type = "source")
# if necessary:    install.packages("devtools")
devtools::install_github("simsem/semTools/semTools")
现在,命令如下:

fit5 <- runMI(model5, data = imputedData, fun="sem", ordered = "mompa")
summary(fit5, standardized = TRUE, ci = T)

请分享您的数据,发布输出
dput(dat2)
。好的,发布在正文中。非常感谢您查看它!唯一的问题是它现在没有打印任何模型拟合度量值。如果我添加参数“chi”打印错误:未知参数“chi”。有没有打印任何适合指数的方法?我找不到任何东西…谢谢,我遵循了你的建议,一切都很有魅力!!有史以来最好的除夕礼物!!我也想获得适合指数,在semTools的文档中有关于如何获得这些指数的建议,但是,所有在我尝试过的命令中,返回“error:unused/unknown argument”或“error:unable-find-inherited-methods”作为签名“lavan.mi”。有没有办法获得卡方、df、cfi/tli和rmsea?我在runMI中尝试过参数“chi”=“all”,以及lavInspect“fit”或fitmasures、lavListInspect“什么“=拟合、fitMeasures、fitMeasures、fitMeasuresMX和其他我能想到(或在线看到)的组合,但没有结果。谢谢!如果我使用以下代码,我会得到拟合指数:anova(fit5,Indexs=TRUE),但那不是mplus版本,对吗?@MarishkaUsacheva你说得对。在新的
semTools
中,许多事情都不能正常工作。我建议启动一个新的R会话,使用
setwd
更改工作目录,安装
semTools
的cran版本,并使用
inspect
命令,如下代码所示:。让我知道它是否有效。非常感谢您的时间!我很快就会尝试它,并会让您知道结果!我昨天确实尝试从CRAN直接安装semTools,但它不起作用,但我确信我所做的与您建议的不同,所以我很兴奋!!
install.packages("lavaan", repos = "http://www.da.ugent.be", type = "source")
# if necessary:    install.packages("devtools")
devtools::install_github("simsem/semTools/semTools")
fit5 <- runMI(model5, data = imputedData, fun="sem", ordered = "mompa")
summary(fit5, standardized = TRUE, ci = T)
Rubin's (1987) rules were used to pool point and SE estimates across 5 imputed data sets, and to calculate degrees of freedom for each parameter's t test and CI.
lavaan.mi object based on 5 imputed data sets. 
See class?lavaan.mi help page for available methods. 

Convergence information:
The model converged on 5 imputed data sets 


Parameter Estimates:

  Information                                 Expected
  Information saturated (h1) model   
  Standard Errors                           Robust.sem

Regressions:
                   Estimate  Std.Err        t       df  P(>|z|) ci.lower ci.upper   Std.lv  Std.all
  ceadiff ~                                                                                        
    mompa             0.473    0.165    2.863 2016.256    0.004    0.149    0.797    0.473    0.223
    cdpea             0.137    0.038    3.589 2507.509    0.000    0.062    0.212    0.137    0.157
    momabhx          -0.251    0.302   -0.831      Inf    0.406   -0.843    0.341   -0.251   -0.059
  mompa ~                                                                                          
    peadiff   (b1)    0.108    0.035    3.091      Inf    0.002    0.039    0.176    0.108    0.245
    momabhx    (c)    0.548    0.165    3.324      Inf    0.001    0.225    0.871    0.548    0.273
    cdpea            -0.048    0.031   -1.525      Inf    0.127   -0.109    0.014   -0.048   -0.116
    mommhpsi  (b2)   -0.022    0.009   -2.365   61.332    0.021   -0.040   -0.003   -0.022   -0.192
 ...