fitMeasures.RdThis function computes a variety of fit measures to assess the global fit of a latent variable model.
fitMeasures(object, fit.measures = "all",
baseline.model = NULL, h1.model = NULL,
fm.args = list(standard.test = "default",
scaled.test = "default",
rmsea.ci.level = 0.90,
rmsea.close.h0 = 0.05,
rmsea.notclose.h0 = 0.08,
robust = TRUE,
cat.check.pd = TRUE),
output = "vector", ...)
fitmeasures(object, fit.measures = "all",
baseline.model = NULL, h1.model = NULL,
fm.args = list(standard.test = "default",
scaled.test = "default",
rmsea.ci.level = 0.90,
rmsea.close.h0 = 0.05,
rmsea.notclose.h0 = 0.08,
robust = TRUE,
cat.check.pd = TRUE),
output = "vector", ...)An object of class lavaan.
If "all", all fit measures available will be
returned. If only a single or a few fit measures are specified by name,
only those are computed and returned.
If not NULL, an object of class
lavaan, representing a user-specified baseline model.
If a baseline model is provided, all fit indices relying on a
baseline model (eg. CFI or TLI) will use the test statistics from
this user-specified baseline model, instead of the default baseline model.
If not NULL, an object of class lavaan,
representing a user-specified alternative to the default unrestricted model.
If h1.model is provided, all fit indices calculated from chi-squared
will use the chi-squared difference test statistics from
lavTestLRT, which compare the user-provided h1.model
to object.
List. Additional options for certain fit measures. The
standard.test element determines the main test statistic (chi-square
value) that will be used to compute all the fit measures that depend on this
test statistic. Usually this is "standard". The scaled.test
element determines which scaling method is to be used for the scaled fit
measures (in case multiple scaling methods were requested). The
rmsea.ci.level element determines the level of the confidence
interval for the rmsea value. The rmsea.close.h0 element
is the rmsea value
that is used under the null hypothesis that rmsea <= rmsea.close.h0.
The rmsea.notclose.h0 element is the rmsea value that is used under the
null hypothesis that rsmsea >= rmsea.notclose.h0. The robust
element can be set to FALSE to avoid computing the so-called robust
rmsea/cfi measures (for example if the computations take too long).
The cat.check.pd element is only used when data is categorical. If
TRUE, robust values for RMSEA and CFI are only computed if the input
correlation matrix is positive-definite (for all groups).
Character. If "vector" (the default), display the
output as a named (lavaan-formatted) vector. If "matrix", display
the output as a 1-column matrix. If "text", display the
output using subsections and verbose descriptions. The latter is used
in the summary output, and does not print the chi-square test by default.
In addition, fit.measures should contain the main ingredient
(for example "rmsea") if related fit measures are requested
(for example "rmsea.ci.lower"). Otherwise, nothing will be
printed in that section.
See the examples how to add the chi-square test in the text output.
Further arguments passed to or from other methods. Not currently
used for lavaan objects.
A named numeric vector of fit measures.
When a scaled (or robust) test statistic is requested (for example, by using
test = "satorra.bentler"), the function will also return fit indices
based on the scaled chi-square statistic, rather than the standard version.
These scaled versions of fit measures, such as CFI and RMSEA, are calculated in
the same way as their standard counterparts, with the key difference being that
the scaled chi-square statistic is used in place of the regular one. In the
output of fitMeasures(), these appear with the .scaled suffix,
or in the Scaled column of the summary() output.
However, this substitution-based approach—used in SEM software for many
years—has since been shown to be incorrect. Improved versions of robust fit
indices have been proposed, offering better theoretical properties. Although
still under development and not yet implemented for all estimation settings,
these improved robust fit measures are provided when available. They appear
with a .robust suffix in the output of fitMeasures(), or in the
Scaled column of the summary() output on a row labeled
Robust. As a general recommendation, these newer robust versions should
be used whenever available, in preference to the older scaled ones. See the
references below for more details.
It is also worth noting that, for models involving ordered categorical data,
robust fit indices are only computed if the underlying matrix of tetrachoric or
polychoric correlations is positive definite. If this condition is not
met—which is not uncommon in small samples—the robust measures are reported
as NA.
Finally, in some situations (especially when the data contains missing values),
computing these robust fit indices may be computationally intensive. To avoid
long runtimes, the calculation of robust fit measures can be disabled by
setting the robust argument to FALSE in the fm.args list.
Brosseau-Liard, P. E., Savalei, V., & Li, L. (2012). An investigation of the sample performance of two nonnormality corrections for RMSEA. Multivariate behavioral research, 47(6), 904-930. doi:10.1080/00273171.2012.715252
Brosseau-Liard, P. E., & Savalei, V. (2014). Adjusting incremental fit indices for nonnormality. Multivariate behavioral research, 49(5), 460-470. doi:10.1080/00273171.2014.933697
Savalei, V. (2018). On the computation of the RMSEA and CFI from the mean-and-variance corrected test statistic with nonnormal data in SEM. Multivariate behavioral research, 53(3), 419-429. doi:10.1080/00273171.2018.1455142
Savalei, V. (2021). Improving fit indices in structural equation modeling with categorical data. Multivariate Behavioral Research, 56(3), 390-407. doi:10.1080/00273171.2020.1717922
Savalei, V., Brace, J. C., & Fouladi, R. T. (2023). We need to change how we compute RMSEA for nested model comparisons in structural equation modeling. Psychological Methods. doi:10.1037/met0000537
Zhang, X., & Savalei, V. (2023). New computations for RMSEA and CFI following FIML and TS estimation with missing data. Psychological Methods, 28(2), 263-283. doi:10.1037/met0000445
HS.model <- ' visual =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
speed =~ x7 + x8 + x9 '
fit <- cfa(HS.model, data = HolzingerSwineford1939)
#> Warning: lavaan->lav_model_vcov():
#> The variance-covariance matrix of the estimated parameters (vcov) does not
#> appear to be positive definite! The smallest eigenvalue (= -1.747972e-02)
#> is smaller than zero. This may be a symptom that the model is not
#> identified.
fitMeasures(fit)
#> npar fmin chisq
#> 21.000 0.142 85.306
#> df pvalue baseline.chisq
#> 24.000 0.000 918.852
#> baseline.df baseline.pvalue cfi
#> 36.000 0.000 0.931
#> tli nnfi rfi
#> 0.896 0.896 0.861
#> nfi pnfi ifi
#> 0.907 0.605 0.931
#> rni logl unrestricted.logl
#> 0.931 -3737.745 -3695.092
#> aic bic ntotal
#> 7517.490 7595.339 301.000
#> bic2 rmsea rmsea.ci.lower
#> 7528.739 0.092 0.071
#> rmsea.ci.upper rmsea.ci.level rmsea.pvalue
#> 0.114 0.900 0.001
#> rmsea.close.h0 rmsea.notclose.pvalue rmsea.notclose.h0
#> 0.050 0.840 0.080
#> rmr rmr_nomean srmr
#> 0.082 0.082 0.065
#> srmr_bentler srmr_bentler_nomean crmr
#> 0.065 0.065 0.073
#> crmr_nomean srmr_mplus srmr_mplus_nomean
#> 0.073 0.065 0.065
#> cn_05 cn_01 gfi
#> 129.490 152.654 0.943
#> agfi pgfi mfi
#> 0.894 0.503 0.903
#> ecvi
#> 0.423
fitMeasures(fit, "cfi")
#> cfi
#> 0.931
fitMeasures(fit, c("chisq", "df", "pvalue", "cfi", "rmsea"))
#> chisq df pvalue cfi rmsea
#> 85.306 24.000 0.000 0.931 0.092
fitMeasures(fit, c("chisq", "df", "pvalue", "cfi", "rmsea"),
output = "matrix")
#>
#> chisq 85.306
#> df 24.000
#> pvalue 0.000
#> cfi 0.931
#> rmsea 0.092
fitMeasures(fit, c("chisq", "df", "pvalue", "cfi", "rmsea"),
output = "text")
#>
#> Model Test User Model:
#>
#> Test statistic 85.306
#> Degrees of freedom 24
#> P-value 0.000
#>
#> User Model versus Baseline Model:
#>
#> Comparative Fit Index (CFI) 0.931
#>
#> Root Mean Square Error of Approximation:
#>
#> RMSEA 0.092
## fit a more restricted model
fit0 <- cfa(HS.model, data = HolzingerSwineford1939, orthogonal = TRUE)
#> Warning: lavaan->lav_model_vcov():
#> The variance-covariance matrix of the estimated parameters (vcov) does not
#> appear to be positive definite! The smallest eigenvalue (= -1.672586e-01)
#> is smaller than zero. This may be a symptom that the model is not
#> identified.
## Calculate RMSEA_D (Savalei et al., 2023)
## See https://psycnet.apa.org/doi/10.1037/met0000537
fitMeasures(fit0, "rmsea", h1.model = fit)
#> rmsea
#> 0.269