r - 如何使用 r 中的 lavaan 包获取 CFA 中因子的相关矩阵和 p 值?
问题描述
我正在使用 r 中的 lavaan 包在我的问卷上运行 CFA。如何获得包含显着性水平数据的因子相关矩阵?(即 p 值)当我使用这条线时,cov2cor(inspect(fit, what = "est")$psi)
我得到了矩阵,但没有得到 p 值。
这是模型的示例代码:
CFA.model <- ' visual =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
speed =~ x7 + x8 + x9 '
fit <- lavaan(CFA.model, data = HolzingerSwineford1939,
auto.var=TRUE, auto.fix.first=TRUE,
auto.cov.lv.x=TRUE)
解决方案
我不会认为 p 值是估计值。它们更像是随机值。这是否提供了您正在寻找的东西?
inspect(fit, what = "test")
$standard
$standard$test
[1] "standard"
$standard$stat
[1] 85.30552
$standard$stat.group
[1] 85.30552
$standard$df
[1] 24
$standard$refdistr
[1] "chisq"
$standard$pvalue
[1] 8.502553e-09
编辑:您正在使用协方差,它们可能不是正态分布的。此外,尚不清楚应该测试什么假设。似乎作者cov2cor
认为不适合对从协方差派生的相关性进行统计检验。的作者lavaan
并且inspect.lavaan
也认为不适合构建 p 值矩阵,所以也许这些不是明智的任务。您能否提供一个可以审查的参考,以支持此请求具有统计意义或无法解释?如果你能做到这一点,那么可能是分离作为底层结构的 S4 对象的机制。fit
. 但是除非我能得到一些理论指导,否则我觉得没有资格在代码中乱七八糟,直到我能找到一个标准误差矩阵并将相关性或协方差的比率与这些值进行比较。
您所期望的可能是通过以下方式交付的summary.lavaan
:
summary(fit)
#-----------------------------------
lavaan 0.6-6 ended normally after 35 iterations
Estimator ML
Optimization method NLMINB
Number of free parameters 21
Number of observations 301
Model Test User Model:
Test statistic 85.306
Degrees of freedom 24
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|)
visual =~
x1 1.000
x2 0.554 0.100 5.554 0.000
x3 0.729 0.109 6.685 0.000
textual =~
x4 1.000
x5 1.113 0.065 17.014 0.000
x6 0.926 0.055 16.703 0.000
speed =~
x7 1.000
x8 1.180 0.165 7.152 0.000
x9 1.082 0.151 7.155 0.000
Covariances:
Estimate Std.Err z-value P(>|z|)
visual ~~
textual 0.408 0.074 5.552 0.000
speed 0.262 0.056 4.660 0.000
textual ~~
speed 0.173 0.049 3.518 0.000
Variances:
Estimate Std.Err z-value P(>|z|)
.x1 0.549 0.114 4.833 0.000
.x2 1.134 0.102 11.146 0.000
.x3 0.844 0.091 9.317 0.000
.x4 0.371 0.048 7.779 0.000
.x5 0.446 0.058 7.642 0.000
.x6 0.356 0.043 8.277 0.000
.x7 0.799 0.081 9.823 0.000
.x8 0.488 0.074 6.573 0.000
.x9 0.566 0.071 8.003 0.000
visual 0.809 0.145 5.564 0.000
textual 0.979 0.112 8.737 0.000
speed 0.384 0.086 4.451 0.000
推荐阅读
- function - Rust:同名的结构和函数
- python - 如何在 django 频道中为消费者编写单元测试?
- c# - C# UWP SpeechRuntime.exe 内存泄漏?
- javascript - 使用 JavaScript 更改事件监听器对产品列表进行排序
- javascript - 如何动态渲染和更新 chart.js 折线图
- azure - 写入 Azure Blob 存储。一切看起来都很好,但它会创建很多临时文件
- python - 创建绘图的 Pytest 测试函数
- javascript - 在搜索结果中包含图像的 Javascript 代码
- c - 为什么标准规定 C 中结构、枚举和联合的标记存在三种可能的命名空间,而实际上它们只有一种?
- json - 使用杰克逊子类型时如何避免获得带有随机信息的额外字段?