cfa_invariance_fit: Compare fit of several CFA or SEM models

Usage Arguments Examples

View source: R/cfa_invariance_fit.r

Usage

1
cfa_invariance_fit(..., model_names = NULL, print = FALSE)

Arguments

...

Lavaan fit objects (e.g., with base, weak, strong and strict invariance constraints).

model_names

If desired, this argument can be used to pass a character vector to the function containing new names for the models (the vector's length needs to equal the number of models!).

print

Logical value indicating whether the output should be formatted according to APA guidelines. #' @return A data frame including one row per model that was passed to the function. The output includes the most commonly reported fit indices for structural equation models.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
library(lavaan)
model_1 <- '
  # latent variables
  ind60 =~ x1 + x2 + x3
  dem60 =~ y1 + y2 + y3 + y4
  dem65 =~ y5 + y6 + y7 + y8
  '
fit_1 <- cfa(model_1, data = PoliticalDemocracy)
  
model_2 <- '
  # latent variables
  ind60 =~ x1 + x2 + x3
  dem60 =~ y1 + y2 + y3
  dem65 =~ y5 + y6 + y7 + y8
'
fit_2 <- lavaan::cfa(model_2, data = PoliticalDemocracy)

# Model comparison
cfa_invariance_fit(fit_1, fit_2)
cfa_invariance_fit(fit_1, fit_2,
                   model_names = c("M1", "M2"),
                   print = TRUE)

masurp/pmstats documentation built on Oct. 6, 2020, 9:24 p.m.