How to Fit a Structural Equation Model in Displayr
In this post I am going to walk through the steps of fitting a structural equation model (SEM) in Displayr. The post assumes that you already know what a SEM is and how to interpret it.
Case study
In the post I am going to analyze Bollen's famous Political Democracy data set (Kenneth Bollen (1989), Structural Equations with Latent Variables, Wiley.)
Step 1: Load the data
Typically data sets are loaded into Displayr from raw data files. But, in this case we will load some data that is stored in an R package.
- Insert > New Data Set > R
- Name: BollenPoliticalDemocracy
- Paste in the code below into the R CODE box
- Click OK
Step 2: Fit the model
The hard step is fitting the model, as this requires you to specify the measurement model, the relationships to be tested (i.e., the regressions), and the correlation structure of the model. For more information about this, please check out the lavaan website.
To do this:
- Insert > R Output
- Paste in the code below
- Press Calculate
Step 3: Review the path diagram
In order to check that the model has been correctly specified it's a good idea to review the path diagram.
- Insert > R Output
- Paste in the code below
- Press Calculate
Step 4: Extract the summary statistics
- Insert > R Output
- Paste in the code below
- Press Calculate
- In the Object inspector, on the right of your screen, click Properties > OUTPUT > Show as > Text
- To align the text neatly, go to Properties > APPEARANCE and set the font to Courier New.