Structural Equation Modeling (SEM)
Before You Start
- What is SEM, and what does it include?
- Note that SEM has two parts: the structural model and the measurement model. Many beginners run into problems with SEM because they did not understand these basic concepts thoroughly at the start.
- When should you use SEM?
- What are latent variables, exogenous variables, and endogenous variables?
- What makes a good structural equation model?
- How do you test mediation?
The procedures and indices discussed below (anything involving numbers) should be backed by the literature. Remember to cite it when you write your paper.
Key Terms
- Exogenous variable (independent variable, predictor): a variable that no other variable in the model predicts. In a path diagram, no single-headed arrow points to it.
- Endogenous variable (dependent variable, outcome, criterion): a variable that at least one other variable predicts. A mediator is endogenous, although it also predicts other variables.
- Observed variable (manifest variable, indicator): a variable in your data, such as a questionnaire item or a sum score.
- Latent variable (factor, construct): a variable that is not measured directly and is defined by its indicators, such as depression measured by the items of a depression scale (Note 1).
- Measurement model: how each latent variable relates to its indicators. On its own, it is a CFA (see CFA).
- Structural model: the regressions among the latent variables, and between them and other observed variables. A structural model with observed variables only is a path analysis.
- Path diagram: the model drawn as a figure. Rectangles are observed variables, ovals are latent variables, single-headed arrows are regressions or loadings, and double-headed arrows are variances or covariances (see the figure in CFA).
- Specification: deciding which parameters are free (estimated from the data) and which are fixed (set to a value, usually 0 or 1). Every arrow you leave out of the diagram fixes a parameter at 0. No model fits the data perfectly; the aim is a model that fits well and makes theoretical sense.
- Identification: whether the free parameters have a unique solution. The data must give at least as many pieces of information as there are free parameters (df ≥ 0; see How CFA Estimates the Model), and each latent variable needs a fixed scale. df ≥ 0 is necessary but not sufficient.
- Model fit: how close the model-implied covariance matrix is to the observed one, summarized by fit indices such as χ², CFI, TLI, RMSEA, and SRMR (Fit Criteria).
- Wald test and score test: the Wald test asks whether fixing or constraining free parameters (for example, setting a path to 0, or two loadings equal) would make the fit significantly worse; in lavaan,
lavTestWald(). The score test, also called the Lagrange multiplier (LM) test, asks whether freeing fixed parameters would make the fit significantly better; in lavaan,lavTestScore(). A modification index is the score test for one fixed parameter (step 7 of the Basic Procedure). - Size of a path: for standardized path coefficients, the benchmarks Cohen (1988) gave for correlations are often used: about .10 is small, .30 medium, and .50 large.
Basic Procedure
- Handle missing values and outliers. There are many ways to do this; here we recommend multiple imputation.
- Test for common method bias and multicollinearity: if all your data come from questionnaires, you need this step, and also check whether the variables are collinear.
- Currently there is no “perfect” test for common method bias. The literature tends to recommend the directly measured latent variable (DMLV) approach, but it requires you to specify the source of the bias in advance and collect an extra questionnaire.
- Test univariate and multivariate normality, because non-normal data need different estimators: MLR or MLM for non-normal continuous data (MLR also handles missing data with FIML), and WLSMV for categorical (ordinal) data.
- Compute the correlations between the dimension (subscale) scores.
- Test the reliability and validity of the scales; there are different indices you can report.
- CFA: this also counts as evidence of construct validity. There are two ways to set the scale of each latent variable, the fixed-variance method and the fixed-loading method, and both give the same model fit.
- Fixed variance: the variance of the latent variable is fixed to 1, and all loadings are estimated freely.
- Fixed loading: the loading of one item on each factor is fixed to 1, and the other loadings are estimated freely.
- Software usually uses fixed loading by default; if you want fixed variance, you may need to adjust the code (in lavaan,
std.lv = TRUE; see CFA syntax).
- CFA: this also counts as evidence of construct validity. There are two ways to set the scale of each latent variable, the fixed-variance method and the fixed-loading method, and both give the same model fit.
- Path analysis: now you can fit the full model (SEM). Most online tutorials and videos only teach this step and skip the ones before it; if you go straight to the full model, the results may be poor.
- Report the fit indices, path coefficients, and other information from the path analysis.
- Model modification:
- Look at the modification indices (MI). When an MI is above 3.84 (the critical chi-square value with 1 df at p < .05), you can add a residual correlation, usually between observed variables within the same factor. Because this is data-driven, it is best to have theoretical support. Don’t follow every MI: stop once the fit indices are acceptable, otherwise the model becomes saturated. Mention these modifications in your paper.
Most people just don’t explain why they made them (after all, they are data-driven). - Then keep revising the model: change some paths based on your theory, and compare the new model with the original one.
- Look at the modification indices (MI). When an MI is above 3.84 (the critical chi-square value with 1 df at p < .05), you can add a residual correlation, usually between observed variables within the same factor. Because this is data-driven, it is best to have theoretical support. Don’t follow every MI: stop once the fit indices are acceptable, otherwise the model becomes saturated. Mention these modifications in your paper.
- Test mediation (details and code in Mediation Analysis):
- The Sobel test assumes the indirect effect is normally distributed, which is rarely true because the product of two coefficients is usually skewed, so bootstrapping is now the common choice. 5,000 resamples are common and 10,000 are recommended, depending on how powerful your computer is.
- Judge significance by the 95% CI rather than the p-value: the effect is significant when the confidence interval does not include 0.
- The total effect can be masked (for example, by suppression), so it may be non-significant. I don’t recommend leaning heavily on terms like “full mediation” and “partial mediation”. Highly recommended reading:
- Rucker, D. D., Preacher, K. J., Tormala, Z. L., & Petty, R. E. (2011). Mediation analysis in social psychology: Current practices and new recommendations. Social and Personality Psychology Compass, 5(6), 359-371. https://doi.org/10.1111/j.1751-9004.2011.00355.x
- It can indeed happen that path coefficients or the indirect effect are not significant after bootstrapping; bootstrapping gives more accurate confidence intervals and a more robust significance test. There are many possible reasons, such as a small sample or a misspecified model; in short, the relationships among the variables are not robust.
- The Sobel test assumes the indirect effect is normally distributed, which is rarely true because the product of two coefficients is usually skewed, so bootstrapping is now the common choice. 5,000 resamples are common and 10,000 are recommended, depending on how powerful your computer is.
Report Results
A results section follows the order of the analysis:
- Data screening: the univariate and multivariate normality of the items, which decides the estimator (step 3 of the Basic Procedure).
- Methods: the software and estimator, how missing data were handled, how each factor was identified (the loading fixed at 1 and the factor means fixed at 0), that the residual covariances were fixed at 0, how the effects were tested (the type of bootstrap CI and the number of draws, and that an effect counts as significant when its 95% CI excludes 0), and the fit criteria with their source.
- Measurement models, one per factor: fit, loadings, R², and whether the hypothesis about the factor was supported.
- Structural model: fit, each path with its estimate, SE, 95% CI, and standardized coefficient (β), and the R² of each endogenous factor.
- Indirect and total effects with their 95% CIs.
With several models or many items, put the numbers in tables and refer to them in the text. The full SEM example below goes through all five steps. The fit criteria and how to report a CFA on its own are in Report Results of the CFA chapter.
A Full SEM
Suppose the hypotheses are that (1a to 1c) the items of FA1, FB1, and FB2 each form a well-fitting factor; (2) FA1 predicts FB1 (path a); (3) FB1 predicts FB2 (path b); (4) FA1 predicts FB2 (path c’); and (5) FA1 has an indirect effect on FB2 through FB1. Each measurement model is tested on its own, then the structural model. Full SEM in Syntax gives the code and the numbers.
The measurement and structural models were estimated in R with the lavaan package. Univariate normality of the items was tested with the Shapiro-Wilk test and multivariate normality with Mardia’s test. All items deviated from normality, Ws = .914 to .917, ps < .001, with skewness from −0.04 to 0.15 and kurtosis from −0.93 to −0.69 (Table 1). Mardia’s multivariate skewness was not significant, p = .999, but multivariate kurtosis was, z = −4.18, p < .001. The models were therefore estimated with robust maximum likelihood (MLR), and missing data were handled with full information maximum likelihood (FIML). The first loading of each factor was fixed at 1 and the factor means at 0, all item intercepts were estimated freely, and residual covariances were fixed at 0. The paths and the indirect and total effects were tested with 5,000 percentile bootstrap samples (ML with FIML), and an effect was considered significant when its 95% confidence interval (CI) excluded zero. Model fit was evaluated against χ²/df ≤ 3, CFI and TLI ≥ .95, RMSEA ≤ .06, and SRMR ≤ .08 (Hu & Bentler, 1999; Schreiber, 2008).
Hypothesis 1a. The measurement model of FA1 fit the data well (Table 2). The χ² test was significant, χ²(9) = 17.89, p = .037, but the other indices met the criteria, χ²/df = 1.99, CFI = .990, TLI = .984, RMSEA = .046, 90% CI [.012, .077], SRMR = .020. The factor variance was significant (ψ = 0.647, SE = 0.073, p < .001), indicating individual differences in FA1. With the loading of A1 fixed at 1, the unstandardized loadings of A2 to A6 ranged from 0.960 to 1.055 (ps < .001), and the standardized loadings of all six items from .665 to .713 (Table 3); the upper limit of each 90% CI was at least .70 (Cheung et al., 2024). The standardized residual variances ranged from .491 to .558, so 49.1% to 55.8% of the variance of each item was unique to it, measurement error and item-specific variance rather than FA1. Correspondingly, R² ranged from .442 to .509: FA1 explained 44.2% to 50.9% of the variance of each item. Hypothesis 1a was supported.
Hypotheses 1b and 1c. The models of FB1, χ²(5) = 4.37, p = .497, and FB2, χ²(14) = 8.15, p = .881, also fit the data well (Table 2). Their standardized loadings ranged from .648 to .671 and from .629 to .678 (ps < .001; Table 3). For FB1, the upper limit of each 90% CI was at least .70. For FB2, the upper limits for B6, B7, and B12 were between .50 and .70 (.681, .699, and .697), a minor concern (Cheung et al., 2024). FB1 explained 42.0% to 45.1%, and FB2 39.5% to 46.0%, of the variance of each item. Hypotheses 1b and 1c were supported.
Hypotheses 2 to 4. The structural model fit the data well (Table 2), χ²(132) = 156.25, p = .073, χ²/df = 1.18, CFI = .991, TLI = .989, RMSEA = .020, 90% CI [.000, .031], SRMR = .035, with standardized loadings from .635 to .706 (ps < .001). FA1 positively predicted FB1 (estimate = 0.314, SE = 0.057, 95% CI [0.208, 0.433], β = .333, p < .001; Table 4), supporting Hypothesis 2. FB1 positively predicted FB2 (estimate = 0.493, SE = 0.069, 95% CI [0.369, 0.636], β = .496, p < .001), supporting Hypothesis 3. FA1 also positively predicted FB2 (estimate = 0.160, SE = 0.051, 95% CI [0.061, 0.262], β = .170, p = .002), supporting Hypothesis 4. R² = .111 for FB1 and .330 for FB2.
Hypothesis 5. The indirect effect of FA1 on FB2 through FB1 was positive and significant (indirect effect = 0.155, SE = 0.032, 95% CI [0.099, 0.224], β = .165). The total effect was 0.315 (95% CI [0.214, 0.426], β = .335; Table 4). Hypothesis 5 was supported.
Table 1
Univariate Normality of the Items
| Item | Skewness | Kurtosis | W | p |
|---|---|---|---|---|
| A1 | −0.034 | −0.819 | .916 | < .001 |
| A2 | −0.002 | −0.879 | .915 | < .001 |
| A3 | 0.022 | −0.880 | .916 | < .001 |
| A4 | 0.060 | −0.778 | .917 | < .001 |
| A5 | 0.005 | −0.837 | .916 | < .001 |
| A6 | −0.011 | −0.933 | .915 | < .001 |
| B1 | 0.100 | −0.738 | .916 | < .001 |
| B2 | 0.017 | −0.849 | .916 | < .001 |
| B3 | 0.074 | −0.804 | .916 | < .001 |
| B4 | 0.024 | −0.812 | .917 | < .001 |
| B5 | 0.019 | −0.850 | .917 | < .001 |
| B6 | 0.050 | −0.907 | .915 | < .001 |
| B7 | 0.027 | −0.894 | .915 | < .001 |
| B8 | 0.025 | −0.693 | .917 | < .001 |
| B9 | −0.039 | −0.878 | .915 | < .001 |
| B10 | 0.152 | −0.779 | .914 | < .001 |
| B11 | −0.020 | −0.804 | .917 | < .001 |
| B12 | −0.009 | −0.825 | .916 | < .001 |
Note. N = 500; each item was tested on the 482 to 494 cases that answered it. Kurtosis is the excess kurtosis (0 for a normal distribution). W = Shapiro-Wilk statistic. Mardia’s test (n = 336 complete cases): multivariate skewness p = .999; multivariate kurtosis z = −4.18, p < .001.
Table 2
Model Fit Indices of the Measurement and Structural Models
| Model | χ² | df | χ²/df | p | RMSEA | RMSEA 90% CI | SRMR | CFI | TLI |
|---|---|---|---|---|---|---|---|---|---|
| FA1 | 17.887 | 9 | 1.987 | .037 | .046 | [.012, .077] | .020 | .990 | .984 |
| FB1 | 4.371 | 5 | 0.874 | .497 | .000 | [.000, .058] | .012 | 1.000 | 1.002 |
| FB2 | 8.150 | 14 | 0.582 | .881 | .000 | [.000, .023] | .013 | 1.000 | 1.009 |
| Structural model | 156.250 | 132 | 1.184 | .073 | .020 | [.000, .031] | .035 | .991 | .989 |
Note. N = 500. Scaled χ² and robust RMSEA, CFI, and TLI (MLR). TLI can exceed 1 when χ² is smaller than its df.
Table 3
Factor Loadings of the Measurement Models
| Model | Item | Estimate | SE | p | β | R² |
|---|---|---|---|---|---|---|
| FA1 | ||||||
| A1 | 1.000 | – | – | .681 | .464 | |
| A2 | 0.960 | 0.073 | < .001 | .665 | .442 | |
| A3 | 1.020 | 0.071 | < .001 | .702 | .492 | |
| A4 | 0.997 | 0.071 | < .001 | .696 | .484 | |
| A5 | 1.055 | 0.074 | < .001 | .713 | .509 | |
| A6 | 1.004 | 0.074 | < .001 | .681 | .464 | |
| FA1 (ψ) | 0.647 | 0.073 | < .001 | |||
| FB1 | ||||||
| B1 | 1.000 | – | – | .651 | .424 | |
| B2 | 1.042 | 0.090 | < .001 | .671 | .451 | |
| B3 | 1.015 | 0.093 | < .001 | .671 | .451 | |
| B4 | 1.009 | 0.086 | < .001 | .648 | .420 | |
| B5 | 1.033 | 0.089 | < .001 | .652 | .425 | |
| FB1 (ψ) | 0.557 | 0.075 | < .001 | |||
| FB2 | ||||||
| B6 | 1.000 | – | – | .629 | .395 | |
| B7 | 1.031 | 0.080 | < .001 | .650 | .423 | |
| B8 | 1.001 | 0.080 | < .001 | .653 | .426 | |
| B9 | 1.063 | 0.079 | < .001 | .678 | .460 | |
| B10 | 1.032 | 0.084 | < .001 | .650 | .423 | |
| B11 | 1.028 | 0.078 | < .001 | .652 | .425 | |
| B12 | 1.019 | 0.077 | < .001 | .646 | .417 | |
| FB2 (ψ) | 0.543 | 0.068 | < .001 |
Note. Estimate = unstandardized loading or factor variance (ψ); β = standardized loading. The first loading of each factor was fixed at 1 for identification.
Table 4
Paths and Effects of the Structural Model
| Path | Estimate | SE | z | p | LLCI | ULCI | β |
|---|---|---|---|---|---|---|---|
| FA1 → FB1 (a) | 0.314 | 0.057 | 5.476 | < .001 | 0.208 | 0.433 | .333 |
| FB1 → FB2 (b) | 0.493 | 0.069 | 7.145 | < .001 | 0.369 | 0.636 | .496 |
| FA1 → FB2 (c’, direct effect) | 0.160 | 0.051 | 3.114 | .002 | 0.061 | 0.262 | .170 |
| FA1 → FB1 → FB2 (indirect effect) | 0.155 | 0.032 | 4.835 | < .001 | 0.099 | 0.224 | .165 |
| Total effect | 0.315 | 0.054 | 5.802 | < .001 | 0.214 | 0.426 | .335 |
Note. Estimate = unstandardized estimate; β = standardized estimate. SE, z, p, and the lower and upper limits of the 95% percentile CI (LLCI, ULCI) are from 5,000 bootstrap draws.
Notes
- Latent vs. observed variables: observed variables are the individual items on the questionnaire, and a latent variable is your operationalized construct, the variable you want to study. For example, if I want to study the severity of depression, that is an abstract concept; you need to make it operational, that is, measure it with a scale (or by other means).
- Don’t be purely data-driven: SEM needs strong theoretical support. If you are purely data-driven, the discussion will be hard to write.
- Use WLSMV for categorical (ordinal or binary) variables: declare them with
ordered =, and lavaan uses WLSMV by default.- WLSMV estimates the model with diagonally weighted least squares (DWLS) and adds robust standard errors and a mean- and variance-adjusted χ².
estimator = "DWLS"gives the same estimates and standard errors, but only the unadjusted χ², so report the WLSMV test. - WLSMV and DWLS have no likelihood, so there is no AIC or BIC (see Model comparison).
- WLSMV estimates the model with diagonally weighted least squares (DWLS) and adds robust standard errors and a mean- and variance-adjusted χ².
- When the model is too complex and the fit is not acceptable:
- Simplify your model. A more complex model is not necessarily better; it has to make sense.
- Take a single dimension into the SEM instead of putting several dimensions together in a mediation model.
- Item parceling (explain why you used this method and how you did it):
- The most common way is to use the dimension scores directly; if you want to use item parceling, look up the literature.
- When I first started and didn’t know better, I summed all the dimension scores into a total and analyzed it as a first-order latent variable. Later I learned this is not correct, although in a sense it is a kind of item parceling.
- However, I strongly recommend using the raw (item-level) data rather than processed data: if you use averages, you may ignore measurement error and introduce bias (see Latent vs. Observed Correlation).
- A composite of the subscales (the sum or mean of the subscale scores, or of the subscale factors) and a second-order factor are not interchangeable. A second-order factor rests on assumptions about the covariances of the first-order factors; a composite does not, and its correlations with other variables can differ a lot from those of the second-order factor. A composite also has to mean something: for a profile-type measure, such as the six interest dimensions of Holland’s RIASEC model, the information is in the profile and a total says little (Rose et al., 2019, pp. 13-14).
- Factor scores, saved from a CFA and used as observed variables, are another option when the full model is too complex to converge. They are estimates that still contain measurement error. In simulations of hierarchical models, they estimated correlations with an outcome about as accurately as the full SEM when the indicators were continuous, but tended to underestimate them when the indicators were binary (Williams et al., 2025).
- The most common way is to use the dimension scores directly; if you want to use item parceling, look up the literature.
- Scale reliability and validity should already be tested in the pilot study, and then adjusted with the large sample. Remember to handle the reverse-scored items.
- Generally, only after a simple mediation model works should you move on to more complex models.
- Variables don’t necessarily need to be correlated.
- Some situations, such as a non-significant total effect or standardized path coefficients greater than 1 or less than -1, can happen, and your software won’t report an error. But you need to look at them together with R² and the 95% CI.
- A non-significant total effect does not rule out an indirect effect (Hayes, 2009); see Mediation Analysis.
- A standardized coefficient beyond ±1 is not an error. It occurs most readily when the predictors are highly correlated (multicollinearity), and it is not by itself a reason to change the model, although its square can then no longer be read as the share of variance that the predictor explains (Deegan, 1978, pp. 886-887). Suppression among the predictors, or a model that is too complex for the sample size, can also produce one. Check the correlations among the predictors.
See also: De Stavola, B. L., Daniel, R. M., Ploubidis, G. B., & Micali, N. (2015). Mediation analysis with intermediate confounding: Structural equation modeling viewed through the causal inference lens. American Journal of Epidemiology, 181(1), 64-80. https://doi.org/10.1093/aje/kwu239
Summary and Practice
Confirmatory factor analysis (CFA)
- Comment: See CFA.
Path analysis
- Functions: lavaan,
sem(), with regressions written asy ~ x(see the quick reference). - Comment: With a binary exogenous predictor such as gender, report
standardizedSolution(fit, type = "std.nox"). It standardizes every variable except the exogenous observed ones, so the coefficient is the difference between the two groups in standard deviations of the outcome. A fully standardized coefficient (Std.all) would be per standard deviation of a 0/1 variable, which has no clear meaning; for indirect effects, see Hayes (2009, p. 417).
Multiple outcomes
- Variable types: Any
- When to use: The same predictors are expected to affect several outcomes, for example X → M → Y1 and X → M → Y2.
- Comment:
- Put the outcomes in one model rather than fitting one model per outcome.
sem()then frees the residual covariance of outcomes that predict nothing else, so the model estimates how strongly the outcomes are related after the predictors are taken into account (their partial correlation). - In one model you can test several parameters at once, such as all paths to both outcomes (
lavTestWald()), instead of running a separate test per outcome, which limits the number of tests. You can also compare a predictor’s effect on the two outcomes by labeling both paths and defining their difference with:=; compare raw coefficients only when the outcomes are on the same scale. - If the outcomes are unrelated and answer separate questions, separate models are fine.
- Put the outcomes in one model rather than fitting one model per outcome.
- Resources: Cross Validated: Does adding more than 1 dependent variable to SEM have purpose other than to control for correlation between dependent variables?, Cross Validated: Testing simple mediation model with two separate outcome variables
Mediation analysis
- Variable types: Continuous mediator and outcome; for categorical ones, see the chapter.
- When to use: Your theory says X affects Y through M.
- Functions: lavaan,
sem(), with the indirect effect defined by:=and a bootstrap confidence interval (se = "bootstrap"). - Comment: See Mediation Analysis. For curved (nonlinear) paths, see Nonlinear Mediation.
Control variables (covariates)
- Variable types: Any
- When to use: My theory is that demographic variables (e.g., gender and age) affect (or predict) suicidal behavior, so to make the results more robust, I control for the effect of the demographic variables on suicidal behavior.
- Comment:
- All the x’s are independent variables: the one you focus on is the explanatory variable, and the ones you don’t focus on are control variables. “Control” means you don’t care about it, but because it affects y, it would affect the estimate for the explanatory variable you care about, so you add it to the model to control for it.
- Paths in SEM stand for hypothesized causal effects, and the independent variable X is where the chain starts. A control variable C is there to remove confounding, not to explain X, so X stays exogenous. X and C may still correlate; the model then estimates the effect of X with C held constant.
- How to specify it depends entirely on your theory (or previous studies). If you think a control variable affects the dependent variable, the mediator, or both, regress those variables on the control variable. If you think it only affects the dependent variable, regress only the dependent variable on it. In fact, regression works the same way: the control variables and the independent variable are allowed to correlate by default. But note: don’t regress the independent variable on the control variables.
- Treat control variables like independent variables. In Becker’s (2005) review, about 63% of the studies that used control variables gave no clear reason for at least one of them (Bernerth & Aguinis, 2016). Bernerth and Aguinis (2016) recommend including a control only when theory explains how and why it relates to the focal variables; adding controls does not make a test more conservative. Measure the controls reliably, report their descriptive statistics and correlations, and report the results with and without them. Controls that are unrelated to the focal variables can be left out, which keeps statistical power. A categorical control with more than two categories has one effect per dummy variable.
- Resources: lavaan Google Group: Add control variable in SEM, lavaan Google Group: lavaan syntax for control variables in mediation, Cross Validated: How do you control for a variable in SEM with mediation?, Quora: What are control variables and how do I use them in regression analysis?, UCLA OARC: Covariate Selection in Regression: A Crash Course on Good and Bad Controls
Moderation
- Variable types: Usually categorical (compared with a multigroup model), but continuous variables also work: use them directly in an interaction term rather than splitting them into groups, which loses information.
- When to use: Your theory says that the effect of X on Y depends on a third variable W, for example that the effect of study time on exam scores depends on prior knowledge.
- Functions: For observed variables, center X and W and regress Y on X, W, and their product: Y = b0 + b1X + b2W + b3(X × W) + e. In lavaan, write
y ~ b1*x + b2*w + b3*x:w. b3 is the interaction; the effect of X at a value w of W (a simple slope) is b1 + b3w, which you can define with:=. For latent variables, the product is harder to model: product indicators (semTools::indProd()), or latent moderated structural equations in Mplus (XWITH). - Comment: After centering, b1 is the effect of X at the mean of W, and b2 the effect of W at the mean of X.
- Resources: EPSY 579 R Cookbook for SEM, Lab 3: Moderation and conditional effects
Multigroup comparisons
- Comment: Measurement invariance and comparing paths across groups: see Multigroup Analysis.
Model comparison
- When to use: You compare competing models, such as a model with and without a path, or two theories about the same variables.
- Comment:
- Nested models (one model is the other with some parameters fixed or constrained): χ² difference test,
lavTestLRT(fit1, fit2). With MLR it uses the scaled difference test (Satorra & Bentler, 2001), and with WLSMV a scaled and shifted one. Don’t subtract the robust χ² values by hand: the scaled difference is not the difference of the scaled values. - Non-nested models: compare AIC and BIC; smaller is better. They need a likelihood, so they exist for ML and MLR but not for WLSMV or DWLS.
- Two paths in the same model: label them and define the difference,
diff := b1 - b2, or constrain them to be equal (give them the same label) and compare with the free model inlavTestLRT(). Equality constraints apply to the unstandardized paths, so the variables should be on comparable scales. - Paths across groups: see Multigroup Analysis.
- Nested models (one model is the other with some parameters fixed or constrained): χ² difference test,
- Resources: Regorz: Path comparison in lavaan, lavaan Google Group: Comparing path coefficients in SEM using lavTestLRT - can I compare standardized or unstandardized values?
Export results
- Functions: lavaan, bruceR
- Resources: bruceR
Figures
- Comment: So far there is no best package for drawing SEM figures; you could use Word or PowerPoint.
Syntax
The code in this section runs in your browser and prints its output when the page loads. The first visit downloads lavaan, so the first results take a while to appear. You can edit any cell and run it again.
The examples use the scored version of the simulated dataset described in Example Data, in which A4 and A11 are already reverse-scored. Some items are missing, so every model uses missing = "fiml" with the MLR estimator (step 3 of the Basic Procedure).
lavaan Syntax Quick Reference
The operators used in the models on this page, with their Mplus equivalents. UCLA OARC: Quick reference of lavaan syntax gives the same list with short examples.
| lavaan | Mplus | |
|---|---|---|
| Factor measured by items | F =~ x1 + x2 + x3 |
F BY x1-x3; |
| Regression | y ~ x |
y ON x; |
| Covariance | x1 ~~ x2 |
x1 WITH x2; |
| Variance | x ~~ x |
x; |
| Mean or intercept | x ~ 1 |
[x]; |
| Fix a parameter at a value | F =~ 1*x1 |
F BY x1@1; |
| Free a parameter that is fixed by default | F =~ NA*x1 |
F BY x1*; |
| Label a parameter | y ~ a*x |
y ON x (a); |
| New parameter from labels | ab := a*b |
MODEL CONSTRAINT: NEW(ab); ab = a*b; |
| Robust ML estimator | estimator = "MLR" |
ANALYSIS: ESTIMATOR = MLR; |
Full SEM
The code for the full SEM example in Report Results. FA1 predicts FB1 (path a), and FB1 and FA1 predict FB2 (paths b and c’), so FB1 mediates the effect of FA1 on FB2. In the simulated data the factors are only correlated, without causal paths, which is enough for an example. SEM by Hand estimates this model step by step.
Normality of the Items
kurtosi() gives the excess kurtosis, which is 0 for a normal distribution. Each item is tested on the cases that answered it; mardia() keeps only the cases that answered all 18 items. These are the numbers in Table 1.
Measurement Models
These are the numbers in Table 3. The last row of each table is the factor variance ψ. The standardized residual variance θ of each item is 1 − R².
Structural Model
The first table gives Table 2, and the standardized values give the β column of Table 4.
Bootstrap Confidence Intervals
The 95% CIs of the paths and effects come from a percentile bootstrap (see Mediation Analysis). lavaan does not bootstrap with MLR, so this fit uses ML with FIML; ML and MLR give the same estimates. With 1,000 draws it takes about 2 minutes, so this part does not run in the browser; run it in R on your computer:
set.seed(2024)
# 5,000 to 10,000 draws are recommended; 1,000 keeps the example fast
fit_boot <- sem(model_sem, data = mydata, missing = "fiml",
se = "bootstrap", bootstrap = 1000)
# estimates, bootstrap SEs, and percentile CIs
est_boot <- parameterEstimates(fit_boot, boot.ci.type = "perc")
est_boot[est_boot$op %in% c("~", ":="), ]These are the estimates, SE, z, p, and CI columns of Table 4. Table 4 comes from the same code with 5,000 draws, so its SEs and CIs differ slightly from a run with 1,000; the estimates are the same.
Resources & References
- Newsom: Categorical Data Analysis class
- UCLA OARC: Introduction to Structural Equation Modeling (SEM) in R with lavaan
- PSY 597: Structural Equation Modeling (Penn State)
- EPSY 579: R Cookbook for Structural Equation Modeling
- Kline, R. B. (2023). Principles and practice of structural equation modeling (5th ed.). Guilford Press.
Becker, T. E. (2005). Potential problems in the statistical control of variables in organizational research: A qualitative analysis with recommendations. Organizational Research Methods, 8(3), 274-289. https://doi.org/10.1177/1094428105278021
Bernerth, J. B., & Aguinis, H. (2016). A critical review and best-practice recommendations for control variable usage. Personnel Psychology, 69(1), 229-283. https://doi.org/10.1111/peps.12103
Cheung, G. W., Cooper-Thomas, H. D., Lau, R. S., & Wang, L. C. (2024). Reporting reliability, convergent and discriminant validity with structural equation modeling: A review and best-practice recommendations. Asia Pacific Journal of Management, 41(2), 745-783. https://doi.org/10.1007/s10490-023-09871-y
Cohen, J. (1988). Statistical power analysis for the behavioral sciences (2nd ed.). Lawrence Erlbaum Associates.
Deegan, J. (1978). On the occurrence of standardized regression coefficients greater than one. Educational and Psychological Measurement, 38(4), 873-888. https://doi.org/10.1177/001316447803800404
Hayes, A. F. (2009). Beyond Baron and Kenny: Statistical mediation analysis in the new millennium. Communication Monographs, 76(4), 408-420. https://doi.org/10.1080/03637750903310360
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
Rose, N., Wagner, W., Mayer, A., & Nagengast, B. (2019). Model-based manifest and latent composite scores in structural equation models. Collabra: Psychology, 5(1), Article 9. https://doi.org/10.1525/collabra.143
Satorra, A., & Bentler, P. M. (2001). A scaled difference chi-square test statistic for moment structure analysis. Psychometrika, 66(4), 507-514. https://doi.org/10.1007/BF02296192
Schreiber, J. B. (2008). Core reporting practices in structural equation modeling. Research in Social and Administrative Pharmacy, 4(2), 83-97. https://doi.org/10.1016/j.sapharm.2007.04.003
Williams, A. L., Conway, C. C., Olino, T. M., Revelle, W., Zinbarg, R. E., & HiTOP Utility Workgroup. (2025). Testing criterion validity in hierarchical models of psychopathology: Comparison of latent-variable and factor-score approaches. Clinical Psychological Science, 13(1), 128-145. https://doi.org/10.1177/21677026231225414
Further Study
Categorical Variables
- lavaan: Categorical data
- lavaan Google Group: How to enter binary observed outcome variable + scaling of latent variable?
- lavaan Google Group: WLSMV or DWLS? Lavaan and SEM with categorical variables
- CRMDA SEM Example 07: Comparing ML and WLSMV estimators for ordinal, Likert-type items
- Park, C. G. (2023). Implementing alternative estimation methods to test the construct validity of Likert-scale instruments. Korean Journal of Women Health Nursing, 29(2), 85-90. https://doi.org/10.4069/kjwhn.2023.06.14.2
Composite Scores and Item Parceling
- Yang, C., Nay, S., & Hoyle, R. H. (2010). Three approaches to using lengthy ordinal scales in structural equation models. Applied Psychological Measurement, 34(2), 122-142. https://doi.org/10.1177/0146621609338592
- Cross Validated: Using total score from multi-scale instrument in structural equation modeling
- Cross Validated: Can we use “subscale scores” as “observed variables” in SEM?