R `update()`公式未按预期工作

laawzig2  于 2023-07-31  发布在  其他
关注(0)|答案(1)|浏览(105)

我正在尝试从semTools更新measEq.syntax函数生成的模型公式。我提供了一个由measEq.syntax工作的基本模型。有时候我想改变模型语法中的一些东西,为此我使用了update函数,但它不像以前那样工作:

HS.model <- ' visual  =~ x1 + x2 + x3
              textual =~ x4 + x5 + x6
              speed   =~ x7 + x8 + x9
              general =~ visual + textual + speed'

library(semTools)
#> Loading required package: lavaan
#> This is lavaan 0.6-15
#> lavaan is FREE software! Please report any bugs.
#> 
#> ###############################################################################
#> This is semTools 0.5-6
#> All users of R (or SEM) are invited to submit functions or ideas for functions.
#> ###############################################################################
syntax.config <- measEq.syntax(configural.model = HS.model,
                               data = HolzingerSwineford1939,
                               ID.fac = "ul",
                               group = "school")
fixMeans.c <- '
textual ~ c(0, 0)*1
speed ~ c(0, 0)*1
general ~ c(0, 0)*1
'
syntax.config <- update(syntax.config, change.syntax = fixMeans.c)
#> Error in nValues > 1L && nValues != nBlocks: 'length = 3' in coercion to 'logical(1)'

字符串
创建于2023-07-11,使用reprex v2.0.2

new9mtju

new9mtju1#

我向一个semTools软件包开发人员报告了这个问题,他们纠正了软件包错误。然后我刚刚安装了最新的GitHub版本(即0.5-6.922版本),问题就解决了。

remotes::install_github("simsem/semTools/semTools") #version 0.5-6.922
HS.model <- ' visual  =~ x1 + x2 + x3
              textual =~ x4 + x5 + x6
              speed   =~ x7 + x8 + x9
              general =~ visual + textual + speed'

library(semTools)
syntax.config <- measEq.syntax(configural.model = HS.model,
                               data = HolzingerSwineford1939,
                               ID.fac = "ul",
                               group = "school")
fixMeans.c <- '
textual ~ c(0, 0)*1
speed ~ c(0, 0)*1
general ~ c(0, 0)*1
'
syntax.config <- update(syntax.config, change.syntax = fixMeans.c)

字符串
创建于2023-07-15带有reprex v2.0.2.9000

相关问题