About how to display more decimal places for model fit indices (i.e., CFI, RMSEA, SRMR)

497 views
Skip to first unread message

Benjamin Wang

unread,
Dec 7, 2021, 12:11:24 PM12/7/21
to lavaan
Dear group, 

When using Lavaan package in R software, I have a question about how to display more decimal places for model fit indices (i.e., CFI, RMSEA, SRMR). Typically, Lavaan displays results of 3 decimal places for fit indices. Are there any ways I could allow Lavaan to display more than 3 decimal places? 

I have checked in the group and found a related post: Display more digits after decimal point (google.com). However, when I try the codes in the post, I still could not allow Lavaan to display more than 3 decimal places for model fit indices. Are there any ways to solve this issue?

Thank you very much for your help in advance!

Yours sincerely,
Benjamin Wang
 

Example model fit indices output as below:

User Model versus Baseline Model:
  Comparative Fit Index (CFI)                    0.950
  Tucker-Lewis Index (TLI)                       0.895

Root Mean Square Error of Approximation:
  RMSEA                                          0.108
  90 Percent confidence interval - lower         0.100
  90 Percent confidence interval - upper         0.116
  P-value RMSEA <= 0.05                          0.000

Standardized Root Mean Square Residual:
  SRMR                                           0.204

car...@web.de

unread,
Dec 7, 2021, 12:39:20 PM12/7/21
to lav...@googlegroups.com
There are several solutions. For example, you could use this one:
fm <- c(fitMeasures(fittedLavObj))
print(round(fm, 4))
 
Gesendet: Dienstag, 07. Dezember 2021 um 18:11 Uhr
Von: "Benjamin Wang" <2816...@gmail.com>
An: "lavaan" <lav...@googlegroups.com>
Betreff: About how to display more decimal places for model fit indices (i.e., CFI, RMSEA, SRMR)
--
You received this message because you are subscribed to the Google Groups "lavaan" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lavaan+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lavaan/a7d422d1-1cb4-4516-b2bf-33cf9d5c0137n%40googlegroups.com.
 
 

Shu Fai Cheung

unread,
Dec 7, 2021, 10:45:07 PM12/7/21
to lavaan
You can also try this, based on the example of fitMeasures(). Just use the nd argument of the print method of fitMeasures() output

library(lavaan)
#> This is lavaan 0.6-9
#> lavaan is FREE software! Please report any bugs.
HS.model <- ' visual  =~ x1 + x2 + x3
              textual =~ x4 + x5 + x6
              speed   =~ x7 + x8 + x9 '

fit <- cfa(HS.model, data=HolzingerSwineford1939)
print(fitMeasures(fit, output = "text"), nd = 5)
#>
#> Model Test User Model:
#>
#>   Test statistic                                      85.30552
#>   Degrees of freedom                                        24
#>   P-value                                              0.00000
#>
#> Model Test Baseline Model:
#>
#>   Test statistic                                     918.85159
#>   Degrees of freedom                                        36
#>   P-value                                              0.00000
#>
#> User Model versus Baseline Model:
#>
#>   Comparative Fit Index (CFI)                          0.93056
#>   Tucker-Lewis Index (TLI)                             0.89584
#>   Bentler-Bonett Non-normed Fit Index (NNFI)           0.89584
#>   Bentler-Bonett Normed Fit Index (NFI)                0.90716
#>   Parsimony Normed Fit Index (PNFI)                    0.60477
#>   Bollen's Relative Fit Index (RFI)                    0.86074
#>   Bollen's Incremental Fit Index (IFI)                 0.93149
#>   Relative Noncentrality Index (RNI)                   0.93056
#>
#> Loglikelihood and Information Criteria:
#>
#>   Loglikelihood user model (H0)                    -3737.74493
#>   Loglikelihood unrestricted model (H1)            -3695.09217
#>                                                              
#>   Akaike (AIC)                                      7517.48985
#>   Bayesian (BIC)                                    7595.33917
#>   Sample-size adjusted Bayesian (BIC)               7528.73911
#>
#> Root Mean Square Error of Approximation:
#>
#>   RMSEA                                                0.09212
#>   90 Percent confidence interval - lower               0.07142
#>   90 Percent confidence interval - upper               0.11368
#>   P-value RMSEA <= 0.05                                0.00066
#>
#> Standardized Root Mean Square Residual:
#>
#>   RMR                                                  0.08218
#>   RMR (No Mean)                                        0.08218
#>   SRMR                                                 0.06521
#>
#> Other Fit Indices:
#>
#>   Hoelter Critical N (CN) alpha = 0.05               129.49020
#>   Hoelter Critical N (CN) alpha = 0.01               152.65403
#>                                                              
#>   Goodness of Fit Index (GFI)                          0.94333
#>   Adjusted Goodness of Fit Index (AGFI)                0.89375
#>   Parsimony Goodness of Fit Index (PGFI)               0.50311
#>                                                              
#>   McDonald Fit Index (MFI)                             0.90318
#>                                                              
#>   Expected Cross-Validation Index (ECVI)               0.42294


Created on 2021-12-08 by the reprex package (v2.0.1)

If you use summary(), it directly supports the nd argument:

summary(fit, fit.measures = TRUE, nd = 5)

Hope this helps.

-- Shu Fai

Benjamin Wang

unread,
Dec 7, 2021, 11:30:54 PM12/7/21
to lavaan
Thank you very much to both of your methods and codes! They all worked out perfectly.

Yours sincerely,
Benjamin Wang

Reply all
Reply to author
Forward
0 new messages