Skip to contents

Combine fit measures form several models and compare

Usage

lav_compare(
  ...,
  what = c("cfi", "tli", "rmsea", "srmr", "bic", "df"),
  LRT = F,
  print = T
)

Arguments

...

lavaan fitted objects

what

Character vector of fit indices as given in lavaan `fitMeasures()`

LRT

Logical. Whether to include likelihood ratio test (anova) comparing the models.

print

Logical. Whether to print the results to the console.

Details

Extracts select fit measures from lavaan objects and lists it in the tables.

Examples

data("HolzingerSwineford1939", package="lavaan")
m1 = cfa("F1 =~ x1 + x2 + x3 + x4 + x5", estimator= "mlr", HolzingerSwineford1939)
#> Error in cfa("F1 =~ x1 + x2 + x3 + x4 + x5", estimator = "mlr", HolzingerSwineford1939): could not find function "cfa"
m2 = cfa("F1 =~ x1 + x2 + x3 + x4 + x5; x4 ~~ x5", estimator= "mlr", HolzingerSwineford1939)
#> Error in cfa("F1 =~ x1 + x2 + x3 + x4 + x5; x4 ~~ x5", estimator = "mlr",     HolzingerSwineford1939): could not find function "cfa"
lav_compare(m1, m2, what = c("cfi.scaled", "rmsea.scaled") )
#> Error: object 'm1' not found