An R package to create nice looking output for CFA and SEM analyses using lavaan and semPlot packages

Interact with an Example RMarkdown Output



Required Packages

  • lavaan package to run CFA and SEM analyses

  • semPlot package to display model diagrams

  • sjPlot package to print correlation tables


The package contains an R Markdwon template that makes it very easy to run CFA and SEM analyses in R and create nice looking output.

Once you install the package, you will be able to access the R Markdown template by going to:

File -> New File -> R Markdown… -> From Template -> CFA/SEM (lavaan)


lavaan syntax is very intuitive to use and is documented with useful tutorials

Example lavaan syntax


# Specify the model parameters using intuitive syntax to write out equations
model <- '
# latent factors
f1 =~ v1 + v2 + v3
f2 =~ v4 + v5 + v6
f3 =~ v7 + v8 + v9

# correlated errors
v5 ~~ v6
v7 ~~ v8

# Run a latent variable analysis
fit <- cfa(model, data = data, missing = "ML", = FALSE)

Screenshots of nice looking output

Model Fit

alt text

CFA Output

alt text

SEM Output

alt text

Model Diagram

alt text

Correlation Matrix

alt text