| lavTestLRT | R Documentation |
LRT test for comparing (nested) lavaan models.
lavTestLRT(object, ..., method = "default", test = "default",
a_method = "delta", scaled_shifted = TRUE,
check_nested = TRUE,
type = "Chisq", model_names = NULL)
anova(object, ...)
object |
An object of class |
... |
additional objects of class |
method |
Character string. The possible options are
|
test |
Character string specifying which scaled test statistics to use,
in case multiple scaled |
a_method |
Character string. The possible options are |
scaled_shifted |
Logical. Only used when method = |
check_nested |
Logical. If |
type |
Character. If |
model_names |
Character vector. If provided, use these model names in the first column of the anova table. |
The anova function for lavaan objects simply calls the
lavTestLRT function, which has a few additional arguments.
The chi-squared difference test is only valid when all models are
(nested and) fitted to the same set of sample statistics. Several
sanity checks are therefore carried out (in the spirit of
semTools::net()): the number of groups, the group labels, the
(group-specific) numbers of observations, and the observed sample
statistics must all be identical across models. If any of these
checks fails, a warning is issued (but the table is still computed).
In particular, a single-group (pooled) model cannot be compared
directly with a multiple-group model: their test statistics are
computed relative to different (saturated) models. Instead, refit the
pooled model as a multiple-group model in which all parameters are
constrained to be equal across groups (group_equal = "all"),
and compare that model with the unrestricted multiple-group model.
See the Examples section for an illustration.
The only test= options that currently have actual consequences are
"satorra.bentler", "yuan.bentler", or "yuan.bentler.mplus"
because "mean.var.adjusted" and "scaled_shifted" are
currently distinguished by the scaled_shifted argument.
See lavOptions for details about the test= options
implied by robust estimator= options. The "default" is to
select the first available scaled statistic, if any. To check which test(s)
were computed when fitting your model(s), use
lavInspect(fit, "options")$test.
If type = "Chisq" and the test statistics are scaled, a
special scaled difference test statistic is computed. If method is
"satorra.bentler.2001", a simple approximation is used
described in Satorra & Bentler (2001). In some settings,
this can lead to a negative test statistic. To ensure a positive
test statistic, we can use the method proposed by
Satorra & Bentler (2010). Alternatively, when method="satorra.2000",
the original formulas of Satorra (2000) are used. The latter is used for
model comparison when ... contains additional (nested) models.
Even when test statistics are scaled in object or ...,
users may request the method="standard" test statistic,
without a robust adjustment.
Conversely, a robust method= ("satorra.bentler.2001",
"satorra.bentler.2010" or "satorra.2000") can only be applied
when the models were fitted with a robust (scaled) test statistic. If none
of the models in object or ... were fitted with a robust test
statistic, a robust method= cannot be honored: in that case a warning
is issued, the method= argument is ignored, and a standard (regular)
chi-squared difference test is returned.
FMG nested tests are available when type = "Chisq" and
test is an FMG test name. The supported nested FMG methods are
"pall", "all", "peba" and "pols" variants.
The convenience value "fmg" resolves to "pall_ug_rls" for
single-group comparisons and "pall_ug_ml" for multiple-group
comparisons.
They use the Satorra (2000) UGamma projection; method may be left
at "default" or set to "standard" or
"satorra.2000". Other nested LRT methods are not used for FMG
tests.
An object of class anova. When given a single argument, it simply returns the test statistic of this model. When given a sequence of objects, this function tests the models against one another, after reordering the models according to their degrees of freedom.
The object carries a few (hidden) attributes that record which
difference test was computed (intended for developers; new in 0.7-3):
"type" (the type of test, in canonical spelling, e.g.
"chisq" or "browne.residual.nt.model"), "method"
(the method that was used for a scaled difference test, e.g.
"satorra.bentler.2001"; "standard" for an unscaled
difference test), "test" (the name of the scaled test statistic
the difference test was based on, e.g. "satorra.bentler";
"standard" if unscaled) and "scaled" (logical). For
scaled difference tests, the attributes "scale" (and
"shift") contain the scaling factors (and shift parameters).
If there is a lavaan model stored in
object@external$h1.model, it will be added to ...
Satorra, A. (2000). Scaled and adjusted restricted tests in multi-sample analysis of moment structures. In Heijmans, R.D.H., Pollock, D.S.G. & Satorra, A. (eds.), Innovations in multivariate statistical analysis: A Festschrift for Heinz Neudecker (pp.233-247). London, UK: Kluwer Academic Publishers.
Satorra, A., & Bentler, P. M. (2001). A scaled difference chi-square test statistic for moment structure analysis. Psychometrika, 66(4), 507-514. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1007/BF02296192")}
Satorra, A., & Bentler, P. M. (2010). Ensuring positiveness of the scaled difference chi-square test statistic. Psychometrika, 75(2), 243-248. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1007/s11336-009-9135-y")}
Foldnes, N., Moss, J., & Gronneberg, S. (2024). Improved goodness of fit procedures for structural equation models. Structural Equation Modeling: A Multidisciplinary Journal, 1-13. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1080/10705511.2024.2372028")}
Bentler, P. M., & Satorra, A. (2010). Testing model nesting and equivalence. Psychological Methods, 15(2), 111-123. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1037/a0019625")}
Asparouhov, T., & Muthen, B. (2019). Nesting and equivalence testing for structural equation models. Structural Equation Modeling: A Multidisciplinary Journal, 26(2), 302-309. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1080/10705511.2018.1513795")}
Foldnes, N., Gronneberg, S., & Moss, J. (2026). Penalized eigenvalue block averaging: Extension to nested model comparison and Monte Carlo evaluations. Behavior Research Methods, 58(4). \Sexpr[results=rd]{tools:::Rd_expr_doi("10.3758/s13428-026-02968-4")}
HS.model <- '
visual =~ x1 + b1*x2 + x3
textual =~ x4 + b2*x5 + x6
speed =~ x7 + b3*x8 + x9
'
fit1 <- cfa(HS.model, data = HolzingerSwineford1939)
fit0 <- cfa(HS.model, data = HolzingerSwineford1939,
orthogonal = TRUE)
lavTestLRT(fit1, fit0)
## A single-group (pooled) model can NOT be compared directly with a
## multiple-group model; the warning explains why the test is invalid:
HS <- '
visual =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
speed =~ x7 + x8 + x9
'
fit.pooled <- cfa(HS, data = HolzingerSwineford1939, meanstructure = TRUE)
fit.groups <- cfa(HS, data = HolzingerSwineford1939, group = "school")
lavTestLRT(fit.pooled, fit.groups) # invalid comparison (warning)
## A valid alternative: refit the pooled model as a multiple-group model
## with all parameters constrained to be equal across groups
fit.pooled2 <- cfa(HS, data = HolzingerSwineford1939, group = "school",
group_equal = "all")
lavTestLRT(fit.pooled2, fit.groups) # valid comparison
## When multiple test statistics are selected when the model is fitted,
## use the type= and test= arguments to select a test for comparison.
## refit models, requesting 6 test statistics (in addition to "standard")
t6.1 <- cfa(HS.model, data = HolzingerSwineford1939,
test = c("browne.residual.adf","scaled.shifted","mean.var.adjusted",
"satorra.bentler", "yuan.bentler", "yuan.bentler.mplus"))
t6.0 <- cfa(HS.model, data = HolzingerSwineford1939, orthogonal = TRUE,
test = c("browne.residual.adf","scaled.shifted","mean.var.adjusted",
"satorra.bentler", "yuan.bentler", "yuan.bentler.mplus"))
## By default (test="default", type="Chisq"), the first scaled statistic
## requested will be used. Here, that is "scaled.shifted"
lavTestLRT(t6.1, t6.0)
## But even if "satorra.bentler" were requested first, method="satorra.2000"
## provides the scaled-shifted chi-squared difference test:
lavTestLRT(t6.1, t6.0, method = "satorra.2000")
## == lavTestLRT(update(t6.1, test = "scaled.shifted"), update(t6.0, test = "scaled.shifted"))
## The mean- and variance-adjusted (Satterthwaite) statistic implies
## scaled_shifted = FALSE
lavTestLRT(t6.1, t6.0, method = "satorra.2000", scaled_shifted = FALSE)
## Because "satorra.bentler" is not the first scaled test in the list,
## we MUST request it explicitly:
lavTestLRT(t6.1, t6.0, test = "satorra.bentler") # method="satorra.bentler.2001"
## == lavTestLRT(update(t6.1, test = "satorra.bentler"),
## update(t6.0, test = "satorra.bentler"))
## The "strictly-positive test" is necessary when the above test is < 0:
lavTestLRT(t6.1, t6.0, test = "satorra.bentler", method = "satorra.bentler.2010")
## Likewise, other scaled statistics can be selected:
lavTestLRT(t6.1, t6.0, test = "yuan.bentler")
## == lavTestLRT(update(t6.1, test = "yuan.bentler"),
## update(t6.0, test = "yuan.bentler"))
lavTestLRT(t6.1, t6.0, test = "yuan.bentler.mplus")
## == lavTestLRT(update(t6.1, test = "yuan.bentler.mplus"),
## update(t6.0, test = "yuan.bentler.mplus"))
## To request the difference between Browne's (1984) residual-based statistics,
## rather than statistics based on the fitted model's discrepancy function,
## use the type= argument:
lavTestLRT(t6.1, t6.0, type = "browne.residual.adf")
## Despite requesting multiple robust tests, it is still possible to obtain
## the standard chi-squared difference test (i.e., without a robust correction)
lavTestLRT(t6.1, t6.0, method = "standard")
## == lavTestLRT(update(t6.1, test = "standard"), update(t6.0, test = "standard"))
## FMG nested p-values use the Satorra (2000) UGamma projection
lavTestLRT(fit1, fit0, method = "satorra.2000", test = "pall")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.