Structural equation modeling (SEM)

Does trust in institutions increase the sense of belonging to the community, and through it – participation? Structural equation modeling connects two things: a measurement model – which items measure each concept (as in confirmatory factor analysis) – and a structural model – arrows between the concepts themselves, free of measurement error. The page estimates both steps like lavaan: fit indices for each step and the difference test between them, unstandardized and standardized path coefficients, direct, indirect and total effects, loadings, correlation residuals, modification indices, a diagram and a findings paragraph in English.

Calculator

Loading the data

Drag an Excel file or an SPSS file (.sav) here, or click to choose
In the site's standard template: row = participant, column = item, first row of headers. CSV is accepted too.
The items are numeric columns (item scores, without a summed scale score); negatively worded items – reverse them first (the coding – from items to a scale score page).
Just want to try it out? The same sample file as on the CFA page (320 residents, 12 Likert items 1-7 – belonging, trust, participation); the mediation model is predefined: English example
or

Paste columns directly from the sheet (including the header row) – select them in Excel, copy, and paste here:

A
B
C
D
E
F
You can also just paste – the data will be loaded and displayed automatically.

Model specification

Guide

When to use?

When the hypothesis is about relationships between concepts each of which is measured by several items. Byrne (2016, p. 54) defines: a full structural equation model "includes both a measurement model and a structural model", so that "certain latent variables are connected by one-way arrows, the direction of which reflects hypotheses about the causal structure of the variables in the model". In the sample file: trust in institutions → belonging to the community → participation, plus a direct arrow from trust to participation – a mediation model, four items for each concept.

Three pages in this module answer related questions. Path analysis draws arrows between observed variables (e.g. scale scores), so its coefficients are not corrected for measurement error; confirmatory factor analysis tests only the measurement model – the factors are correlated, without direction; full SEM combines both. Kline (2023, p. 264) explains the difference: in path analysis, the disturbance of a dependent variable includes both omitted causes and measurement error, whereas in SEM the disturbances of endogenous factors "reflect only omitted causes" – the measurement error is in the measurement part, so the path coefficients between the factors are "corrected for measurement error". Related pages: Cronbach's alpha and scale score, questionnaire construction.

The logic: from the paths to the covariance matrix

The model. Two systems of equations: in the measurement model each item is a loading times its factor plus a residual (x = Λη + ε, as in CFA); in the structural model each endogenous factor is a combination of the factors that predict it plus a disturbance (η = Bη + ζ). Hence the covariance matrix implied by the model: Σ = Λ(I − B)⁻¹Ψ(I − B)⁻ᵀΛ′ + Θ, where Ψ contains the variances and correlations of the exogenous factors and the variances of the disturbances. Rosseel (2012, Table 1) describes the three operators that define such a model in lavaan: =~ ("is measured by"), ~ ("is regressed on") and ~~ (covariance).

Identification. Kline (2023, p. 265, Rule 15.1 – "the two-step identification rule", after Anderson and Gerbing, 1988, and Bollen, 1989, as cited in Kline): a full model is identified if (1) the measurement part, when formulated as a CFA, is identified, and (2) the structural part is identified – and every recursive structural model (without loops) is identified (ibid., p. 110, Rule 7.4). So the page accepts only recursive models, and requires at least two items per factor. Setting the scale – as in CFA: marker (the default of lavaan and of AMOS) or std.lv; with std.lv, as in lavaan, the disturbance variances of the endogenous factors are also fixed to 1, so the unstandardized coefficients differ – but the fit and the standardized coefficients are identical.

