This article describes how to fit a structural equation model in Displayr
In this article 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.)
Requirements
A Displayr Document with data suitable for structural equation modeling
Method
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.
-
Go to Data Sets > Plus (+) > R.
-
Under Name, enter the name BollenPoliticalDemocracy for the data set.
- 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:
- Select Calculation > Custom Code and click on the page
- Paste in the code below in the R Code window
- 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.
- Calculation > Custom Code and click page
- Paste in the code below
- Press Calculate
Step 4: Extract the summary statistics
- Click Calculation > Custom Code
- 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.
Next
How to Work With R in Displayr