This module introduces Structural Equation Modeling (SEM).
SEM is a sophisticated statistical approach that enables researchers to analyze the relationships between observed variables and underlying latent constructs.
You will learn:
The basic concepts of SEM.
The key terms used in SEM: latent and observed variables; reliability; direct and indirect effects; and path diagrams.
The types of models you can analyze (confirmatory factor analysis; path models; and models that combine factor analysis and regression models).
How SEM as a general technique can be used to estimate regression models as a special case.
How to evaluate and improve your model: goodness-of-fit statistics and modification indices.
How to report the results of SEM, including a visualization.
How to specify and run SEM-models in R’s lavaan package, or with user-friendly tools (JASP and Jamovi) which are based on lavaan.
2 What is Structural Equation Modeling?
2.1 Introduction
Structural equation modeling (SEM) is used for estimating causal relationships among variables.
SEM is a combination of two techniques discussed in other modules:
- Factor analysis, and
- Regression analysis.
2.1.1 Factor Analysis & Measurement
Typically, in social and economic research we make use of multiple item scales to measure concepts that are hard to measure directly.
Single-item measures are often tricky. They are vulnerable to biases of meaning and interpretation.
Multiple-item scales are designed to cover the full range of a construct, while single items tend to have narrow and/or ambiguous interpretations.
While it may seem easy for a hotel guest to answer one single question on his or her satisfaction with their stay, satisfaction is the result of differences between expected and perceived aspects (or dimensions) of service quality. Each of these aspects is indicated or measured by several items, as described in a general model of service quality like the SERVQUAL model (Parasuraman, Zeithaml, and Berry 1985).
The dimensions and the items to measure them are often based on extensive research, in which many items are proposed and analyzed using (exploratory) factor analysis.
Once there is agreement on the definition of several constructs and their measurement, then we can use questionnaires on these constructs for a quantitative assessment.
2.1.2 Regression Analysis and Causal Research
When doing applied research on (causal) relationships, we often start from existing theories. We can conduct a survey that makes use of a questionnaire based on, for instance, the SERVQUAL model.
We would still be interested in the reliability of the items measuring our constructs, but mainly to confirm the theory rather than to explore.
SEM models often combine measurement and causal research within one model. These models are visualized in path diagrams.
A path diagram for a research model on customer satisfaction and loyalty can look like this.
In this path diagram we see:
The constructs satisfaction and loyalty in ovals. Since these constructs are not measured directly, they are called latent variables. These constructs are also referred to as factors or dimensions.
The constructs are measured or indicated by items, which are the (observed) variables. Observed variables appear as rectangles in what we call a path diagram.
It is hard to understand why the arrows point from the latent variables to their measurements, rather than the other way around.
The idea is that the responses (observed scores on measurements) are caused by some latent variable. Each answer to an item (e.g., the respondent’s intention to recommend the hotel to others) is partly caused by the latent variable loyalty.
The circles with the Greek letters ε (pronounced epsilon) indicate that the items are not fully explained by the latent variable but have a unique, unexplained variance. Even though our respondent is very loyal to the hotel and plans to go back whenever he can, he may still have reasons not to recommend the hotel to family and friends (maybe he doesn’t have any)! But by and large, we would expect that items are positively correlated, and jointly form valid and reliable measurements of their constructs.
The above remarks are related to the measurement part of the model. The (causal) relation between satisfaction and loyalty is referred to as the structural part.
While in regression analysis, we are typically dealing with one dependent variable, and one or more independent variables, SEM-models can be more complex. In the figure below, overall customer satisfaction is a latent variable which explains customer loyalty but is also explained by other latent variables (perceived quality, perceived value, and customer expectations).
Complex models like this contain complex patterns of causality. Satisfaction is explained directly by customer expectations, and indirectly, via the impact of customer expectations on perceived quality. These direct and indirect effects are relevant from both a theoretical and practical point of view.
This model complexity calls for a different terminology from what we are used to in regression analysis. In regression analysis, variables are either dependent or independent. In SEM, variables (like overall customer satisfaction in the figure above), can be both dependent and independent! For that reason, we speak of endogenous and exogenous variables. Exogenous variables are all (latent or observed variables) that do not have an arrow pointing to them. Endogenous are all other variables, which are explained within the model.
In summary, structural equation models represent causal relationships between latent and observed variables.
Observed variables can be measured directly.
Latent variables cannot be measured directly.
Full SEM-models consist of two parts.
A measurement part, and
A structural part.
The measurement model specifies the relationships between observed variables and latent variables, while the structural model specifies the causal relationships between variables.
SEM-models may lack either a measurement part or a structural part!
2.2 Confirmatory Factor Analysis (CFA)
Confirmatory Factor Analysis (CFA) is a type of SEM-model used to test the validity of measurement models. It verifies whether the observed data fit a pre-specified model. A structural part is missing.
An example of a CFA-model is depicted below. This example is based on the Holzinger-Swineford data used in many papers and books on SEM.
A short version of the data set consists of mental ability test scores, with 9 observed variables on 3 factors. The two-sided arrows between the latent variables indicate that the latent variables are correlated.
Note that this simplified graphical representation is incomplete: the observed variables are bound to have a unique variance which is not shown for the sake of simplicity.
2.3 Path Analysis
Path Analysis is a SEM-model that includes observed variables only.
In a graphical representation, a path analysis model only has rectangles, and no ovals (not counting the variances of the endogenous observed variables).
It is probably here that confusion sets in! 😕
Attitude, in the path model above, is a variable that is hard to measure directly and is typically based on some multiple-item scale. The same holds true for the other three variables in the model.
Note
Traditionally, in the pre-SEM era, researchers used regression models with (independent and/or dependent) variables based on sum scores.
Satisfaction, in the model at the beginning of this module, would be defined as the sum (or more likely, the average) of items 1 to 4. Technically, satisfaction as a sum score is then added as a new and seemingly observed variable to the data set, and subsequently used as such in analyses.
Sum scores are a second-best alternative in the absence of better ways to do it.
SEM, in contrast to regression analysis, allows us to include satisfaction and loyalty as latent variables, each measured by four items with their unique variances. Using sum scores, these variances unique to the items are absorbed in the new variable, while in SEM the latent variable is free of measurement error!
Important
Why then use sum scores in SEM models?
Well, preferably, we don’t!
However, if the sample size is relatively small relative to the complexity of the model, then your software may encounter estimation problems.
One way out of this estimation issue is to reduce the complexity by falling back on sum scores. This takes away one of the advantages of using SEM (dealing with measurement error) but tends to be robust in the structural part of the model – which may be the most interesting part of the analysis.
3 Comparing Regression Analysis and SEM
From the previous section, we can conclude that SEM is a general technique that covers and integrates factor analysis and regression analysis.
In reverse, regression models are just special cases of models that can be estimated with SEM!
Since most of us are familiar with regression models, and how to interpret regression analysis output, we will proceed to show that, indeed, SEM can be used for regression analysis.
This will help you to familiarize yourself with typical SEM output, which looks very different from regression analysis.
Throughout this module, we will make use of a data set that is sampled from a much bigger data set on High-Performance Organizations (HPO; (Waal, Goedegebuure, and Hinfelaar 2015)).
3.1 The Data Set
The High-Performance Organizations (HPO) framework consists of five factors, which are measured by a total of 35 items.
We have sampled 500 responses from a large data with the responses on the questionnaire that was used to collect data from managers and employees in numerous organizations and countries across the globe.
We will use three out of the five factors. For each of these three factors we have picked the - in our view - four most salient items.
The three selected factors are:
Continuous Improvement & Renewal (CI)
Management Quality (MQ), and
Long-Term Orientation (LT).
The 12 items used to measure these factors are the following.
Item
Description
ci1
Our organization has adopted a strategy that sets it clearly apart
ci2
Everything that matters to performance is explicitly reported
ci3
We continuously innovate our core competencies
ci4
We continuously innovate our products, processes and services
mq1
My manager is a role model for organizational members
mq2
My manager coaches organizational members to achieve better results
mq3
My manager applies strong leadership
mq4
My manager holds organizational members responsible for their results
lt1
Our organization maintains good long-term relationships with stakeholders
lt2
Our organization is aimed at servicing the customers optimally
lt3
New management is promoted from within the organization
lt4
Our organization is a secure workplace
3.2 The SEM Model
Our ultimate aim in this module is to test the following model.
In the core of this diagram, CI is explained by both MQ and LT. LT is explained within the model by MQ. As a consequence, MQ has both a direct effect on CI, and an indirect effect on CI via LT.
CI, MQ and LT are latent variables (which is why they appear in ovals), measured by 4 items each (the observed variables in our data set). The latent variables are not measured, and therefore not part of the original data set!
The small circles that are connected to all (latent and observed) endogenous variables, are error variances. Error variances indicate that the endogenous variables may not be fully explained by the model.
3.3 A Regression Model in SEM
It is clear that the model above cannot be tested using one single regression analysis! In order to shed light on the full model, you would have to run at least two regression analyses: one model to regress LT on MQ, and a nother model to regress CI on MQ and LT. That’s not what we want!
But in order to show that regression analysis is a special case of SEM, we simplify the model:
We do away with the measurement part of the model.
We exclude the indirect effect of MQ on CI via LT.
This results in the following model:
We now have:
One dependent variable (CI), and
Two independent variables (MQ and LT).
These variables appear as observed variables, in rectangles. However, they are not (yet) in our data set, so we have to compute them from the observed 12 items that are part of the data set. Traditionally, we use sum scores, after making sure that the items are reliable measurements of the three factors.
Let’s go through the motions!
We will check the reliability of the 12 items as measurements of the three factors.
If reliability is OK, then we will proceed to compute sum scores for the three factors, and add them as new variables (MQ, LT, and CI) to the data.
Lastly, we will regress CI on MQ and LT using both regression analysis and an equivalent model in SEM.
3.3.1 Step 1 - Checking Reliability
We use R to test the reliability of the items used to measure the three factors.
The most widely used measure for reliability, is Cronbach’s alpha (α) (Tavakol and Dennick 2011). It is a measure of internal consistency, indicating how closely related a set of items are as a group. It does so by comparing the shared variance (or covariance) among the items to the amount of overall variance.
We use the alpha() function in R’s psych package, to perform the reliability tests.
Let’s first read the data, which are available from GitHub, and summarize the variables ci1 to ci4.
The output is massive. In addition to Cronbach’s α (.85), the output includes among others confidence intervals for α, the impact on α of dropping an item.
A Cronbach’s α of .70 is considered acceptable, and .80 is considered good. It is tempting to go for excellent (.90 or higher) but values of α close to 1 reflect very high correlations between the items - which raises the question if some of the items are not just duplications, and therefore redundant. The α of items ci1 to ci4 is OK.
Dropping an item makes sense if doing so would increase reliability. According to the output, this is not the case for any of the items ci1 to ci4, and therefore we conclude that the items are internally consistent.
The video below summarizes the interpretation of Cronbach’s α.
Although the output suggests that dropping some of the items would marginally increase the Cronbach’s α values on both factors, there is no compelling reason to do so. Since the items have been taken from a theoretical model that has been tested in many settings, dropping items would make our findings less comparable to similar studies.
3.3.2 Step 2 - Generate New Variables as Sum Scores
The Cronbach’s α scores for the three sets of items are OK. We can proceed to generate sum scores, as follows.
Code
hpoData$ci_avg <-rowMeans(hpoData[,1:4 ])hpoData$mq_avg <-rowMeans(hpoData[,5:8 ])hpoData$lt_avg <-rowMeans(hpoData[,9:12])summary(hpoData[,13:15]) # the new variables are in columns 13 to 15
ci_avg mq_avg lt_avg
Min. : 1.00 Min. : 1.00 Min. : 1.000
1st Qu.: 5.25 1st Qu.: 5.75 1st Qu.: 6.000
Median : 6.50 Median : 7.00 Median : 7.000
Mean : 6.33 Mean : 6.73 Mean : 6.955
3rd Qu.: 7.50 3rd Qu.: 8.00 3rd Qu.: 8.000
Max. :10.00 Max. :10.00 Max. :10.000
In our data set, we do not have any missing data. If you do have missing data, then you have to think of a strategy to deal with it! If some respondents miss out on one or two items then the missing data can be somehow imputed. If they miss out on most items, it is probably best to delete these cases altogether.
We are now ready to run our regressions, either using a function for regression analysis or SEM.
3.3.3 Step 3 - Regression Analysis
The variables to be used in regression analysis have been added to our data set, in the previous step.
We use R to perform a multiple regression analysis, regressing CI (the dependent variable) on the regressors MQ and LT
3.3.3.1 Regression Analysis Using lm()
In R, we use the lm() function to do the regression analysis.
For easy interpretation and comparison, we use the lm.beta() function from the QuantPsyc package to give us the standardized coefficients which are obtained after standardizing all variables to have a mean of 0 and a standard deviation of 1.
Call:
lm(formula = ci_avg ~ mq_avg + lt_avg, data = hpoData)
Residuals:
Min 1Q Median 3Q Max
-5.7253 -0.5859 0.1047 0.7145 3.7088
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.84675 0.23315 3.632 0.000311 ***
mq_avg 0.35334 0.03959 8.924 < 2e-16 ***
lt_avg 0.44648 0.04292 10.403 < 2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 1.114 on 497 degrees of freedom
Multiple R-squared: 0.5406, Adjusted R-squared: 0.5388
F-statistic: 292.5 on 2 and 497 DF, p-value: < 2.2e-16
Code
# install.packages(QuantPsyc) # if neededlibrary(QuantPsyc)lm.beta(hpoReg)
mq_avg lt_avg
0.3701947 0.4315377
The regression coefficients turn out to be positive as expected, and significant.
The coefficient of determination, R2, is .5406, indicating that 54% of the variance of CI is explained by the model.
3.3.3.2 Regression Analysis Using SEM
Our aim is to replicate the above results using SEM, which should be possible if regression analysis is indeed a special case of SEM. What makes it special is that we have neither a measurement model with latent variables, nor any indirect effects.
SEM models can be estimated using the lavaan package.
Essentially, we first have to translate model as we have drawn it in the diagram into equations. Since our regression model is simple, the code in lavaan is straightforward:
Code
# install.packages("lavaan")library(lavaan)hpoRegLavaan <-' # measurement model # regressions ci_avg ~ mq_avg + lt_avg'hpoRegLavaanFit <-sem(hpoRegLavaan, data = hpoData)summary(hpoRegLavaanFit, standardized=TRUE)
lavaan 0.6-19 ended normally after 1 iteration
Estimator ML
Optimization method NLMINB
Number of model parameters 3
Number of observations 500
Model Test User Model:
Test statistic 0.000
Degrees of freedom 0
Parameter Estimates:
Standard errors Standard
Information Expected
Information saturated (h1) model Structured
Regressions:
Estimate Std.Err z-value P(>|z|) Std.lv Std.all
ci_avg ~
mq_avg 0.353 0.039 8.951 0.000 0.353 0.370
lt_avg 0.446 0.043 10.434 0.000 0.446 0.432
Variances:
Estimate Std.Err z-value P(>|z|) Std.lv Std.all
.ci_avg 1.234 0.078 15.811 0.000 1.234 0.459
Note that the lines starting with “#” are just comment lines which can be left out. Below the “# measurement model” comment, there is no code since we do not have latent variables measured by observed variables. We only have “observed variables” which in this case are sum scores of truly observed variables.
The output of both regression analyses is extensive. We will focus on the key statistics:
The (unstandardized and standardized) regression coefficients.
The significance of the regression coefficients.
The R2, indicating how much of the variance of the dependent variable is explained by the model.
The table below summarizes the information.
The unstandardized and standardized regression coefficients in both approaches are identical. While regression analysis uses a t-test for the significance of the coefficients, SEM uses a z-test. If the sample size is large, like here, then the difference between the tests is small. The coefficients are significantly different from zero.
The model explains 54% of the variance in the dependent variable (CI). We can deduce that information from the variance of the error term of CI (or ci_avg, to be precise) in the SEM output.
SEM indeed produces the same results as regression analysis 😅 !
Warning
Maybe the use of different tests for the significance of the regression coefficients worries you.
Since SEM models are usually way more complicated than regression models, testing the significance of the coefficients follows a different approach.
Some experts actually warn against the use of the z-test, as you see in this video!
4 A SEM model
Now that we are a bit familiar with the output of SEM, and how it relates to the output of regression analysis, we can proceed to applying SEM to the more complex model we wish to estimate.
We include:
A measurement part: latent variables (for CI, MQ, and LT), and the 12 observed variables (items) that measure them.
In the structural part, a path from MQ to LT (and hence, an indirect effect of MQ on CI, via LT).
It is good practice to present the main results of the analysis in a path diagram.
Of course, you can draw the diagram yourself, e.g., in PowerPoint. Always follow the main rules:
Latent variables appear in ovals, observed variables in rectangles.
For the measurement part of the model, the arrows (normally) point from latent variables to observed variables.
For the structural part of the model, the arrows run from causes (e.g., MQ in our example) to effects (here, LT and CI).
Endogenous variables have an error variance, shown in small ovals/circles. In order to avoid clutter, the error variances are sometimes left out.
The figure below gives the SEM-diagram.
We produced the diagram in STATA. The big advantage of STATA is that you can draw the diagram in a so-called GUI (Graphical User Interface), and run the analysis directly from the diagram. Apart from the convenience (no coding needed), this assures that the estimated model and the graphical representation are aligned.
You can check for yourself that the results of the analysis in STATA are the same as in lavaan.
The results indicate that:
The coefficients are positive, and significant.
Apart from the direct effect of MQ on CI, there is a strong indirect effect of MQ on CI via LT. The total effect of MQ on CI is the sum of the direct effect plus the indirect effect. While the direct effect (.29) is directly visible from the diagram, the indirect effect has to be computed. There are options to do so within the code, but it is easy to do it by hand: the indirect effect of MQ on CI via LT is the product of the effect of MQ on LT, times the effect of LT on CI (.80*.59 = .47). The total effect of MQ on CI then is .47+.29=.76, of which the largest part (.47/.76 = 62%) is indirect.
The error term (or unexplained variance) of CI is .30, implying that the remainder (70%) of the variance of CI is explained by the model. Likewise, 65% of LT is explained by the model. MQ is an exogenous variable, and has no error term.
5 Goodness-of-Fit Statistics
How well does the model fit our data?
SEM uses several goodness-of-fit measures.
SEM starts from a covariance matrix (a matrix of variances and covariances) of the variables in the model. This matrix is used to estimate all parameters in the model, based on an estimation method (mostly the maximum likelihood method).
In reverse, the estimated parameters imply a set of variances and covariances which then can be compared to the starting matrix.
The closer the starting and implied covariance matrices are, the better the model fit.
Over time, statisticians have developed a variety of goodness-of-fit measures based on the above principle, and guidelines for what makes up a good model.
An excellent although somewhat dated overview, is provided by Hooper et al, 2008.
5.1 Chi-Square
Chi-Square (χ2) is the traditional measure for model fit. It reflects the difference between the starting covariance matrix and the one implied by the model. A good model has a χ2 close to zero. Since we hope to find a small value for χ2, it is sometimes called a badness-of-fit statistic.
χ2 is sensitive to sample size. It easily rejects the model if the sample is large.
Some prefer to use the relative version of this meaure, which divides χ2 by the degrees-of-freedom. There is no consensus on an acceptable value for this statistic. Recommendations range from 2 to 5.
χ2 is considered less relevant as a goodness-of-fit measure, but it is important in testing the significance of parameters and in improving the model, as we will see in the next sections.
5.2 RMSEA
The Root Mean Square Error of Approximation (RMSEA) is based on the same principle of comparing the observed covariance matrix to the implied one. It is considered informative because of its sensitivity to the model complexity. Low values of RMSEA indicate a good model fit. Values close to .06 or an upper limit of .07 indicate a good model fit.
An advantage of the RMSEA is that it comes with a confidence interval. In a well-fitting model the lower limit of the interval is close to 0 and the upper limit is below .08.
A related measure is pclose, the probability that RMSEA<.05. The higher pclose the better!
5.3 SRMR
The Standardized Root Mean Squared Residual (SRMR) measures how close the model comes to reproducing all correlations, on average. An SRMR of, say, .05 indicates that the model manages to reproduce correlations to .05 differences.
Values for well fitting models have an SRMR<.05, but values as high as .08 are acceptable.
5.4 CFI
Comparative fit indices compare χ2 to a baseline model.
The Comparative Fit Index (CFI) assumes that all latent variables are uncorrelated and compares the sample covariance matrix with this null model.
The values of the CFI for this statistic can range from 0 to 1, with values close to 1 indicating a good fit. A CFI of .95 or higher indicates a good fit.
5.5 Reporting Goodness-of-Fit
Hooper et al (2008) recommend to report:
χ2 including the degrees of freedom and the p-value.
RMSEA and its confidence interval, and/or pclose.
SRMR.
CFI.
A well-fitting model has the following goodness-of-fit scores:
Goodness-of-Fit Measure
Values
Comment
χ2 (df), p-value
p>.05
A low χ2 relative to the degrees-of-freedom (df). Models are easily rejected in case of large samples.
χ2/df
<5
No clear cut-off point. Values below 5 are considered acceptable.
RMSEA
<.07
.07 is considered an upper limit. A value of .03 or lower indicates a good fit.
pclose
>.05
If the value is larger than .05, then the hypothesis of an RMSEA close to .05 (indicative of a well-fitting model) is accepted.
SRMR
<.08
CFI
>.95
The Annex shows a helpful video on reporting SEM results.
5.6 Goodness-of-Fit Statistics in Our Example
In our example, we can obtain these and other goodness-of-fit statistics as follows.
Code
summary(hpofit, fit.measures=TRUE)
lavaan 0.6-19 ended normally after 34 iterations
Estimator ML
Optimization method NLMINB
Number of model parameters 27
Number of observations 500
Model Test User Model:
Test statistic 163.619
Degrees of freedom 51
P-value (Chi-square) 0.000
Model Test Baseline Model:
Test statistic 3446.768
Degrees of freedom 66
P-value 0.000
User Model versus Baseline Model:
Comparative Fit Index (CFI) 0.967
Tucker-Lewis Index (TLI) 0.957
Loglikelihood and Information Criteria:
Loglikelihood user model (H0) -10991.910
Loglikelihood unrestricted model (H1) -10910.101
Akaike (AIC) 22037.820
Bayesian (BIC) 22151.615
Sample-size adjusted Bayesian (SABIC) 22065.915
Root Mean Square Error of Approximation:
RMSEA 0.066
90 Percent confidence interval - lower 0.055
90 Percent confidence interval - upper 0.078
P-value H_0: RMSEA <= 0.050 0.009
P-value H_0: RMSEA >= 0.080 0.026
Standardized Root Mean Square Residual:
SRMR 0.033
Parameter Estimates:
Standard errors Standard
Information Expected
Information saturated (h1) model Structured
Latent Variables:
Estimate Std.Err z-value P(>|z|)
CI =~
ci1 1.000
ci2 1.162 0.075 15.410 0.000
ci3 1.237 0.072 17.204 0.000
ci4 1.025 0.065 15.804 0.000
MQ =~
mq1 1.000
mq2 1.076 0.050 21.500 0.000
mq3 1.044 0.046 22.494 0.000
mq4 0.665 0.043 15.483 0.000
LT =~
lt1 1.000
lt2 1.091 0.062 17.688 0.000
lt3 0.867 0.072 12.036 0.000
lt4 1.071 0.065 16.370 0.000
Regressions:
Estimate Std.Err z-value P(>|z|)
CI ~
MQ 0.231 0.061 3.804 0.000
LT 0.571 0.081 7.015 0.000
LT ~
MQ 0.667 0.044 15.035 0.000
Variances:
Estimate Std.Err z-value P(>|z|)
.ci1 1.979 0.142 13.956 0.000
.ci2 1.927 0.146 13.216 0.000
.ci3 1.032 0.100 10.276 0.000
.ci4 1.312 0.102 12.830 0.000
.mq1 1.426 0.115 12.405 0.000
.mq2 1.415 0.120 11.817 0.000
.mq3 1.028 0.097 10.644 0.000
.mq4 1.731 0.119 14.599 0.000
.lt1 1.464 0.115 12.709 0.000
.lt2 1.285 0.111 11.564 0.000
.lt3 3.293 0.223 14.800 0.000
.lt4 1.813 0.140 12.946 0.000
.CI 0.572 0.083 6.884 0.000
MQ 2.900 0.268 10.823 0.000
.LT 0.700 0.096 7.290 0.000
Summarizing the results:
Goodness-of-Fit Measure
Value
χ2 (df); p-value
χ2(51) = 163.6; p=0.00 (poor fit)
χ2/df
163.6 / 51 = 3.2 (good)
RMSEA
.066 (interval .055 - .078). Acceptable or good.
pclose
P(RMSEA<.05) = .009 (the probability that the RMSEA is close to that of a well-fitting model, is small).
P(RMSEA>.08) = .026 (the probability that the RMSEA is higher than a poorly fitting model is also small)
SRMR
.033 (good)
CFI
.967 (good)
Considering or remarks on χ2 as a measure of fit, the key statistics look OK.
6 Improving the Model
Since our hypothesized is supported by the data, there is no need to make amendments.
Should the model not fit the data well, then we can dig deeper.
Although the model is not overly complicated, we have excluded a lot of potential paths!
For example, our latent variable CI is only measured by the four items ci1 to ci4, and not by any of the other observed variables (items). We assume, for the validity of our measurements, that the effect of latent variables MQ and LT on the responses ci1 to ci4 is zero.
By fixing a lot of such paths to zero, we reduce the number of parameters to be estimated, thereby increasing the degrees-of-freedom. By adding one path to the model, we will produce a better fit at the cost of giving up a degree of freedom.
We can use trial-and-error to add paths to the model, but in relatively complex models this would be a tedious job.
Luckily, SEM software can do the job for us, using so-called modification indices option. The result of this option gives an estimate of the reduction in χ2 by adding a path to the model.
Warning
It is highly recommend not to add paths blindly in search of a good model fit. There has to be a clear (theoretical) justification to add a path!
In many cases, browsing through the modification indices output will give you an idea of items that for some reason cause problems.
Rather than adding paths that are hard to explain or justify, it is often better leave out problematic items.
Although there is no need to modify our model, we will illustrate the modification indices below.
Code
modindices(hpofit, sort =TRUE, maximum.number =8)
We have opted for a maximum of 8 paths, in the output. By sorting (in descending order) on the size of the modification indices (mi, in the output), the function returns the paths which - if added - lead to the highest reductions in χ2.
In the table we encounter something that we have not discussed before. Some pairs of variables are linked by a double tilde (“~~”). The double tilde signifies a covariance between variables or between error terms. For example, if we would add a covariance term between the error terms of mq1 and mq2, then χ2 would be reduced by an estimated 22, down from 163.
But why would we add this covariance? Apart from the fact that our model performs fine, the issue is probably caused by the fact that responses to items mq1 and mq2 differ from the other mq items.
Item lt4 appears thrice in the list of 8 paths, and in relation to latent variables (CI) and measurements (mq4) that are not connected theoretically. If lt4 confuses respondents or can be considered a measurement of other latent variables in addition to LT, then it may be wise to drop the item. It is best to base such decisions on reasoning rather than on the wish to increase the model fit!
Tip
Measurement using multiple item scales can get very complicated. Some of the issues and how to treat them in SEM are well-documented (Goedegebuure and Adhikari 2023).
7 SEM the User-Friendly Way
We have covered the most important elements of SEM, and explained the key terms.
Everything you have learned in this module should enable you to apply SEM to your own data, using the software of your preference.
There is a lot of powerful software available for SEM.
We will go over some of the software packages, and their pros and cons.
7.1 SEM Using STATA or AMOS
In terms of user-friendliness, some commercial software packages are the best.
Like R, commercial software like STATA and IBM SPSS cover a broad range of basic and advanced statistical techniques.
STATA and Amos (of IBM SPSS) can be used for SEM via Graphical User Interfaces (GUIs). The GUIs allow you to focus on the contours of the model and thereby avoid error-prone and tedious coding. The coding is done behind the scenes.
In addition, commercial software have excellent tutorials to help you on the way.
The main disadvantage is that commercial software is expensive.
7.2 SEM Using R/lavaan
It is fairly easy to run SEM using the lavaan package in R.
One of the good things about lavaan are the excellent documentation and tutorials, including the easy-to-follow examples.
A drawback is that it is harder to obtain publication-quality path diagrams - let alone that you can fit your model from a GUI like in STATA or AMOS. That is, coding cannot be avoided.
There are packages that allow you to produce path diagrams with the main results of the analysis, which is good but adds to the burden of coding.
7.3 SEM Using JASP
An alternative is to use JASP. JASP can be downloaded for free.
JASP positions itself as a fresh way to do statistics - which is a fair claim! JASP is definitely designed with the user in mind. It can perform a wide range of descriptive and inferential statistics, and is a great option for most researchers and for most statistical challenges.
JASP can run SEM-models with limited coding, and the option to generate a high-quality path diagram.
It makes use of R and lavaan but in the background.
The only coding that comes in, is the lavaan-like model specification.
The measurement part of the model specifies the latent variables and their measurements, in (following our example) CI =~ c1+c2+c3+c4 specification.
The structural part follows the regression notation of R: CI ~ MQ+LT
In some cases, it makes sense to add covariances (or correlations, in the standardized version) to error terms. Covariances are specified by a double tilde (~~).
After reading your data into JASP, you only have to specify the model which follows the rules of lavaan. Optionally, the output contains a SEM diagram.
The following video shows you how to run SEM models in JASP.
The data, and the JASP-file, can be found on GitHub.
Once you have downloaded JASP you can download and open the file, and inspect the input and the output. Feel free to play around with the various options, and maybe to adapt the model!
Some things to be aware of:
SEM does not show up in the standard menu of JASP. You can add SEM and many other techniques to the menu, easily.
After loading your data to JASP, you have to check that the variables to be used in SEM are (interval or ratio) scale data, rather than nominal or ordinal data. SEM gives an error message when your variables are not scale (i.e., nominal or ordinal).
The SEM-diagram is great, but in the version of JASP used in this module the coefficients are the unstandardized ones. The standardized coefficients do appear in the results, but cannot be printed in the diagram. Hopefully this will be fixed in next versions of the software.
7.4 SEM Using Jamovi
There’s another tool which is remarkably similar to JASP, called Jamovi.
SEM can be added to Jamovi’s menu. And, like JASP, Jamovi also makes use of R and lavaan, in the background.
There are slight differences between SEM in JASP and Jamovi.
SEM in Jamovi can be done interactively, implying even less coding.
The SEM diagram of Jamovi does offer the option to print standardized estimates, which helps.
Jamovi - at least in the interactive option - forces users to make a distinction between exogenous and endogenous (latent) variables, but the use of the terms is inconsistent, or even irrelevant. Anyway, it’s confusing.
While JASP can handle path models (without latent variables) easily, it is probably possible but not very clear how to run path models in Jamovi the interactive mode.
After downloading Jamovi, you can download and open the Jamovi file with the data and SEM analysis, from Github.
The screenshot below includes the only lines of lavaan-like coding that is required to run the model. The structural part of the model has to be specified in the custom model settings.
Any covariances between error terms can be added in the variances and covariances section. For the sake of the example, we have added a covariance between the error terms of mq1 and mq2, which (according to the output of lavaan, JASP, and Jamovi) would reduce the χ2 by 22, down from 164.
By adding one parameter, we decrease the degrees-of-freedom by one, from 51 to 50. Apart from an improvement in all other goodness-of-fit statistics as well, the regression coefficients are slightly different from the earlier model.
8 Annexes
8.1 SEM in R/lavaan (including path diagrams)
8.2 SEM in JASP
8.3 SEM in Jamovi
Part 1:
Part 2:
8.4 Reporting SEM Results
References
Goedegebuure, Robert, and Manorama Adhikari. 2023. “Factor Analysis: Dealing with Response Bias.”International Journal of Business and Management Research 11 (1): 25–33. https://doi.org/10.37391/ijbmr.110103.
Parasuraman, A., Valarie A. Zeithaml, and Leonard L. Berry. 1985. “A Conceptual Model of Service Quality and Its Implications for Future Research.”Journal of Marketing 49 (4): 41–50. https://doi.org/10.1177/002224298504900403.
Tavakol, Mohsen, and Reg Dennick. 2011. “Making Sense of Cronbach’s Alpha.”International Journal of Medical Education 2 (June): 53–55. https://doi.org/10.5116/ijme.4dfb.8dfd.
Waal, André de, Robert Goedegebuure, and Eveline Hinfelaar. 2015. “Developing a Scale for Measuring High Performance Partnerships.”Journal of Strategy and Management 8 (1): 87–108. https://doi.org/10.1108/jsma-07-2014-0065.
Source Code
---title: "SEM (Structural Equation Modeling)"author: "HAN University of Applied Sciences"date: 2024/10/14format: html: df-print: paged code-fold: true code-tools: truenumber-sections: truetoc: truetoc-depth: 5toc-title: In this e-bookeditor: visualbibliography: references.bib---## Take-AwaysThis module introduces Structural Equation Modeling (SEM).SEM is a sophisticated statistical approach that enables researchers to analyze the relationships between observed variables and underlying latent constructs.You will learn:1. The basic concepts of SEM.2. The key terms used in SEM: latent and observed variables; reliability; direct and indirect effects; and path diagrams.3. The types of models you can analyze (confirmatory factor analysis; path models; and models that combine factor analysis and regression models).4. How SEM as a general technique can be used to estimate regression models as a special case.5. How to evaluate and improve your model: goodness-of-fit statistics and modification indices.6. How to report the results of SEM, including a visualization.7. How to specify and run SEM-models in R's *lavaan* package, or with user-friendly tools (JASP and Jamovi) which are based on *lavaan*.## What is Structural Equation Modeling?### IntroductionStructural equation modeling (SEM) is used for estimating causal relationships among variables.SEM is a combination of two techniques discussed in other modules:\- Factor analysis, and\- Regression analysis.#### Factor Analysis & MeasurementTypically, in social and economic research we make use of multiple item scales to measure concepts that are hard to measure directly.Single-item measures are often tricky. They are vulnerable to biases of meaning and interpretation.Multiple-item scales are designed to cover the full range of a construct, while single items tend to have narrow and/or ambiguous interpretations.> While it may seem easy for a hotel guest to answer one single question on his or her satisfaction with their stay, satisfaction is the result of differences between expected and perceived aspects (or dimensions) of service quality. Each of these aspects is indicated or measured by several items, as described in a general model of service quality like the SERVQUAL model [@parasuraman1985].The dimensions and the items to measure them are often based on extensive research, in which many items are proposed and analyzed using (exploratory) factor analysis.Once there is agreement on the definition of several constructs and their measurement, then we can use questionnaires on these constructs for a quantitative assessment.#### Regression Analysis and Causal ResearchWhen doing applied research on (causal) relationships, we often start from existing theories. We can conduct a survey that makes use of a questionnaire based on, for instance, the SERVQUAL model.We would still be interested in the reliability of the items measuring our constructs, but mainly to confirm the theory rather than to explore.SEM models often combine measurement and causal research within one model. These models are visualized in *path diagrams*.A path diagram for a research model on customer satisfaction and loyalty can look like this.{width="80%"}In this path diagram we see:- The constructs satisfaction and loyalty in ovals. Since these constructs are not measured directly, they are called *latent variables*. These constructs are also referred to as *factors or dimensions*.- The constructs are measured or indicated by *items*, which are the *(observed) variables*. Observed variables appear as rectangles in what we call a *path diagram*.> It is hard to understand why the arrows point from the latent variables to their measurements, rather than the other way around.>> The idea is that the responses (observed scores on measurements) are caused by some latent variable. Each answer to an item (e.g., the respondent's intention to recommend the hotel to others) is partly caused by the latent variable loyalty.- The circles with the Greek letters ε (pronounced *epsilon*) indicate that the items are not fully explained by the latent variable but have a unique, unexplained variance. Even though our respondent is very loyal to the hotel and plans to go back whenever he can, he may still have reasons not to recommend the hotel to family and friends (maybe he doesn't have any)! But by and large, we would expect that items are positively correlated, and jointly form valid and reliable measurements of their constructs.- The above remarks are related to the *measurement part of the model*. The (causal) relation between satisfaction and loyalty is referred to as the *structural part*.- While in regression analysis, we are typically dealing with one dependent variable, and one or more independent variables, SEM-models can be more complex. In the figure below, *overall customer satisfaction* is a latent variable which explains customer loyalty but is also explained by other latent variables (*perceived quality, perceived value, and customer expectations*).{width="80%"}- Complex models like this contain complex patterns of causality. Satisfaction is explained directly by customer expectations, and indirectly, via the impact of customer expectations on perceived quality. These direct and indirect effects are relevant from both a theoretical and practical point of view.- This model complexity calls for a different terminology from what we are used to in regression analysis. In regression analysis, variables are either dependent or independent. In SEM, variables (like overall customer satisfaction in the figure above), can be both dependent and independent! For that reason, we speak of *endogenous* and *exogenous* variables. Exogenous variables are all (latent or observed variables) that do not have an arrow pointing to them. Endogenous are all other variables, which are explained within the model.In summary, structural equation models represent causal relationships between latent and observed variables.- Observed variables can be measured directly.- Latent variables cannot be measured directly.Full SEM-models consist of two parts.- A *measurement part*, and- A *structural part*.The measurement model specifies the relationships between observed variables and latent variables, while the structural model specifies the causal relationships between variables.SEM-models may lack either a measurement part or a structural part!### Confirmatory Factor Analysis (CFA)Confirmatory Factor Analysis (CFA) is a type of SEM-model used to test the validity of measurement models. It verifies whether the observed data fit a pre-specified model. A structural part is missing.An example of a CFA-model is depicted below. This example is based on the [Holzinger-Swineford data](https://search.r-project.org/CRAN/refmans/lavaan/html/HolzingerSwineford1939.html) used in many papers and books on SEM.A short version of the data set consists of mental ability test scores, with 9 observed variables on 3 factors. The two-sided arrows between the latent variables indicate that the latent variables are correlated.Note that this simplified graphical representation is incomplete: the observed variables are bound to have a unique variance which is not shown for the sake of simplicity.{width="80%"}### Path AnalysisPath Analysis is a SEM-model that includes observed variables only.In a graphical representation, a path analysis model only has rectangles, and no ovals (not counting the variances of the endogenous observed variables).{width="80%"}It is probably here that confusion sets in! 😕Attitude, in the path model above, is a variable that is hard to measure directly and is typically based on some multiple-item scale. The same holds true for the other three variables in the model.::: callout-noteTraditionally, in the pre-SEM era, researchers used regression models with (independent and/or dependent) variables based on *sum scores*.Satisfaction, in the model at the beginning of this module, would be defined as the sum (or more likely, the average) of items 1 to 4. Technically, satisfaction as a sum score is then added as a new and seemingly observed variable to the data set, and subsequently used as such in analyses.:::Sum scores are a second-best alternative in the absence of better ways to do it.SEM, in contrast to regression analysis, allows us to include satisfaction and loyalty as latent variables, each measured by four items with their unique variances. Using sum scores, these variances unique to the items are absorbed in the new variable, while in SEM the latent variable is *free of measurement error*!::: callout-importantWhy then use sum scores in SEM models?Well, preferably, we don't!However, if the sample size is relatively small relative to the complexity of the model, then your software may encounter *estimation problems*.One way out of this estimation issue is to reduce the complexity by falling back on sum scores. This takes away one of the advantages of using SEM (dealing with measurement error) but tends to be robust in the structural part of the model -- which may be the most interesting part of the analysis.:::## Comparing Regression Analysis and SEMFrom the previous section, we can conclude that SEM is a general technique that covers and integrates factor analysis and regression analysis.In reverse, regression models are just special cases of models that can be estimated with SEM!Since most of us are familiar with regression models, and how to interpret regression analysis output, we will proceed to show that, indeed, SEM can be used for regression analysis.This will help you to familiarize yourself with typical SEM output, which looks very different from regression analysis.Throughout this module, we will make use of a data set that is sampled from a much bigger data set on High-Performance Organizations (HPO; [@dewaal2015]).### The Data SetThe High-Performance Organizations (HPO) framework consists of five factors, which are measured by a total of 35 items.{width="70%"}We have sampled 500 responses from a large data with the responses on the questionnaire that was used to collect data from managers and employees in numerous organizations and countries across the globe.We will use three out of the five factors. For each of these three factors we have picked the - in our view - four most salient items.The three selected factors are:1. Continuous Improvement & Renewal (CI)2. Management Quality (MQ), and3. Long-Term Orientation (LT).The 12 items used to measure these factors are the following.+-------------+---------------------------------------------------------------------------+| Item | Description |+=============+===========================================================================+| **ci1** | Our organization has adopted a strategy that sets it clearly apart |+-------------+---------------------------------------------------------------------------+| **ci2** | Everything that matters to performance is explicitly reported |+-------------+---------------------------------------------------------------------------+| **ci3** | We continuously innovate our core competencies |+-------------+---------------------------------------------------------------------------+| **ci4** | We continuously innovate our products, processes and services |+-------------+---------------------------------------------------------------------------+| **mq1** | My manager is a role model for organizational members |+-------------+---------------------------------------------------------------------------+| **mq2** | My manager coaches organizational members to achieve better results |+-------------+---------------------------------------------------------------------------+| **mq3** | My manager applies strong leadership |+-------------+---------------------------------------------------------------------------+| **mq4** | My manager holds organizational members responsible for their results |+-------------+---------------------------------------------------------------------------+| **lt1** | Our organization maintains good long-term relationships with stakeholders |+-------------+---------------------------------------------------------------------------+| **lt2** | Our organization is aimed at servicing the customers optimally |+-------------+---------------------------------------------------------------------------+| **lt3** | New management is promoted from within the organization |+-------------+---------------------------------------------------------------------------+| **lt4** | Our organization is a secure workplace |+-------------+---------------------------------------------------------------------------+### The SEM ModelOur ultimate aim in this module is to test the following model.{width="80%"}In the core of this diagram, CI is explained by both MQ and LT. LT is explained within the model by MQ. As a consequence, MQ has both a direct effect on CI, and an indirect effect on CI via LT.CI, MQ and LT are latent variables (which is why they appear in ovals), measured by 4 items each (the observed variables in our data set). The latent variables are not measured, and therefore not part of the original data set!The small circles that are connected to all (latent and observed) endogenous variables, are error variances. Error variances indicate that the endogenous variables may not be fully explained by the model.### A Regression Model in SEMIt is clear that the model above cannot be tested using one single regression analysis! In order to shed light on the full model, you would have to run at least two regression analyses: one model to regress LT on MQ, and a nother model to regress CI on MQ and LT. That's not what we want!But in order to show that regression analysis is a special case of SEM, we simplify the model:- We do away with the measurement part of the model.- We exclude the indirect effect of MQ on CI via LT.This results in the following model:{width="80%"}We now have:- One dependent variable (CI), and- Two independent variables (MQ and LT).These variables appear as observed variables, in rectangles. However, they are not (yet) in our data set, so we have to compute them from the observed 12 items that are part of the data set. Traditionally, we use sum scores, after making sure that the items are reliable measurements of the three factors.Let's go through the motions!1. We will check the *reliability* of the 12 items as measurements of the three factors.2. If reliability is OK, then we will proceed to compute *sum scores* for the three factors, and add them as new variables (MQ, LT, and CI) to the data.3. Lastly, we will regress CI on MQ and LT using both regression analysis and an equivalent model in SEM.#### Step 1 - Checking ReliabilityWe use R to test the reliability of the items used to measure the three factors.The most widely used measure for reliability, is Cronbach's alpha (α) [@tavakol2011]. It is a measure of *internal consistency*, indicating how closely related a set of items are as a group. It does so by comparing the shared variance (or covariance) among the items to the amount of overall variance.We use the *alpha()* function in R's *psych* package, to perform the reliability tests.Let's first read the data, which are available from [GitHub](https://github.com/statmind/jasp_sem), and summarize the variables **ci1** to **ci4**.```{r}hpoData <-read.csv("https://raw.githubusercontent.com/statmind/jasp_sem/refs/heads/main/jasp_hpo_csv.csv", header=TRUE)hpoDatasummary(hpoData[1:4])```The items used to measure CI are in the first four columns of the data set. We can compute the Cronbach's α statistic as follows.```{r}# install.packages("psych") library(psych)alpha(hpoData[,1:4]) # reliability of the ci-items```The output is massive. In addition to Cronbach's α (.85), the output includes among others confidence intervals for α, the impact on α of dropping an item.A Cronbach's α of .70 is considered acceptable, and .80 is considered good. It is tempting to go for excellent (.90 or higher) but values of α close to 1 reflect very high correlations between the items - which raises the question if some of the items are not just duplications, and therefore redundant. The α of items **ci1** to **ci4** is OK.Dropping an item makes sense if doing so would increase reliability. According to the output, this is not the case for any of the items **ci1** to **ci4**, and therefore we conclude that the items are *internally consistent*.The video below summarizes the interpretation of Cronbach's α.<iframewidth="560"height="315"src="https://www.youtube.com/embed/W9uPvAmtTOk?si=Af8QN6r-xyj6oD5a"title="YouTube video player"frameborder="0"allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"referrerpolicy="strict-origin-when-cross-origin"allowfullscreen></iframe>We do the the same for MQ and LT:```{r}alpha(hpoData[,5:8])alpha(hpoData[,9:12])```Although the output suggests that dropping some of the items would marginally increase the Cronbach's α values on both factors, there is no compelling reason to do so. Since the items have been taken from a theoretical model that has been tested in many settings, dropping items would make our findings less comparable to similar studies.#### Step 2 - Generate New Variables as Sum ScoresThe Cronbach's α scores for the three sets of items are OK. We can proceed to generate sum scores, as follows.```{r}hpoData$ci_avg <-rowMeans(hpoData[,1:4 ])hpoData$mq_avg <-rowMeans(hpoData[,5:8 ])hpoData$lt_avg <-rowMeans(hpoData[,9:12])summary(hpoData[,13:15]) # the new variables are in columns 13 to 15```> In our data set, we do not have any missing data. If you do have missing data, then you have to think of a strategy to deal with it! If some respondents miss out on one or two items then the missing data can be somehow *imputed*. If they miss out on most items, it is probably best to delete these cases altogether.We are now ready to run our regressions, either using a function for regression analysis or SEM.#### Step 3 - Regression AnalysisThe variables to be used in regression analysis have been added to our data set, in the previous step.We use R to perform a multiple regression analysis, regressing CI (the dependent variable) on the *regressors* MQ and LT##### Regression Analysis Using *lm()*In R, we use the *lm()* function to do the regression analysis.For easy interpretation and comparison, we use the *lm.beta()* function from the *QuantPsyc package* to give us the *standardized coefficients* which are obtained after standardizing all variables to have a mean of 0 and a standard deviation of 1.```{r message=FALSE, warning=FALSE}hpoReg <-lm(ci_avg ~ mq_avg + lt_avg, data=hpoData)summary(hpoReg)# install.packages(QuantPsyc) # if neededlibrary(QuantPsyc)lm.beta(hpoReg)```The regression coefficients turn out to be positive as expected, and significant.The *coefficient of determination*, *R^2^*, is .5406, indicating that 54% of the variance of CI is explained by the model.##### Regression Analysis Using SEMOur aim is to replicate the above results using SEM, which should be possible if regression analysis is indeed a special case of SEM. What makes it special is that we have neither a measurement model with latent variables, nor any indirect effects.SEM models can be estimated using the *lavaan* package.Essentially, we first have to translate model as we have drawn it in the diagram into equations. Since our regression model is simple, the code in *lavaan* is straightforward:```{r message=FALSE, warning=FALSE}# install.packages("lavaan")library(lavaan)hpoRegLavaan <-' # measurement model # regressions ci_avg ~ mq_avg + lt_avg'hpoRegLavaanFit <-sem(hpoRegLavaan, data = hpoData)summary(hpoRegLavaanFit, standardized=TRUE)```Note that the lines starting with "\#" are just comment lines which can be left out. Below the "*\# measurement model*" comment, there is no code since we do not have latent variables measured by observed variables. We only have "observed variables" which in this case are sum scores of truly observed variables.The output of both regression analyses is extensive. We will focus on the key statistics:1. The (unstandardized and standardized) *regression coefficients*.2. The *significance of the regression coefficients*.3. The *R^2^*, indicating how much of the variance of the dependent variable is explained by the model.The table below summarizes the information.The unstandardized and standardized regression coefficients in both approaches are identical. While regression analysis uses a t-test for the significance of the coefficients, SEM uses a z-test. If the sample size is large, like here, then the difference between the tests is small. The coefficients are significantly different from zero.The model explains 54% of the variance in the dependent variable (CI). We can deduce that information from the variance of the error term of CI (or **ci_avg**, to be precise) in the SEM output.{width="100%"}SEM indeed produces the same results as regression analysis 😅 !::: callout-warningMaybe the use of different tests for the significance of the regression coefficients worries you.Since SEM models are usually way more complicated than regression models, testing the significance of the coefficients follows a different approach.Some experts actually warn against the use of the z-test, as you see in this [video](https://youtu.be/jqcyMuGKWo4?si=y6-2KZvGQnrpXgj9)!:::## A SEM modelNow that we are a bit familiar with the output of SEM, and how it relates to the output of regression analysis, we can proceed to applying SEM to the more complex model we wish to estimate.We include:- A *measurement part*: latent variables (for CI, MQ, and LT), and the 12 observed variables (items) that measure them.- In the *structural part*, a path from MQ to LT (and hence, an indirect effect of MQ on CI, via LT).```{r}hpoSEM <-' # measurement model CI =~ ci1 + ci2 + ci3 + ci4 MQ =~ mq1 + mq2 + mq3 + mq4 LT =~ lt1 + lt2 + lt3 + lt4 # regressions CI ~ MQ + LT LT ~ MQ'hpofit <-sem(hpoSEM, data = hpoData)summary(hpofit, standardized =TRUE)```It is good practice to present the main results of the analysis in a *path diagram*.Of course, you can draw the diagram yourself, e.g., in PowerPoint. Always follow the main rules:- Latent variables appear in ovals, observed variables in rectangles.- For the measurement part of the model, the arrows (normally) point from latent variables to observed variables.- For the structural part of the model, the arrows run from causes (e.g., MQ in our example) to effects (here, LT and CI).- Endogenous variables have an error variance, shown in small ovals/circles. In order to avoid clutter, the error variances are sometimes left out.The figure below gives the SEM-diagram.We produced the diagram in STATA. The big advantage of STATA is that you can draw the diagram in a so-called GUI (Graphical User Interface), and run the analysis directly from the diagram. Apart from the convenience (no coding needed), this assures that the estimated model and the graphical representation are aligned.You can check for yourself that the results of the analysis in STATA are the same as in *lavaan*.{width="100%"}The results indicate that:- The coefficients are positive, and significant.- Apart from the direct effect of MQ on CI, there is a strong indirect effect of MQ on CI via LT. The total effect of MQ on CI is the sum of the direct effect plus the indirect effect. While the direct effect (.29) is directly visible from the diagram, the indirect effect has to be computed. There are options to do so within the code, but it is easy to do it by hand: the indirect effect of MQ on CI via LT is the product of the effect of MQ on LT, times the effect of LT on CI (.80\*.59 = .47). The total effect of MQ on CI then is .47+.29=.76, of which the largest part (.47/.76 = 62%) is indirect.- The error term (or unexplained variance) of CI is .30, implying that the remainder (70%) of the variance of CI is explained by the model. Likewise, 65% of LT is explained by the model. MQ is an exogenous variable, and has no error term.## Goodness-of-Fit StatisticsHow well does the model fit our data?SEM uses several goodness-of-fit measures.SEM starts from a *covariance matrix* (a matrix of variances and covariances) of the variables in the model. This matrix is used to estimate all parameters in the model, based on an estimation method (mostly the *maximum likelihood* method).In reverse, the estimated parameters imply a set of variances and covariances which then can be compared to the starting matrix.The closer the starting and implied *covariance matrices* are, the better the model fit.Over time, statisticians have developed a variety of goodness-of-fit measures based on the above principle, and guidelines for what makes up a good model.An excellent although somewhat dated overview, is provided by [Hooper et al, 2008](https://academic-publishing.org/index.php/ejbrm/article/view/1224/1187).### Chi-SquareChi-Square (χ^2^) is the traditional measure for model fit. It reflects the difference between the starting covariance matrix and the one implied by the model. A good model has a χ^2^ close to zero. Since we hope to find a small value for χ^2^, it is sometimes called a badness-of-fit statistic.χ^2^ is sensitive to sample size. It easily rejects the model if the sample is large.Some prefer to use the relative version of this meaure, which divides χ^2^ by the degrees-of-freedom. There is no consensus on an acceptable value for this statistic. Recommendations range from 2 to 5.χ^2^ is considered less relevant as a goodness-of-fit measure, but it is important in testing the significance of parameters and in improving the model, as we will see in the next sections.### RMSEAThe Root Mean Square Error of Approximation (RMSEA) is based on the same principle of comparing the observed covariance matrix to the implied one. It is considered informative because of its sensitivity to the model complexity. Low values of RMSEA indicate a good model fit. Values close to .06 or an upper limit of .07 indicate a good model fit.An advantage of the RMSEA is that it comes with a confidence interval. In a well-fitting model the lower limit of the interval is close to 0 and the upper limit is below .08.A related measure is *p~close~*, the probability that RMSEA\<.05. The higher *p~close~* the better!### SRMRThe Standardized Root Mean Squared Residual (SRMR) measures how close the model comes to reproducing all correlations, on average. An SRMR of, say, .05 indicates that the model manages to reproduce correlations to .05 differences.Values for well fitting models have an SRMR\<.05, but values as high as .08 are acceptable.### CFIComparative fit indices compare χ^2^ to a *baseline model*.The Comparative Fit Index (CFI) assumes that all latent variables are uncorrelated and compares the sample covariance matrix with this null model.The values of the CFI for this statistic can range from 0 to 1, with values close to 1 indicating a good fit. A CFI of .95 or higher indicates a good fit.### Reporting Goodness-of-FitHooper *et al* (2008) recommend to report:- χ^2^ including the degrees of freedom and the p-value.- RMSEA and its confidence interval, and/or p~close~.- SRMR.- CFI.A well-fitting model has the following goodness-of-fit scores:+-------------------------+----------+---------------------------------------------------------------------------------------------------------------------------------+| Goodness-of-Fit Measure | Values | Comment |+=========================+==========+=================================================================================================================================+| χ^2^ (df), p-value | p\>.05 | A low χ^2^ relative to the degrees-of-freedom (df). Models are easily rejected in case of large samples. |+-------------------------+----------+---------------------------------------------------------------------------------------------------------------------------------+| χ^2^/df | \<5 | No clear cut-off point. Values below 5 are considered acceptable. |+-------------------------+----------+---------------------------------------------------------------------------------------------------------------------------------+| RMSEA | \<.07 | .07 is considered an upper limit. A value of .03 or lower indicates a good fit. |+-------------------------+----------+---------------------------------------------------------------------------------------------------------------------------------+| p~close~ | \>.05 | If the value is larger than .05, then the hypothesis of an RMSEA close to .05 (indicative of a well-fitting model) is accepted. |+-------------------------+----------+---------------------------------------------------------------------------------------------------------------------------------+| SRMR | \<.08 | |+-------------------------+----------+---------------------------------------------------------------------------------------------------------------------------------+| CFI | \>.95 | |+-------------------------+----------+---------------------------------------------------------------------------------------------------------------------------------+The Annex shows a helpful video on reporting SEM results.### Goodness-of-Fit Statistics in Our ExampleIn our example, we can obtain these and other goodness-of-fit statistics as follows.```{r}summary(hpofit, fit.measures=TRUE)```Summarizing the results:+-------------------------+-----------------------------------------------------------------------------------------------------------+| Goodness-of-Fit Measure | Value |+=========================+===========================================================================================================+| χ^2^ (df); p-value | χ^2^(51) = 163.6; p=0.00 (poor fit) |+-------------------------+-----------------------------------------------------------------------------------------------------------+| χ^2^/df | 163.6 / 51 = 3.2 (good) |+-------------------------+-----------------------------------------------------------------------------------------------------------+| RMSEA | .066 (interval .055 - .078). Acceptable or good. |+-------------------------+-----------------------------------------------------------------------------------------------------------+| p~close~ | P(RMSEA\<.05) = .009 (the probability that the RMSEA is close to that of a well-fitting model, is small). || | || | P(RMSEA\>.08) = .026 (the probability that the RMSEA is higher than a poorly fitting model is also small) |+-------------------------+-----------------------------------------------------------------------------------------------------------+| SRMR | .033 (good) |+-------------------------+-----------------------------------------------------------------------------------------------------------+| CFI | .967 (good) |+-------------------------+-----------------------------------------------------------------------------------------------------------+Considering or remarks on χ^2^ as a measure of fit, the key statistics look OK.## Improving the ModelSince our hypothesized is supported by the data, there is no need to make amendments.Should the model not fit the data well, then we can dig deeper.Although the model is not overly complicated, we have excluded a lot of potential paths!For example, our latent variable CI is only measured by the four items **ci1** to **ci4**, and not by any of the other observed variables (items). We assume, for the validity of our measurements, that the effect of latent variables MQ and LT on the responses **ci1** to **ci4** is zero.By fixing a lot of such paths to zero, we reduce the number of parameters to be estimated, thereby increasing the *degrees-of-freedom*. By adding one path to the model, we will produce a better fit at the cost of giving up a degree of freedom.We can use *trial-and-error* to add paths to the model, but in relatively complex models this would be a tedious job.Luckily, SEM software can do the job for us, using so-called *modification indices* option. The result of this option gives an estimate of the reduction in χ^2^ by adding a path to the model.::: callout-warningIt is highly recommend not to add paths blindly in search of a good model fit. There has to be a clear (theoretical) justification to add a path!In many cases, browsing through the *modification indices* output will give you an idea of items that for some reason cause problems.Rather than adding paths that are hard to explain or justify, it is often better leave out problematic items.:::Although there is no need to modify our model, we will illustrate the modification indices below.```{r}modindices(hpofit, sort =TRUE, maximum.number =8)```We have opted for a maximum of 8 paths, in the output. By sorting (in descending order) on the size of the modification indices (**mi**, in the output), the function returns the paths which - if added - lead to the highest reductions in χ^2^.In the table we encounter something that we have not discussed before. Some pairs of variables are linked by a double tilde ("\~\~"). The double tilde signifies a covariance between variables or between error terms. For example, if we would add a covariance term between the error terms of **mq1** and **mq2**, then χ^2^ would be reduced by an estimated 22, down from 163.But why would we add this covariance? Apart from the fact that our model performs fine, the issue is probably caused by the fact that responses to items **mq1** and **mq2** differ from the other **mq** items.Item **lt4** appears thrice in the list of 8 paths, and in relation to latent variables (CI) and measurements (**mq4**) that are not connected theoretically. If **lt4** confuses respondents or can be considered a measurement of other latent variables in addition to LT, then it may be wise to drop the item. It is best to base such decisions on reasoning rather than on the wish to increase the model fit!::: callout-tipMeasurement using multiple item scales can get very complicated. Some of the issues and how to treat them in SEM are well-documented [@goedegebuure2023].:::## SEM the User-Friendly WayWe have covered the most important elements of SEM, and explained the key terms.Everything you have learned in this module should enable you to apply SEM to your own data, using the software of your preference.There is a lot of powerful software available for SEM.We will go over some of the software packages, and their pros and cons.### SEM Using STATA or AMOSIn terms of user-friendliness, some commercial software packages are the best.Like R, commercial software like STATA and IBM SPSS cover a broad range of basic and advanced statistical techniques.STATA and Amos (of IBM SPSS) can be used for SEM via Graphical User Interfaces (GUIs). The GUIs allow you to focus on the contours of the model and thereby avoid error-prone and tedious coding. The coding is done behind the scenes.In addition, commercial software have excellent tutorials to help you on the way.The main disadvantage is that commercial software is expensive.### SEM Using R/lavaanIt is fairly easy to run SEM using the *lavaan* package in R.One of the good things about lavaan are the excellent [documentation and tutorials](https://lavaan.ugent.be/), including the easy-to-follow examples.A drawback is that it is harder to obtain publication-quality path diagrams - let alone that you can fit your model from a GUI like in STATA or AMOS. That is, coding cannot be avoided.There are packages that allow you to produce path diagrams with the main results of the analysis, which is good but adds to the burden of coding.### SEM Using JASPAn alternative is to use [JASP](https://jasp-stats.org/). JASP can be downloaded for free.JASP positions itself as a fresh way to do statistics - which is a fair claim! JASP is definitely designed with the user in mind. It can perform a wide range of descriptive and inferential statistics, and is a great option for most researchers and for most statistical challenges.JASP can run SEM-models with limited coding, and the option to generate a high-quality path diagram.It makes use of R and *lavaan* but in the background.The only coding that comes in, is the *lavaan*-like model specification.{width="100%"}- The measurement part of the model specifies the latent variables and their measurements, in (following our example) *CI =\~ c1+c2+c3+c4* specification.- The structural part follows the regression notation of R: *CI \~ MQ+LT*- In some cases, it makes sense to add covariances (or correlations, in the standardized version) to error terms. Covariances are specified by a double tilde (\~\~).You can refer to the [lavaan website and tutorials](https://lavaan.ugent.be/), for examples of model specifications.After reading your data into JASP, you only have to specify the model which follows the rules of *lavaan*. Optionally, the output contains a SEM diagram.The following video shows you how to run SEM models in JASP.<iframewidth="560"height="315"src="https://www.youtube.com/embed/U-um8VlX1OI?si=xnip0VINRWjG8aQY"title="YouTube video player"frameborder="0"allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"referrerpolicy="strict-origin-when-cross-origin"allowfullscreen></iframe>The data, and the JASP-file, can be found on [GitHub](https://github.com/statmind/jasp_sem).Once you have [downloaded JASP](https://jasp-stats.org/download/) you can download and open the file, and inspect the input and the output. Feel free to play around with the various options, and maybe to adapt the model!Some things to be aware of:1. SEM does not show up in the standard menu of JASP. You can add SEM and many other techniques to the menu, easily.2. After loading your data to JASP, you have to check that the variables to be used in SEM are (interval or ratio) *scale* data, rather than nominal or ordinal data. SEM gives an error message when your variables are not *scale* (i.e., nominal or ordinal).3. The SEM-diagram is great, but in the version of JASP used in this module the coefficients are the unstandardized ones. The standardized coefficients do appear in the results, but cannot be printed in the diagram. Hopefully this will be fixed in next versions of the software.### SEM Using JamoviThere's another tool which is remarkably similar to JASP, called [Jamovi](https://www.jamovi.org/).SEM can be added to Jamovi's menu. And, like JASP, Jamovi also makes use of R and *lavaan*, in the background.There are slight differences between SEM in JASP and Jamovi.1. SEM in Jamovi can be done interactively, implying even less coding.2. The SEM diagram of Jamovi does offer the option to print standardized estimates, which helps.3. Jamovi - at least in the interactive option - forces users to make a distinction between exogenous and endogenous (latent) variables, but the use of the terms is inconsistent, or even irrelevant. Anyway, it's confusing.4. While JASP can handle path models (without latent variables) easily, it is probably possible but not very clear how to run path models in Jamovi the interactive mode.You can download Jamovi [here](https://www.jamovi.org/).After downloading Jamovi, you can download and open the Jamovi file with the data and SEM analysis, from [Github](https://github.com/statmind/jasp_sem).The screenshot below includes the only lines of *lavaan*-like coding that is required to run the model. The *structural part of the model* has to be specified in the custom model settings.Any covariances between error terms can be added in the variances and covariances section. For the sake of the example, we have added a covariance between the error terms of **mq1** and **mq2**, which (according to the output of *lavaan*, JASP, and Jamovi) would reduce the χ^2^ by 22, down from 164.By adding one parameter, we decrease the degrees-of-freedom by one, from 51 to 50. Apart from an improvement in all other goodness-of-fit statistics as well, the regression coefficients are slightly different from the earlier model.{width="100%"}{width="100%"}## Annexes### SEM in R/lavaan (including path diagrams)<iframewidth="560"height="315"src="https://www.youtube.com/embed/RlWpbA7Ydic?si=TXs8UK_mcp_Xalsp"title="YouTube video player"frameborder="0"allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"referrerpolicy="strict-origin-when-cross-origin"allowfullscreen></iframe>### SEM in JASP<iframewidth="560"height="315"src="https://www.youtube.com/embed/fno5LC5cKdM?si=TftTFl322IiGGnjb"title="YouTube video player"frameborder="0"allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"referrerpolicy="strict-origin-when-cross-origin"allowfullscreen></iframe>### SEM in JamoviPart 1:<iframewidth="560"height="315"src="https://www.youtube.com/embed/ZjShUzLY0R0?si=ggoLJIEBkR9Dy3Yc"title="YouTube video player"frameborder="0"allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"referrerpolicy="strict-origin-when-cross-origin"allowfullscreen></iframe>Part 2:<iframewidth="560"height="315"src="https://www.youtube.com/embed/DRfJWW61moY?si=strqkvAIH9qZ0_ab"title="YouTube video player"frameborder="0"allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"referrerpolicy="strict-origin-when-cross-origin"allowfullscreen></iframe>### Reporting SEM Results<iframewidth="560"height="315"src="https://www.youtube.com/embed/kEuxOwTWKPA?si=pygYfmNrS1wWLzPc"title="YouTube video player"frameborder="0"allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"referrerpolicy="strict-origin-when-cross-origin"allowfullscreen></iframe>