Estimation. Maximum likelihood (ML) as in lavaan, with the same engine as the CFA page (Fisher scoring with the expected information, until the derivative is smaller than 10−10; χ² = N·F). Validation: the page reproduces the full example of Rosseel (2012, section 5.1, pp. 18-20) – Bollen's data on industrialization and political democracy (1989, as cited in Rosseel), 75 countries, three factors, three paths and six residual correlations: χ²(35) = 38.125, p = .329, the paths 1.483, 0.572 and 0.837, and all 34 rows of the printed output (estimate, standard error, z and Std.all) to the third digit; and lavaan 0.6-17 in seven models – including the indirect effects (:=), the correlation residuals, the difference test between the steps and the modification indices.

The two-step approach

If a full model does not fit – where is the problem: in the measurement, in the structure, or in both? Kline (2023, p. 265) presents the two-step approach of Anderson and Gerbing (1988, as cited in Kline): in Step 1 the model is specified as a CFA – the same factors and items, all factors correlated – and its fit is tested; "if the fit of the CFA model is poor, the fit of the structural model may be even worse". In Step 2, with a well-fitting measurement model, the structural model is compared with it by a χ² difference test: the structural model is nested in the measurement model (an unspecified path = a correlation fixed to zero). When the structural part is just-identified – there is a path or a correlation between every two factors, as in the example model – "the fit of the structural model and of the CFA are identical, because the models are equivalent". The page runs both steps and shows them together in Table 1.

Two warnings from Kline (pp. 266-268). First, equivalent models: when the structural and measurement models are equivalent, "the only basis" for preferring the model with the arrows "is rational (that is, argument, not analysis) or supported by the research design (e.g., temporal precedence in measurement)"; and the report should "acknowledge the existence of equivalent models at every stage" and explain why the model was chosen. Second, stability of the loadings: when the structural part is changed, the loadings should change only slightly; a marked change is "interpretational confounding" – the meaning of the factor changes according to what predicts it. And also: the global fit indices are influenced more by the measurement part, which usually has many more degrees of freedom, so good fit of the model as a whole can hide a problem in the structural part (McDonald and Ho, 2002, as cited in Kline, p. 268).

How to read the output?

Table 1 – Fit at both steps. One row for the measurement model and one for the structural model, with the same indices and the same cutoffs as on the CFA page: χ² (you want a p greater than .05), CFI and TLI (above .95 good, above .90 acceptable), RMSEA with a 90% confidence interval (up to .06 good, up to .08 acceptable) and SRMR (up to .08) – the cutoffs of Hu and Bentler (1999, p. 27), "close to" and not rules, and the ranges that Brown (2015, pp. 74-75) gives; Kline (2023, pp. 268, 421) does not recommend relying on fixed cutoffs at all, without examining local fit. In the note – the Δχ² difference test between the steps, or a message that the models are equivalent.

Table 2 – The paths. For each path: b (unstandardized), standard error, z, p, 95% confidence interval and β (Std.all) – by how many standard deviations the predicted factor changes when the predictor rises by one standard deviation and its other predictors are held constant. In the note – the R² of each endogenous factor: the share of its variance that the predictors explain (Byrne, 2016, p. 212, on the SMC of each dependent factor: a statistic "that is independent of the units of measurement").

Table 3 – Direct, indirect and total effects (section below). Table 4 – The loadings of the measurement model, as in Table 2 on the CFA page. Table 5 – Variances: for an exogenous factor – variance and correlation with the other exogenous factors; for an endogenous factor – the disturbance variance, whose standardized value is 1 − R².

