fit_table: Creates a table with relevant fit indices for an SEM or CFA

Description Usage Arguments Value Examples

View source: R/fit_table.r

Description

This function returns a data frame that contains the fit indices for a SEM or CFA model. The type of indices can be chosen (available are all indices that can be obtained using the function inspect). Reliability indices (alpha, omega, average variance extracted) can added if desired (will be computed by using the function reliability).

Usage

1
2
3
4
5
6
7
8
9
fit_table(
  object,
  indices = c("chisq", "df", "pvalue", "cfi", "tli", "rmsea", "rmsea.ci.lower",
    "rmsea.ci.upper", "srmr"),
  rmsea_ci = FALSE,
  reliability = FALSE,
  robust = FALSE,
  print = FALSE
)

Arguments

object

An object of class lavaan created by using cfa() or sem() from the package 'lavaan'.

indices

Vector of the indices that should be in the ouput.

rmsea_ci

Logical vector indicating whether the confidence intervals of the RMSEA should be included (important for reporting the fit in an RMarkdown document using print_fit)

reliability

Logical value indicating whether Cronbach's alpha, McDonald's omega (composite reliability), and the average variance extracted should be included.

robust

Logical value indicating whether the model was fitted with a robust estimator. If yes, scaled indices will be used.

print

Logical value indicating whether the table should be formatted according to APA guidelines.

Value

A data frame containing the fit indices of the model.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
library(lavaan)
model <- '
  # latent variables
  ind60 =~ x1 + x2 + x3
  dem60 =~ y1 + y2 + y3 + y4
  dem65 =~ y5 + y6 + y7 + y8

  # regressions
  dem60 ~ ind60
  dem65 ~ ind60 + dem60

  # residual covariances
  y1 ~~ y5
  y2 ~~ y4 + y6
  y3 ~~ y7
  y4 ~~ y8
  y6 ~~ y8
'
fit <- sem(model,
data = PoliticalDemocracy)

# Create table of fit indices
fit_table(fit)
fit_table(fit, indices = c("cfi", "tli"))
fit_table(fit, rmsea_ci = TRUE, print = TRUE)

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