Armin
Armin

Reputation: 21

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. How can I get a correlation matrix of factors that also includes data on significance levels? (i.e. p-value) When I use the line cov2cor(inspect(fit, what = "est")$psi) I get the matrix but not the p-values.

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)

Upvotes: 0

Views: 1565

Answers (1)

IRTFM
IRTFM

Reputation: 263301

I would not consider p-values to be estimates. 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. 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. 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. 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(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

Upvotes: 1

Related Questions