Table 6 – Correlation residuals. For each pair of items: the observed correlation minus the correlation implied by the model (each matrix standardized by its own diagonal – cor.bollen in lavaan, the default in Kline's book, 2023, p. 147). Correlation residuals, unlike covariance residuals, "can be compared directly across different pairs" (ibid., p. 145). In his examples Kline flags an absolute value above .10 as a sign that the model does not explain the relation between the two variables well (p. 146, Table 9.4) – the page shades them. Kline (p. 422) stresses that reporting global fit indices alone "is not enough": "the real details of fit" are in the residuals (p. 268). Table 7 – Modification indices: as in CFA, plus unspecified paths and correlations between factors or disturbances (a path that would close a loop also appears, as in lavaan, and is marked). Diagram – the structural part: β on the arrows, R² under each endogenous factor.

Indirect effects (mediation)

The indirect effect of trust on participation via belonging is the product of the two coefficients along the path – a·b – and the total effect is the direct plus the indirect (Kline, 2023, p. 125; when there are several paths, the page sums the products of all of them, like the total-effects matrix (I − B)⁻¹ − I). In lavaan they are defined with the := operator, and their standard errors are computed "by the delta method (Sobel, 1982)" (Rosseel, 2012, Section 7.4) – the same computation as on the page. For a path of two links this is the Sobel standard error (Kline, p. 125, Equation 8.2), where in a single model the covariance between the two coefficients also enters the computation.

Limitation. Kline (2023, p. 128): the Sobel test "assumes normality, but distributions of product estimators are generally not normal; they are often asymmetrical", so its p values should not be over-interpreted; the alternative is a bootstrap confidence interval (ibid., pp. 128-129, with the warning that without a fixed seed the limits may change between runs). The page prints the normal confidence interval (b ± 1.96·SE, like parameterEstimates()), and the R script in the output includes the bootstrap command; the bootstrap itself, in the browser – per path, with percentile and bias-corrected intervals and the same samples as lavaan with the same seed – is computed by the page latent mediation. In the sample data file the difference is small: the delta interval for the indirect effect [0.164, 0.398], and a percentile interval from 5,000 bootstrap samples (seed 2026) [0.171, 0.414] – asymmetric, as expected. And interpretation: "mediation" is a causal claim, and in the cross-sectional model of the example a model with the arrows in the opposite direction fits the data equally well (section "The two-step approach").

Assumptions and warnings

Sample size. Kline (2023, p. 16): "there is no simple rule of thumb for sample size that works across all studies". As a starting point he cites Jackson's (2003, as cited in Kline) N:q rule – a ratio of 20 participants per estimated parameter is recommended, 10 is "less ideal", and below that "the trustworthiness of the results" also declines – and the median sample size in reviews of SEM studies, about 200; "with N < 100, almost any type of SEM may be untenable" unless the model is very simple. The page warns below 200 participants (and more sharply below 100) and below a 10:1 ratio. In the sample data file: 314 participants and 27 parameters – 11.6:1.

Normality and Likert items – as in CFA: ML estimation assumes multivariate normality; according to Rhemtulla et al. (2012, p. 354) ML is suitable for items with 5 or more categories, and estimation for ordinal data – for fewer than that. Inadmissible solution: a negative residual or disturbance variance (in an endogenous factor – R² above 1), or a factor correlation above 1; "do not interpret results from an inadmissible solution" (Kline, 2023, p. 421; Brown, 2015, pp. 162-163). Missing values – listwise deletion across all the model's items (the lavaan default). Changing the model after the run: Kline (p. 266) warns that "the method capitalizes on chance variation" when changes are made and tested on the same data, and that without fitting to new data "it is unknown whether the model would replicate"; Byrne (2016, pp. 206-208) demonstrates the process – adding paths "that are substantively meaningful" according to the modification indices, and then removing non-significant paths "in the interest of parsimony" – and concludes (p. 217) that there are no "rigid rules" for when to stop, other than theoretical knowledge, weighing the indices and "a watchful eye on parsimony". Both approaches touch the same point: every change is reported, and a model changed in this way requires replication.

What the page does not compute. Non-recursive models (loops, reciprocal effects), correlations between disturbances, a factor with a single item, observed variables in the structural part (e.g., age as a predictor), bootstrap confidence intervals (on the page latent mediation), RMSEA of the structural part alone (RMSEA-P, Kline, p. 268), group comparison and measurement invariance, robust estimation (MLR) and estimation for ordinal data (WLSMV), FIML, equality constraints.

And how is it done in SPSS and AMOS?

SPSS Statistics has no structural equation models; Pallant (2020, chapter 10) notes that it "supports an add-on called AMOS". In AMOS the measurement model is drawn as in CFA (an ellipse for each factor, a rectangle for each item, a residual circle for each item), and instead of a two-headed arc between factors that have a causal hypothesis between them – a single-headed arrow; for each endogenous factor a disturbance circle is added (AMOS fixes its arrow to 1). Byrne (2016, chapter 6) demonstrates such a full model step by step. Under Analysis Properties › Output check Standardized estimates, Squared multiple correlations and Modification indices (Byrne, 2016, p. 210: request the SMC as well). The expected difference is as in CFA: AMOS computes χ² = (N − 1)Fmin (Byrne, 2016, p. 93), whereas lavaan and the page use N·F (Brown, 2015, p. 67); the estimates are identical, and χ² and the standard errors differ slightly.

And how do you do it in R?

lavaan: the measurement model in =~ lines, the paths in ~ lines, labels before the predictors (a*trust), and defined effects with := (Rosseel, 2012, Section 7.4); sem() adds the residual and disturbance variances and the correlations between the exogenous factors by itself. The "Download R script" button in the output writes the script of the model you defined – both steps, the test between them, the correlation residuals and the modification indices. The script below was run as is on the sample data file (lavaan 0.6-17).

# Structural equation model – Professor Stat. This file is saved as UTF-8; every comment line starts with an English word
library(readxl)   # Reading Excel
library(lavaan)   # cfa, sem, lavTestLRT, modindices

# Loading: the standard layout – row = participant, column = item; the sheet "data"
d <- read_excel("C:/Rdata/DATA_cfa_example_eng.xlsx", sheet = "data")
items <- c(paste0("belong_", 1:4), paste0("trust_", 1:4), paste0("partic_", 1:4))
d <- as.data.frame(d[, items])
names(d) <- c(paste0("b", 1:4), paste0("t", 1:4), paste0("p", 1:4))   # Short English names for the model

# Step 1: the measurement model – three correlated factors
meas <- "
  belong =~ b1 + b2 + b3 + b4
  trust  =~ t1 + t2 + t3 + t4
  partic =~ p1 + p2 + p3 + p4
"
fit1 <- cfa(meas, data = d)                 # χ²(51) = 51.083, p = .470, CFI 1.000, RMSEA .002, SRMR .031

# Step 2: trust → belonging → participation, plus trust → participation
model <- paste0(meas, "
  belong ~ a*trust
  partic ~ b*belong + c*trust
  ind := a*b
  tot := c + a*b
")
fit <- sem(model, data = d)                 # ML, listwise deletion: 314 of 320
summary(fit, fit.measures = TRUE, standardized = TRUE, rsquare = TRUE)
# Same χ²(51) = 51.083 – the structural part is just-identified, so it is equivalent to Step 1
# Paths: a 0.531 (SE 0.078, β .509), b 0.529 (SE 0.089, β .521), c -0.014 (p = .874, β -.013)
# ind 0.281 (SE 0.060), β .266; tot 0.267 (SE 0.076); R²: belong .259, partic .265

# Correlation residuals – the largest in absolute value .078 (b1, p1); modification indices above 3.84 – b2 ~~ b3: 8.024
round(residuals(fit, type = "cor.bollen")$cov, 3)
mi <- modindices(fit, sort. = TRUE)
mi[mi$mi > 3.84, c("lhs", "op", "rhs", "mi", "epc", "sepc.all")]

# Bootstrap confidence interval for the indirect effect (not on the page) – percentiles, 5000 samples, fixed seed
set.seed(2026)
fitb <- sem(model, data = d, se = "bootstrap", bootstrap = 5000)
pe <- parameterEstimates(fitb, boot.ci.type = "perc")
pe[pe$op == ":=", ]                          # ind: [0.171, 0.414]; tot: [0.124, 0.427]

# Without the direct path (full mediation) – the model is nested, and it can be tested
model2 <- paste0(meas, "
  belong ~ trust
  partic ~ belong
")
fit2 <- sem(model2, data = d)
lavTestLRT(fit2, fit1)                       # Δχ²(1) = 0.025, p = .875

Reporting the results

Kline (2023, pp. 420-422) lists what to report: the software and its version and the syntax of the final model (in an appendix or in supplementary material); the estimation method, and whether the estimation converged and the solution is admissible; the decisions in choosing between models, with the difference tests between nested models; the number of changes to the model and the substantive rationale for each, with a clear distinction between what was specified in advance and what was found after looking at the data; the unstandardized estimates with their standard errors alongside the standardized ones – "it is a mistake to report only the standardized solution"; and the residuals – "reporting only global fit indices is not enough". From the page: Table 1 (both steps), Table 2 and Table 3, the correlation residuals briefly ("no residual exceeded .10 in absolute value"), and a diagram with the coefficients (APA, 2020, Figure 7.8). APA (2020, section 6.44) – define SEM, CFI, RMSEA at first use; section 6.36 – no zero before the decimal point for β, R², p, CFI and RMSEA, and with a zero for b.

Common mistakes

Skipping Step 1. A structural model with a measurement model that does not fit – there is no way to know where the problem is. Check the CFA first.

"The model fits, so the direction is right". When the structural part is just-identified, the fit is identical to that of the CFA – it says nothing about the direction of the arrows; and even in a nested model, equivalent models with reversed arrows fit equally well.

Reading the p of the indirect effect as decisive. The distribution of the product is not normal; report a confidence interval, preferably bootstrap.

Reporting only β. Report b with its standard error too (Kline, 2023, p. 422).

Settling for the global indices. Good CFI and RMSEA can hide a pair of items that the model does not explain – Table 6.

Adding and removing paths until it fits. Every change – with a substantive rationale, reported, and in a new sample before drawing conclusions.

References

American Psychological Association. (2020). Publication manual of the American Psychological Association (7th ed.). https://doi.org/10.1037/0000165-000

Brown, T. A. (2015). Confirmatory factor analysis for applied research (2nd ed.). Guilford Press.

Byrne, B. M. (2016). Structural equation modeling with AMOS: Basic concepts, applications, and programming (3rd ed.). Routledge.

Hu, L., & Bentler, P. M. (1999). Cutoff criteria for fit indexes in covariance structure analysis: Conventional criteria versus new alternatives. Structural Equation Modeling: A Multidisciplinary Journal, 6(1), 1-55. https://doi.org/10.1080/10705519909540118

Kline, R. B. (2023). Principles and practice of structural equation modeling (5th ed.). Guilford Press.

Pallant, J. (2020). SPSS survival manual: A step by step guide to data analysis using IBM SPSS (7th ed.). Routledge.

Rhemtulla, M., Brosseau-Liard, P. É., & Savalei, V. (2012). When can categorical variables be treated as continuous? A comparison of robust continuous and categorical SEM estimation methods under suboptimal conditions. Psychological Methods, 17(3), 354-373. https://doi.org/10.1037/a0029315

Rosseel, Y. (2012). lavaan: An R package for structural equation modeling. Journal of Statistical Software, 48(2), 1-36. https://doi.org/10.18637/jss.v048.i02

Anderson and Gerbing (1988), Bollen (1989), Jackson (2003) and McDonald and Ho (2002) – as cited in Kline (2023); Bollen (1989) and Sobel (1982) – as cited in Rosseel (2012). By the site's rule, the reference list includes only sources read in the original. Site conventions: the shading of correlation residuals above .10 (following Kline's examples), the warning below 200 participants and below a 10:1 ratio, and the default paths in the sample data file. The computation on the page is verified against the lavaan 0.6-17 package in R and against the printed output of Rosseel (2012).