<- '
myModel # 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
'
<- sem(model = myModel,
fit data = PoliticalDemocracy)
summary(fit)
About lavaan
News:
- (pinned): Exciting things are being planned for lavaan’s future development! Click here to read more, or use the donate button below to donate to our efforts:
- (15 March 2025): the slides and R code for the pre-conference workshop “The structural after measurement (SAM) approach to SEM”, part of the SEM working group meeting at TU Chemnitz, can found in this directory.
- (15 March 2025): here are the slides of my presentation “The structural after measurement (SAM) approach: updates and extensions”, to be presented during the SEM working group meeting at TU Chemnitz.
- (23 December 2024): Utrecht University is organizing an e-learning course on Structural Equation Modeling in R using lavaan in March 2025.
- (26 September 2024): lavaan version 0.6-19 has been released on CRAN. See Version History for more information.
What is lavaan?
The lavaan package is developed to provide useRs, researchers and teachers a free open-source, but commercial-quality package for latent variable modeling. You can use lavaan to estimate a large variety of multivariate statistical models, including path analysis, confirmatory factor analysis, structural equation modeling and growth curve models.
The official reference to the lavaan package is the following paper:
Yves Rosseel (2012). lavaan: An R Package for Structural Equation Modeling. Journal of Statistical Software, 48(2), 1-36. URL http://www.jstatsoft.org/v48/i02/
First impression
To get a first impression of how lavaan works in practice, consider the following example of a SEM model. The figure below contains a graphical representation of the model that we want to fit.
This is the corresponding lavaan model syntax: