【发布时间】:2023-01-26 19:49:16
【问题描述】:
我必须运行许多 CFA,并希望在数据框中自动保存特定的输出值,以便稍后将其转换为乳胶表。
具体来说,我使用 lavaan 得到类似这样的输出:
model <- 'y =~ x1 + x2 + x3'
fit <- cfa(model, data)
sum <- summary(fit_os_bi, fit.measures=TRUE, standardized=T)
我设法提取了一些值,例如 p_val <- sum$test$standard$pvalue,但我不知道如何获取 CFI、TLI、RMSEA 和 SRMR。我想我什至错过了正确的搜索词来成功地用谷歌搜索这个问题。
如何从摘要对象访问这些值?如果您能为我提供正确的代码或为我提供解释它的资源,我将不胜感激!
以下是cfa摘要的摘录:
lavaan 0.6-12 ended normally after 42 iterations
Estimator ML
Optimization method NLMINB
Number of model parameters 9
Number of observations 213
Model Test User Model:
Test statistic 1.625
Degrees of freedom 1
P-value (Chi-square) 0.202
User Model versus Baseline Model:
Comparative Fit Index (CFI) 0.997
Tucker-Lewis Index (TLI) 0.983
Root Mean Square Error of Approximation:
RMSEA 0.054
90 Percent confidence interval - lower 0.000
90 Percent confidence interval - upper 0.200
P-value RMSEA <= 0.05 0.315
Standardized Root Mean Square Residual:
SRMR 0.014
我在 R-Studio 的环境检查器中查看了“总和”(我在其中找到了 p 值的位置)并搜索了 lavaan 的文档,但无济于事。
由于我正在寻找的值出现在输出中,我希望它们必须被存储某处在摘要对象中。
【问题讨论】:
-
无法帮助您提供代码,因为未提供数据。你能在你的问题中输入数据吗?
Error in lavaan::lavaan(model = model, data = data, model.type = "cfa", : lavaan ERROR: data is a function; it should be a data.frame