我该如何处理 Lavaan 错误:“lavaan 模型语法中的语法错误”?

格式化

我是第一次尝试做CFA。Lavaan 给出以下错误。

Error in lavParseModelString(model) : 
  lavaan ERROR: syntax error in lavaan model syntax

我的代码看起来像这样简化:

mycfa <- 'Construct =~ A +
                       B +
                       C +
                       D +
                       E +
                       F +
                       G +
                       H
                       '
fit <- cfa(mycfa, data = mydataframe)

我猜我的模型中有回归依赖和协方差,否则 lavaan 会输出吗?有没有人给我一个关于如何进行的提示。

辛瓦尔

这很简单:

library(lavaan)
#> This is lavaan 0.6-8
#> lavaan is FREE software! Please report any bugs.

mydataframe <- HolzingerSwineford1939[, paste0("x",1:8)]
names(mydataframe) <- LETTERS[1:8]

mycfa <- 'Construct =~ A +
                       B +
                       C +
                       D +
                       E +
                       F +
                       G +
                       H
                       '
fit <- cfa(mycfa, data = mydataframe)
summary(fit)
#> lavaan 0.6-8 ended normally after 30 iterations
#> 
#>   Estimator                                         ML
#>   Optimization method                           NLMINB
#>   Number of model parameters                        16
#>                                                       
#>   Number of observations                           301
#>                                                       
#> Model Test User Model:
#>                                                       
#>   Test statistic                               209.040
#>   Degrees of freedom                                20
#>   P-value (Chi-square)                           0.000
#> 
#> Parameter Estimates:
#> 
#>   Standard errors                             Standard
#>   Information                                 Expected
#>   Information saturated (h1) model          Structured
#> 
#> Latent Variables:
#>                    Estimate  Std.Err  z-value  P(>|z|)
#>   Construct =~                                        
#>     A                 1.000                           
#>     B                 0.505    0.157    3.215    0.001
#>     C                 0.476    0.151    3.161    0.002
#>     D                 2.006    0.276    7.273    0.000
#>     E                 2.203    0.304    7.258    0.000
#>     F                 1.862    0.257    7.250    0.000
#>     G                 0.367    0.141    2.593    0.010
#>     H                 0.371    0.133    2.801    0.005
#> 
#> Variances:
#>                    Estimate  Std.Err  z-value  P(>|z|)
#>    .A                 1.115    0.093   11.926    0.000
#>    .B                 1.320    0.108   12.195    0.000
#>    .C                 1.220    0.100   12.198    0.000
#>    .D                 0.370    0.047    7.804    0.000
#>    .E                 0.476    0.059    8.087    0.000
#>    .F                 0.352    0.043    8.230    0.000
#>    .G                 1.150    0.094   12.224    0.000
#>    .H                 0.988    0.081   12.215    0.000
#>     Construct         0.244    0.067    3.640    0.000

reprex 包( v2.0.0 )于 2021 年 4 月 23 日创建

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章