如何解释 lavaan 生成的模型拟合指数(在 R 中)?型号规格有问题?

机器算法验证 r 模拟 拟合优度 结构方程建模 路径模型
2022-03-28 13:53:34

我正在尝试在 R 中使用 Lavaan 复制路径分析 SEM 模型,并且对它给出的关于模型拟合统计的结果感到非常困惑。

代码如下:

#Import Package
library(lavaan)

#Input Correlation Matrix
sigma <- matrix(c(1.00, -0.03,  0.39, -0.05, -0.08,
                 -0.03,  1.00,  0.07, -0.23, -0.16,
                  0.39,  0.07,  1.00, -0.13, -0.29,
                 -0.05, -0.23, -0.13,  1.00,  0.34,
                 -0.08, -0.16 ,-0.29,  0.34,  1.00), nr=5, byrow=TRUE)
rownames(sigma) <-c("Exercise", "Hardiness", "Fitness", "Stress", "Illness")
colnames(sigma) <-c("Exercise", "Hardiness", "Fitness", "Stress", "Illness")

#Create Covariance Matrix
sdevs <-c(66.5, 3.8, 18.4, 6.7, 624.8)
covmax <- cor2cov(sigma, sdevs)
as.matrix(covmax)

#Specify Model 
mymodel<-'Illness ~ Exercise + Fitness
Illness ~ Hardiness + Stress
Fitness ~ Exercise + Hardiness 
Stress ~ Exercise + Hardiness + Fitness 
Exercise ~~ Exercise 
Hardiness ~~ Hardiness 
Exercise ~~ Hardiness'

#Fit the model with the covariance matrix
N = 363
fit.path <-sem(mymodel,sample.cov=covmax, sample.nobs=N, fixed.x=FALSE)

#Summary of the model fit
summary(fit.path, fit.measures = TRUE)

我得到的输出如下:

 lavaan (0.5-12) converged normally after  93 iterations

 Number of observations                         37300

 Estimator                                         ML
 Minimum Function Test Statistic                0.000
 Degrees of freedom                                 0
 P-value (Chi-square)                           1.000

 Model test baseline model:

 Minimum Function Test Statistic            16594.387
 Degrees of freedom                                10
 P-value                                        0.000

 Full model versus baseline model:

 Comparative Fit Index (CFI)                    1.000
 Tucker-Lewis Index (TLI)                       1.000

 Loglikelihood and Information Criteria:

 Loglikelihood user model (H0)             -882379.005
 Loglikelihood unrestricted model (H1)     -882379.005

 Number of free parameters                         15
 Akaike (AIC)                              1764788.009
 Bayesian (BIC)                            1764915.910
 Sample-size adjusted Bayesian (BIC)       1764868.240

 Root Mean Square Error of Approximation:

 RMSEA                                          0.000
 90 Percent Confidence Interval          0.000  0.000
 P-value RMSEA <= 0.05                          1.000

 Standardized Root Mean Square Residual:

 SRMR                                           0.000

 Parameter estimates:

 Information                                 Expected
 Standard Errors                             Standard

                Estimate  Std.err  Z-value  P(>|z|)
 Regressions:
 Illness ~
 Exercise          0.318    0.048    6.640    0.000
 Fitness          -8.835    0.174  -50.737    0.000
 Hardiness       -12.146    0.793  -15.321    0.000
 Stress           27.125    0.451   60.079    0.000
 Fitness ~
 Exercise          0.109    0.001   82.602    0.000
 Hardiness         0.396    0.023   17.211    0.000
 Stress ~
 Exercise         -0.001    0.001   -2.614    0.009
 Hardiness        -0.393    0.009  -44.332    0.000
 Fitness          -0.040    0.002  -19.953    0.000

 Covariances:
 Exercise ~~
 Hardiness        -7.581    1.309   -5.791    0.000

 Variances:
 Exercise       4422.131   32.381
 Hardiness        14.440    0.106
 Illness       318744.406 2334.012
 Fitness         284.796    2.085
 Stress           41.921    0.307

这些是我的问题:

  • 为什么卡方说没有自由度?
  • 为什么 p 值正好是 1?为什么 CFI 和 TLI 正好是 1?
  • 为什么 RMSEA 为 0?

  • 我需要做些什么来模拟一个更逼真的模型,它不会人为地“完美”地出现?

  • 跟型号规格有关系吗?
1个回答

似乎这是一个模型,其中(几乎)所有内容都在其他所有内容上回归。

您的模型中有 5 个变量。这意味着你有 10 个协方差。

你有 10 个参数。

模型的df等于(协方差数)-(参数数)。这是零。该模型被描述为饱和,并且没有测试任何东西。因为它没有测试任何东西,所以拟合指数都是完美的。(如果您查看拟合指数的公式,这将是有意义的 - 零卡方应该为您提供这些拟合指数)。

模拟模型是什么意思?如果您不希望完美匹配,请添加一些约束。通常,一约束为零。

所以是的,它与模型规范有关。这是一个用 SEM 测试的不寻常模型,但如果这是您想要测试的模型,那就是您的模型。如果你想让它更可测试,你需要添加一个变量,它是一个变量的可能原因,而不是其他变量的可能原因。例如,社会支持可能会影响压力,但不应(直接)影响疾病,也许不会影响其他因素。如果您添加社会支持,并将仅社会支持的箭头指向压力,您将为模型添加 6 个协方差,但仅添加 1 个 df。因此,您的模型将具有 5 df,并且拟合将不再完美。