About lavaan

News:

  • (15 July 2024): as many of you have noticed, google has (permanently?) blocked/removed the lavaan discussion group; this happened (presumably) after a spam attack that started on Sunday 14 July and continued on Monday 15 July: hundreds of spam messages slipped through; at the moment, it is unclear if we will be able to unblock the lavaan group, let alone if we will be able to get access to its archive; the google message I received read as follows:
    Hello yrosseel@gmail.com,
    We're letting you know that we've permanently removed the content at https://groups.google.com/d/forum/lavaan
    Why did this happen?
    An external report flagged the content for illegal content or policy violations. As a result, our legal content and policy standards team removed the content for the following reason: regulated.
    Learn more
    You can learn more about our content policies and enforcement at our help center https://support.google.com/groups/answer/4561696?hl=en_US
    What you can do next
    You may have the option to pursue your claims in court. If you have legal questions or wish to examine legal options that may be available to you, you may want to consult with your own legal counsel.
    Visit the help center. https://support.google.com/groups/answer/46601?hl=en_US
    We are trying to resolve the matter; in the mean time, please use stack exchange for questions (and make sure to use the tags R and lavaan)
  • (7 June 2024): lavaan version 0.6-18 has been released on CRAN. See Version History for more information.
  • (25 March 2024): slides for my presentation (‘The SAM approach to SEM’) at the joint quantitative brownbag (JQBB) speaker series can be found here; the corresponding R can found here.

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. lavaan example

This is the corresponding lavaan model syntax:

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
'
fit <- sem(model = myModel, 
           data = PoliticalDemocracy) 
summary(fit)