简体   繁体   English

如何使用r中的lavaan包获得CFA中因子的相关矩阵和p值?

[英]How can I get correlation matrix and p values of factors in CFA using lavaan package in r?

I am running a CFA on my questionnaire using lavaan package in r.我正在使用 r 中的 lavaan 包在我的问卷上运行 CFA。 How can I get a correlation matrix of factors that also includes data on significance levels?如何获得还包括显着性水平数据的因素相关矩阵? (ie p-value) When I use the line cov2cor(inspect(fit, what = "est")$psi) I get the matrix but not the p-values. (即 p 值)当我使用cov2cor(inspect(fit, what = "est")$psi)我得到矩阵但不是 p 值。

Here's a sample code for the model:这是模型的示例代码:

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)

I would not consider p-values to be estimates.我不会认为 p 值是估计值。 They are more like random values.它们更像是随机值。 Does this deliver what you were looking for?这是否提供了您想要的东西?

 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

EDIT: You are working with covariances and they may not be Normally distributed.编辑:您正在使用协方差,它们可能不是正态分布的。 Furthermore, it's not clear what hypothesis should be tested.此外,尚不清楚应该测试什么假设。 It appears that the authors of cov2cor have not seen fit to deliver statistical tests on correlations derived from covariances.似乎cov2cor的作者cov2cor不适合对从协方差得出的相关性进行统计测试。 The authors of lavaan and inspect.lavaan have also not seen fit to construct a p-value matrix, so maybe these are not sensible tasks to carry out. lavaaninspect.lavaan的作者也认为不适合构建p 值矩阵,所以也许这些不是执行的明智任务。 Can you supply a reference that can be reviewed to back up this request as being statistically meaningful or uinterpretable?您能否提供可以审查的参考资料,以支持此请求在统计上有意义或无法解释? If you can do that, then the may be mechanisms to pull apart the S4 object that is the underlying structure of fit .如果您可以做到这一点,那么可能是将 S4 对象(作为fit的底层结构)分开的机制。 But unless I can get some theoretical guidance I don't feel qualified to just muck around in the code until I can find a standard errors matrix and compare ratios of correlations or covariance to such values.但除非我能得到一些理论指导,否则我觉得没有资格在代码中乱搞,直到我能找到一个标准误差矩阵并将相关性或协方差的比率与这些值进行比较。

It's possible that what you are expecting is delivered with summary.lavaan :您所期望的内容可能与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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM