How to Perform Structural Equation Modeling in JASP

With the latest release of JASP, the Structural Equation Modeling (SEM) module has received a few updates to make it more user-friendly. In this blogpost, we go through a famous example of latent mediation in order to show how the functionality of JASP’s SEM module can be used for advanced statistical modeling.

The SEM module in JASP is based on Yves Rosseel’s great R package lavaan (Rosseel, 2012). It uses the intuitive and straightforward syntax from this package for specifying models. Details can be found on the website of lavaan.

Following the excellent lavaan tutorial page, let’s take as an example Bollen’s dataset on industrialization and democracy in different countries. It is built into JASP and can be easily opened from the (also new and improved) data library. See this animated GIF to see how to open a dataset from the new data library. Alternatively, you can also download the annotated JASP file from our OSF folder.

Model Specification

Bollen used the following model in his analysis of these data: each latent variable is measured by three or four indicators, industrialization is measured in 1960, and democracy is measured at two timepoints (1960 and 1965). The model is shown in the figure below. In SEM, it is common to display latent (unmeasured) variables as circles and observed variables as rectangles.


This model may be encoded in the SEM module using lavaan syntax as follows:

# 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

In lavaan, =~ indicates measurement, with an (unobserved) latent variable on the left-hand side and its (observed) indicators on the right-hand side. The first statement reads as ind60 is measured by x1, x2, and x3. The ~ operator indicates regression: dem60 is regressed on ind60 or, equivalently, ind60 predicts dem60. The ~~ operator indicates a double-headed arrow or covariance. In this model, residual covariances are introduced between the equivalent items across time to account for the theory that the same item will correlate more than is explained by their relation through dem65 and dem60.

When this model is entered into the SEM module in JASP, it quickly returns outputs on the model fit, the estimates, and their uncertainty:

In addition, JASP can output additional fit measures, fitted, observed, and residual covariance matrices, modification indices, and much more.

A Latent Mediation Model

Although these estimates and the model fit give us a lot of information already, an interesting quantity in this model may be that of the indirect effect of industrialization in 1960 on democracy in 1965 via democracy in 1960. For example, we may be interested in the proportion of the effect of ind60 on dem65 that is mediated by dem60.

The advanced syntax of lavaan allows us to specify this indirect effect in terms of the parameters of the model. We can do this by adding labels to the regressions part of the model above and creating new combinations using the := operator:

# regressions
dem60 ~ alpha*ind60
dem65 ~ direct*ind60 + beta*dem60
# effects of interest
indirect := alpha * beta
total := indirect + direct
proportion := indirect/total

If we check the options for bootstrapping standard errors and confidence intervals, this results in estimates with uncertainty for these complicated combinations of parameters:

The total effect of industrialization in 1960 on democracy in 1965 is positive, and we may conclude from the confidence interval in the bottom row in the table that the proportion of this effect mediated by dem60 is between 0.441 and 0.935.


The new JASP update, version 0.9, has enabled new functionality for the SEM module. In principle, all lavaan syntax commands will now be available. This allows JASP users to calculate estimates and (bootstrap) confidence intervals for complex combinations of parameters.


Like this post?

Subscribe to our newsletter to receive regular updates about JASP including our latest blog posts, JASP articles, example analyses, new features, interviews with team members, and more! You can unsubscribe at any time.


Note: The title picture of this blog post has been created by Tim Bates, who uploaded it to Wikipedia Commons. The picture has been edited by the JASP team in the following way: we drew a blue border around the original image.


Bollen, K. A. (1989) Structural Equations With Latent Variables. Wiley.

Rosseel, Y. (2012) lavaan: An R Package for Structural Equation Modeling. Journal of Statistical Software, 48(2), 1-36.

About the author

Erik-Jan van Kesteren

Erik Jan van Kesteren is a PhD candidate at Utrecht University. At JASP, he is responsible for adding plots, functions, and UI elements, and interfacing R and C++.