SEM theorie
📚 SEM theorie.pptx
Brief overview
This document provides a comprehensive introduction to Structural Equation Modeling (SEM), detailing its theoretical foundations and practical applications. Understanding SEM is crucial for analyzing complex relationships between observed and latent variables in various research fields.
Key points
- Overview of Structural Equation Modeling (SEM) and its core principles.
- Confirmatory Factor Analysis (CFA) and its matrix representation in SEM.
- SEM applications with a political democracy dataset and model evaluation techniques.
- Introduction to SEM analysis using the 'lavaan' R package.
- Advanced SEM topics including multiple groups and measurement invariance.
1. Introduction to Structural Equation Modeling (SEM)
1.1 What is SEM?
Structural Equation Modeling (SEM) is a powerful multivariate statistical technique used to analyze complex relationships among variables.
- It allows for the testing of hypothesized data-generating models.
- These models can incorporate latent variables:
- Hypothetical constructs (e.g., depression, intelligence) measured by a set of observed indicators.
- Random effects, such as random intercepts.
- SEM accommodates complex relationships like indirect effects (mediation) and reciprocal effects.
- Models are typically represented graphically as path diagrams.
🔑 Important: SEM extends simpler regression models by explicitly modeling latent variables and their relationships with observed indicators, offering a more comprehensive approach to theory testing.
1.2 Foundational Concepts in SEM
SEM analyses traditionally commence with the observed variance-covariance matrix (S) of the data.
- For P observed variables, S is a P×P symmetric matrix.
- Diagonal elements represent variances; off-diagonal elements represent covariances.
- A covariance quantifies the linear association between two variables.
- A correlation matrix is a standardized version of the covariance matrix.
- In addition to S, SEM can incorporate the means (yˉ) of the observed variables.
- If data are multivariate normally distributed, S and yˉ contain all information about the data.
1.2.1 Regression using Variance-Covariance Matrices
Standard regression models can be conceptualized and estimated using the variance-covariance matrix.
- For a regression model predicting y1 from x2,x3,x4 (y1=β0+β1x2+β2x3+β3x4+ϵ), the coefficients can be derived from S.
- The regression coefficients (β^p) are calculated as β^p=(S234,234)−1S234,1.
- The intercept (β^0) is derived as β^0=yˉ1−β^′xˉ234.
1.3 The Model-Implied Variance-Covariance Matrix
The core of SEM involves comparing a hypothesized model's implications to the observed data.
- A specified SEM model, often depicted as a path diagram, implies a specific structure for the population variance-covariance matrix.
- This implied matrix is denoted as Σ^.
- The goal is to estimate model parameters such that Σ^ closely matches the observed sample covariance matrix S.
- Different models will produce different Σ^ matrices.
📝 Example: Consider three observed variables y1,y2,y3. A model where y1 predicts y2 and y3 (i.e., y2=ay1+ϵ2, y3=by1+ϵ3) will imply a specific Σ^ based on the variances of y1,ϵ2,ϵ3 and the coefficients a,b.
1.3.1 Rules for Variance and Covariance Calculation
Understanding how variances and covariances are composed in a model is crucial for deriving Σ^. Key rules include:
- Variances:
- Var(X+Y)=Var(X)+Var(Y)+2Cov(X,Y)
- Var(aX)=a2Var(X)
- Covariances:
- Cov(A+B,C+D)=Cov(A,C)+Cov(A,D)+Cov(B,C)+Cov(B,D)
- Cov(aX,bY)=abCov(X,Y)
Standard assumptions often stipulate that predictors and error terms are uncorrelated (e.g., Cov(y1,ϵ2)=0).
📝 Example: For the model y2=ay1+ϵ2, assuming y1 and ϵ2 are uncorrelated: Var(y2)=Var(ay1+ϵ2)=Var(ay1)+Var(ϵ2)+2Cov(ay1,ϵ2) Var(y2)=a2Var(y1)+Var(ϵ2)+0.
1.3.2 Model Equivalence
It is possible for different SEM models to imply the exact same Σ^ matrix. These models are considered equivalent.
🔑 Important: The essence of SEM is to specify a theoretical model, collect data, derive the model-implied covariance matrix Σ^, and compare it to the observed sample covariance matrix S. Goodness-of-fit indices quantify this comparison.
2. Confirmatory Factor Analysis (CFA) and Matrix Representation
2.1 Overview of Confirmatory Factor Analysis
-
Confirmatory Factor Analysis (CFA): A specific application of Structural Equation Modeling (SEM) used to test hypothesized relationships between latent variables (factors) and their observed indicators.
-
Model Structure: CFA models posit that observed variables are linear composites of unmeasured latent variables, along with unique error terms.
-
Example Scenario: The Holzinger & Swineford (1939) data can be modeled with three latent factors: 'visual', 'textual', and 'speed', each measured by three distinct observed indicators.
-
Factor Correlations: In typical CFA, the latent factors are assumed to be correlated, representing shared variance among them.
2.2 Matrix Representation of CFA
The structure of a CFA model is concisely represented using three core matrices:
-
Lambda Matrix (Λ):
- Represents the factor loadings, which are the regression coefficients linking latent factors to observed indicators.
- Its dimensions correspond to the number of observed indicators (rows) by the number of latent factors (columns).
- Zeroes in this matrix denote the absence of a direct path from a factor to an indicator.
-
Psi Matrix (Ψ):
- Encapsulates the variances and covariances of the latent variables.
- It is a square matrix, with dimensions equal to the number of latent factors.
- Diagonal elements represent the variances of the factors, and off-diagonal elements represent their covariances.
-
Theta Matrix (Θ):
- Contains the residual variances (or error variances) of the observed indicators.
- It is a diagonal matrix, as the errors for each indicator are typically assumed to be uncorrelated with each other and with the common factors.
🔑 Important: These matrices collectively define the hypothesized structural relationships within the CFA model.
2.3 The Model-Implied Covariance Matrix
The fundamental equation for generating the model-implied covariance matrix (Σ) in a standard CFA is:
Σ=ΛΨΛ′+Θ
-
This equation integrates the contributions of the latent factors (ΛΨΛ′) and the unique error variances (Θ) to explain the observed variances and covariances.
-
Parameter Estimation: The goal of SEM is to estimate the free parameters within Λ, Ψ, and Θ such that the resulting Σ^ is as close as possible to the observed sample covariance matrix (S).
-
Estimation Methods: Common estimation techniques include Maximum Likelihood (ML) and Generalized Least Squares (GLS).
🔑 Important: The formula Σ=ΛΨΛ′+Θ is central to CFA; it translates the hypothesized model structure into a predicted covariance matrix that can be compared to the data.
2.4 Model Identification and Parameter Constraints
For a CFA model to be identifiable (i.e., have a unique solution for its parameters), certain constraints must be imposed. The most common methods for setting the metric of the latent variables are:
-
Unit Loading Identification (ULI):
- Fixes the factor loading of one indicator (the "reference indicator") per factor to 1.0.
- This anchors the scale of the latent variable to the scale of that indicator.
-
Unit Variance Identification (UVI):
- Fixes the variance of each latent factor to 1.0.
- This standardizes the latent variables, effectively making them comparable to z-scores.
🔑 Important: Without fixing parameters (e.g., setting loadings or variances), the model is underidentified, meaning an infinite number of parameter combinations could produce the same model-implied covariance matrix.
2.5 Parameters and Degrees of Freedom
-
Free Parameters: These are the parameters (Λ, Ψ, Θ) that are estimated from the data. Their number is crucial for model evaluation.
-
Sample Statistics: The observed sample covariance matrix (S) contains P(P+1)/2 unique elements, where P is the number of observed variables.
-
Degrees of Freedom (df):
- Calculated as the number of unique elements in S minus the number of free parameters in the model.
- df=2P(P+1)−(number of free parameters)
- A positive df indicates a constrained model, while df=0 signifies a saturated model where Σ^=S perfectly.
Aspect Description Value in Example Number of variables (P) Number of observed indicators. 9 Sample statistics Unique elements in the sample covariance matrix (S). 45 Free parameters Parameters estimated from the data (e.g., loadings, variances). 21 Degrees of freedom Difference between sample statistics and free parameters. 24
🔑 Important: The number of free parameters must be less than or equal to the number of sample statistics for the model to be identified. A higher number of degrees of freedom generally suggests a more parsimonious and testable model.
3. SEM applications: Political democracy dataset and model evaluation
3.1 The Political Democracy Dataset and Model Specification
The Political Democracy dataset comprises data from 75 developing countries, focusing on industrialization in 1960 and political democracy in 1960 and 1965. It includes observed variables (indicators) for three latent variables:
ind60(industrialization in 1960): Measured by gross national product (GNP) per capita, inanimate energy consumption per capita, and the percentage of the labor force in industry.dem60(political democracy in 1960): Measured by expert ratings of press freedom, freedom of political opposition, fairness of elections, and effectiveness of the legislature.dem65(political democracy in 1965): Measured by expert ratings of press freedom, freedom of political opposition, fairness of elections, and effectiveness of the legislature.
This constitutes a full Structural Equation Model (SEM) incorporating both measurement and structural components. The model matrices required for estimation include:
LAMBDA: Factor loadings matrix.THETA: Residual variances (and covariances) of observed indicators.PSI: Variances and covariances of latent variables.BETA: Regression coefficients for the structural part.
The model-implied variance-covariance matrix (Σ) is calculated as: \Sigma = \Lambda (I - B)^{-1} \Psi (I - B)^{-1}' \Lambda' + \Theta where I is the identity matrix.
🔑 Important: A full SEM model integrates both how latent variables are measured (measurement model) and how they relate to each other (structural model), requiring four key matrices for its representation.
3.2 Model Estimation
Model estimation aims to find parameter values (θ) that minimize the discrepancy between the observed data's covariance matrix (S) and the model-implied covariance matrix (Σ(θ)). The estimated parameters are denoted as θ^, and the estimated model-implied covariance matrix as Σ^=Σ(θ^).
Different discrepancy measures exist, with the most common based on Maximum Likelihood (ML): FML(θ)=log∣Σ∣+tr(SΣ−1)−log∣S∣−p where p is the number of observed variables.
An alternative is Weighted Least Squares (WLS): FWLS(θ)=(s−σ)′W−1(s−σ) where s and σ are vectors of unique elements of S and Σ, respectively, and W is a weight matrix.
🔑 Important: Model estimation seeks parameter values that make the model's implied data as close as possible to the actual observed data.
3.3 Model Evaluation
Model evaluation assesses how well the estimated model fits the data. This involves both global fit assessment and checking the admissibility of results.
3.3.1 Global fit assessment
- Chi-square test statistic (χ2): This is the primary test of the model. A non-significant χ2 (large p-value) indicates a good fit. However, it is highly sensitive to sample size, often becoming significant with large N.
- Fit indices: These provide supplementary measures of model fit, with common rules of thumb:
CFI/TLI: Comparative Fit Index / Tucker-Lewis Index. Aim for >0.95.RMSEA: Root Mean Square Error of Approximation. Aim for <0.05.SRMR: Standardized Root Mean Square Residual. Aim for <0.06.
🔑 Important: A comprehensive model evaluation requires reporting the χ2 statistic with degrees of freedom and p-value, alongside multiple fit indices (e.g., RMSEA, CFI, SRMR), avoiding cherry-picking.
3.3.2 Admissibility of results
Parameter estimates must be evaluated for validity:
- Negative variances: Residual variances or variances of latent variables should not be negative.
- Correlations > 1: Standardized solutions should not yield correlations greater than unity.
- Sign consistency: Regression coefficients and factor loadings should have the expected theoretical sign.
- Significance of parameters: Most free parameters should be statistically significant.
- Standard errors: Avoid excessively large standard errors, which can indicate numerical instability or weak identification.
🔑 Important: Even a model with good global fit indices can contain inadmissible solutions (e.g., negative variances), signaling a problematic model.
3.4 Model Respecification
If a model does not fit the data well, it can be respecified by making modifications. Common respecification strategies include:
- Changing the number of factors.
- Allowing indicators to load on multiple factors (cross-loadings).
- Permitting correlated residual errors among indicators.
- Allowing correlated disturbances among endogenous latent variables.
- Removing problematic indicators.
Ideally, any model change should be theoretically justified. Exploratory approaches, such as examining modification indices, can suggest potential changes, but these should be implemented cautiously to avoid overfitting.
🔑 Important: Model respecification should ideally be guided by theory, though modification indices can inform data-driven adjustments.
3.5 Reporting Results
Reporting SEM analyses requires sufficient detail for replication. This typically includes:
- The observed covariance matrix (or correlation matrix and standard deviations).
- Ensuring the full dataset is available (e.g., via appendix or website).
🔑 Important: The reproducibility of SEM findings is paramount and hinges on providing complete information about the data and the analysis.
4. Introduction to Lavaan and SEM with R (part 1)
4.1 Introduction to lavaan
lavaan is a powerful R package designed for latent variable analysis, encompassing a wide range of structural equation modeling (SEM) techniques.
- Core Functionality:
- Provides a user-friendly syntax and interface for defining and fitting SEM models.
- Supports various data types, including continuous, binary, and ordinal data.
- Accommodates complex data structures such as missing data, non-normal distributions, and clustered observations.
- Modeling Capabilities:
- Confirmatory Factor Analysis (CFA)
- Structural Equation Modeling (SEM)
- Path Analysis
- Growth Curve Modeling
- Exploratory Factor Analysis (EFA)
- Exploratory Structural Equation Modeling (ESEM)
- Multilevel SEM
4.2 Installation and documentation
Installing lavaan is straightforward within an R session.
- Standard Installation:
- Execute
install.packages("lavaan")in your R console.
- Execute
- Development Version Installation:
- Method 1 (CRAN mirror):
install.packages("lavaan", repos = "http://www.da.ugent.be", type = "source") - Method 2 (devtools package):
library(devtools)followed byinstall_github("yrosseel/lavaan") - Method 3 (Local file):
install.packages("c:/temp/lavaan_0.6-11.tar.gz", NULL, type = "source")(adjust path as needed)
- Method 1 (CRAN mirror):
- Resources:
- Official Website: http://lavaan.org provides comprehensive information.
- Publication: Rosseel (2012) for detailed insights into the package.
- Discussion Group: A Google Group is available for community support and Q&A.
4.3 The lavaan ecosystem
lavaan is part of a broader ecosystem of related R packages and tools that extend its capabilities.
- Key Companion Packages:
- blavaan: Facilitates Bayesian SEM using JAGS or Stan with a lavaan interface.
- lavaan.survey: Incorporates survey weights, clustering, strata, and finite sampling corrections into SEM.
- semTools: A collection of functions for advanced SEM analysis and diagnostics.
- semPlot: Specializes in visualizing SEM models.
- EffectLiteR: Focuses on estimating average and conditional effects using SEM.
- MIIVsem: Implements instrumental variable estimation within SEM.
🔑 Important: The lavaan ecosystem offers specialized tools that enhance SEM analysis for various research designs and data complexities, demonstrating the package's central role in the R statistical environment.
4.4 Basic lavaan syntax: Regression and path analysis
lavaan uses a distinct syntax to define SEM models, which can represent various statistical models, including regression and path analysis.
- Simple Linear Regression:
- Similar to R's
lm()function, but within the lavaan framework. - Syntax:
'dependent ~ predictor1 + predictor2 + ...' - To include the intercept, use
meanstructure = TRUEin thesem()function or specify'~ 1 + predictor1 + ...'in the model syntax.
- Similar to R's
- Multivariate Regression:
- Multiple dependent variables are specified on separate lines within the model syntax.
- Syntax: ' y1 ~ x1 + x2 y2 ~ x1 + x2 '
- Path Analysis:
- Models directed relationships between observed variables.
- Each dependent variable is specified with its exogenous predictors.
- Syntax: ' x5 ~ x1 + x2 + x3 x6 ~ x4 + x5 x7 ~ x6 '
🔑 Important: The lavaan syntax is hierarchical: regression equations for observed variables are the building blocks for more complex SEM models.
4.5 Mediation analysis in lavaan
Mediation analysis models how an independent variable influences a dependent variable through an intermediate variable (mediator).
- Syntax:
- Define the direct effect of the independent variable (X) on the dependent variable (Y) (
c). - Define the effect of X on the mediator (M) (
a). - Define the effect of M on Y (
b). - Use defined labels (e.g.,
a,b,c) to compute indirect and total effects.
- Define the direct effect of the independent variable (X) on the dependent variable (Y) (
- Model Definition: myModel <- ' Y ~ cX + bM M ~ aX indirect := ab total := c + (a*b) '
- Estimation:
- The
sem()function is used for fitting. - Bootstrap estimation (
se = "bootstrap") is recommended for estimating standard errors of indirect and total effects.
- The
🔑 Important: lavaan allows for the explicit definition of composite parameters (like indirect and total effects) and their estimation using robust methods such as bootstrapping.
4.6 Confirmatory Factor Analysis (CFA) in lavaan
CFA models how observed variables (indicators) load onto latent variables (factors).
- Functions: Both
cfa()andsem()can be used for Confirmatory Factor Analysis.cfa()is specifically tailored for this purpose. - Syntax for CFA:
- Define latent variables on the left side of the
~operator. - Specify their observed indicators on the right side, separated by
+. - Example: HS.model <- ' visual =~ x1 + x2 + x3 textual =~ x4 + x5 + x6 speed =~ x7 + x8 + x9 '
- Define latent variables on the left side of the
- Output: The
summary()function provides parameter estimates, standard errors, and fit measures (when requested withfit.measures = TRUEandstandardized = TRUE).
4.7 Advanced model specification with lavaan()
The general lavaan() function offers more control over model specification compared to specialized functions like cfa().
- Syntax for
lavaan():- Explicitly defines factor loadings, factor variances, and residual variances.
- Uses
~for regression paths (factor loadings). - Uses
~~for (co)variances. - Uses
1 * indicatorto fix the first indicator's loading to 1 (standard practice for model identification). - Explicitly defines variances for latent factors and residuals.
- Example Model Syntax:
HS.model <- '
latent variables
visual =~ 1x1 + x2 + x3 textual =~ 1x4 + x5 + x6 speed =~ 1*x7 + x8 + x9
# factor (co)variances
visual ~~ visual visual ~~ textual visual ~~ speed textual ~~ textual textual ~~ speed speed ~~ speed
# residual variances
x1 ~~ x1; x2 ~~ x2; x3 ~~ x3 x4 ~~ x4; x5 ~~ x5; x6 ~~ x6 x7 ~~ x7; x8 ~~ x8; x9 ~~ x9 '
- Fitting:
fit <- lavaan(model = HS.model, data = HolzingerSwineford1939)
🔑 Important: While
sem()andcfa()automate many aspects of model definition for common SEM structures, the directlavaan()function provides granular control, making it suitable for highly customized or complex model specifications.
🔑 Important: lavaan's flexible syntax allows for the representation of diverse statistical models, from simple regressions to complex latent variable structures, with its
sem()andcfa()functions offering user-friendly interfaces for common analyses, while the baselavaan()function provides maximum control.
5. Introduction to Lavaan and SEM with R (part 2)
5.1 Model specification in lavaan syntax
lavaan uses a specific syntax to define structural equation models. This syntax translates graphical model representations into text-based specifications.
- Basic Structure: Each line in the model syntax represents a formula with a left-hand side (lhs), an operator, and a right-hand side (rhs).
- Operators: Different operators define relationships:
~: Regresses the lhs on the rhs.=~: Defines a latent variable (lhs) from observed indicators (rhs).~~: Defines a covariance between two variables (lhs and rhs).
- Combining Formulas: The
+operator allows combining multiple formulas with the same lhs into a single line. For example,Y ~ A + B + Cis equivalent toY ~ A,Y ~ B, andY ~ Con separate lines.
📝 Example:
ind60 =~ x1 + x2 + x3(latent variableind60is measured byx1,x2,x3)dem60 ~ ind60(endogenous latent variabledem60is regressed on exogenousind60)y1 ~~ y5(residual covariance betweeny1andy5)
5.2 Equality constraints and modifiers
Equality constraints are used to specify that two or more parameters in the model must be equal, which is crucial for testing measurement invariance.
- Parameter Labeling: Assign arbitrary labels (e.g.,
a,b,c) to parameters in the model syntax to signal equality. - Syntax for Equality: When the same label is used for multiple parameters, lavaan enforces an equality constraint.
🔑 Important: When testing for measurement invariance, equality constraints are applied to factor loadings and/or intercepts to ensure that latent constructs are measured consistently across groups or time points.
- Modifiers: Each rhs term can be preceded by a modifier:
NA *: Fixes a parameter toNA, effectively removing it from estimation (often used for setting latent variable metrics).0.5 *: Fixes a parameter to a specific value (e.g.,0.5).b1 *: Assigns a label to a parameter.- Linear and non-linear constraints can be specified using
==for equality,>for greater than, and<for less than.
📝 Example:
dem60 =~ y1 + a * y2 + b * y3 + c * y4dem65 =~ y5 + a * y6 + b * y7 + c * y8In this example, the parameters fory2andy6are constrained to be equal (a), as arey3/y7(b) andy4/y8(c).
5.3 Fitting SEM models with lavaan
The lavaan package provides functions to estimate SEM models.
lavaan()function: The core function for fitting models. It accepts the model syntax, data, and various optional arguments.auto.var = TRUE: Automatically adds residual variances for observed variables.auto.fix.first. Gaye = TRUE: Automatically fixes the first indicator's loading to 1 for each latent variable to set its metric.auto.cov.lv.x = TRUE: Automatically adds covariances between exogenous latent variables and covariates.auto.bal = TRUE: Balances latent variable metrics by setting the first indicator's loading to 1.
sem()function: A wrapper aroundlavaan()with severalauto.*arguments set toTRUEby default, simplifying the fitting process for standard SEM models.cfa()function: Identical tosem(), specifically designed for Confirmatory Factor Analysis.
🔑 Important: The choice between
lavaan(),sem(), andcfa()often depends on the complexity of the model and whether automatic parameter fixing and scaling is desired.sem()andcfa()are more user-friendly for common SEM and CFA applications.
5.4 Interpreting model output and extractor functions
After fitting a model, lavaan offers various functions to extract and inspect results.
summary(fit, standardized = TRUE): Provides a comprehensive overview of the model, including parameter estimates, standard errors, test statistics, fit indices, and standardized solutions.- Parameter estimates are presented for factor loadings, regressions, and covariances.
- Standardized estimates (e.g., Std.lv, Std.all) are crucial for interpreting the magnitude of relationships independent of the original variable scales.
- Standard R Extractor Functions:
coef(fit): Returns a named numeric vector of free parameter estimates.fitted(fit): Returns the implied moments (covariance matrix and mean vector) of the model.resid(fit): Returns raw, normalized, or standardized residuals.vcov(fit): Returns the covariance matrix of the estimated parameters.logLik(fit),AIC(fit),BIC(fit): Compute likelihood-based statistics and information criteria.
- lavaan-Specific Extractor Functions:
lavInspect(fit): A powerful function to extract various model details, including parameter tables, sample statistics, implied statistics, and matrices.parameterTable(fit): Returns the parameter table as a data frame.standardizedSolution(fit): Returns standardized parameter estimates as a data frame.modindices(fit): Computes modification indices and expected parameter changes.fitMeasures(fit): Extracts selected fit measures.
📝 Example: Using
fitted(fit)allows comparison of the model-implied covariance matrix with the observed sample covariance matrix, offering insight into how well the model reproduces the data.
🔑 Important: Model fit is assessed using a suite of fit indices (e.g., SRMR, RMSEA, CFI) and the significance of the model test statistic. No single index is definitive; a holistic evaluation is required.
6. Introduction to lavaan and SEM with R (part 3)
6.1 Model inspection and diagnostics
lavaan offers extensive functions for inspecting model fit and diagnosing potential issues beyond the primary fit indices. These functions provide detailed information about model parameters, deviations, and suggested improvements.
6.1.1 Extracting model matrices and statistics
lavInspect(fit): Retrieves various model matrices and statistical summaries from a fittedlavaanobject.- Default output includes model matrices such as λ (loadings), Θ (error variances), Ψ (latent variable variances/covariances), and K (covariances).
lavInspect(fit, "sampstat"): Extracts sample statistics from the data.lavInspect(fit, "cov.lv"): Displays the model-implied covariance matrix of the latent variables.lavTech(fit, "cov.lv"): Provides the model-implied covariance matrix of latent variables in a matrix format, potentially including labels for clarity whenadd.labels = TRUE. This is often more suitable for programmatic use than the defaultlavInspectoutput.
6.1.2 Understanding parameter tables
parameterTable(fit): Generates a comprehensive table detailing each parameter in the SEM model.- Key columns include:
lhs: Left-hand side of the parameter definition.op: Operator specifying the parameter type (e.g.,=~for factor loading,~~for variance/covariance,~for regression).rhs: Right-hand side of the parameter definition.block: The block in which the parameter is defined.free: Indicator if the parameter is estimated (1) or fixed (0).ustart: Initial starting value for the parameter.label: User-defined label for the parameter.
- Key columns include:
parameterEstimates(fit): Displays the estimated parameters along with their standard errors, z-values, p-values, and confidence intervals. This is a subset of the fullparameterTablefocused on estimated values.
🔑 Important: The
parameterTableis crucial for understanding the structure of the defined SEM, whileparameterEstimatesprovides the inferential statistics for each parameter.
6.1.3 Identifying model improvement suggestions
modindices(fit, sort = TRUE, minimum.value = 5): Suggests potential model modifications by identifying parameters that, if added, would most improve the model fit.- Key columns:
lhs,op,rhs: Define the parameter to be added.mi: Modification Index (MI) – the expected decrease in the model's chi-squared statistic if the parameter were added.epc: Expected Parameter Change – the estimated value of the parameter if added.sepc.lv,sepc.all,sepc.nox: Standardized Expected Parameter Change values, scaled differently.
- Parameters are sorted by MI in descending order. A common heuristic is to consider adding parameters with MIs greater than 5 or 10.
- Key columns:
6.1.4 Score tests for model assessment
lavTestScore(fit, add = "..."): Computes score tests to evaluate the significance of adding specific parameters or constraints to the current model.totalscore test: Evaluates the overall improvement from adding a single constraint/parameter.univariatescore tests: Provides individual tests for each specified parameter.- These tests indicate how much the model fit would improve if a particular parameter (e.g.,
visual=~x9) were freely estimated.
6.1.5 Analyzing residual covariances and differences
- Residual matrices (e.g.,
cov.z): These matrices represent the difference between the observed covariances and the model-implied covariances.- Large absolute values in residual matrices indicate areas where the model does not adequately capture the observed relationships.
- Systematic patterns in residuals can suggest model misspecification.
- SRMR (Standardized Root Mean Square Residual): A measure of the average standardized difference between observed and predicted correlations. Lower values indicate better fit. The output often includes a
usrmr.closefitcomponent which is part of this assessment.
6.1.6 Likelihood Ratio Tests for model comparison
lavTestLRT(model_null, model_alt): Compares two nested models using a chi-squared difference test.model_null: The restricted (null hypothesis) model.model_alt: The less restricted (alternative hypothesis) model.- The test determines if the more complex
model_altprovides a significantly better fit to the data than themodel_null. A significant p-value suggests rejecting the null hypothesis that the models are equivalent. orthogonal = TRUEis an option to test if factors can be treated as uncorrelated.
📝 Example: To compare a model where three factors are allowed to correlate versus a model where they are fixed to be uncorrelated, one would use
lavTestLRTwith the unrestricted model and the model specified withorthogonal = TRUE.
🔑 Important: Model comparison tests are essential for selecting the most parsimonious yet well-fitting model among a set of nested alternatives.
🔑 Important: The primary utility of
modindicesandlavTestScoreis to guide model modification, suggesting which parameters to add or free to improve fit.
7. Advanced SEM topics: Multiple groups, measurement invariance, and data handling (part 1)
7.1 Incorporating means in SEM
When SEM is extended to include mean structures, it allows for the analysis of means in addition to covariance structures. This is pertinent in situations involving:
- Multiple group analysis
- Longitudinal data analysis
- Analysis of non-normally distributed or missing data
In lavaan, specifying meanstructure = TRUE adds the mean structure to the model. Without restrictions, the model fit remains equivalent to a model without means.
The inclusion of means introduces:
- p additional data points (the mean vector).
- p free parameters (intercepts of observed variables).
- Latent variable means are typically fixed to zero by default.
The output for a model with meanstructure = TRUE will show an increase in the number of estimated parameters, corresponding to the intercepts of the observed variables.
7.2 Multiple group analysis
Multiple group analysis in SEM involves fitting a model simultaneously across two or more distinct groups (e.g., by gender, nationality, or experimental condition).
- Single Group Analysis: Typically focuses on covariance structures. Latent variable means are often fixed to zero as they are not the primary focus.
- Multiple Group Analysis: Becomes essential when comparing means of latent variables across groups. If groups differ significantly on latent variable means, it suggests variations in the underlying constructs.
Key concept: The validity of comparing latent variable means across groups hinges on establishing measurement invariance.
7.3 Measurement invariance
Measurement invariance ensures that a construct is measured equivalently across different groups. If measurement invariance is not established, observed differences in latent means may reflect disparities in measurement rather than true differences in the construct.
The process of testing for measurement invariance typically follows a sequential model comparison approach:
- Configural Invariance: The same factor structure (number of factors, observed variables loading on each factor) is imposed on all groups. All parameters are freely estimated per group.
- Weak Invariance (Metric Invariance): Factor loadings are constrained to be equal across groups, in addition to the configural structure.
- Strong Invariance (Scalar Invariance): Both factor loadings and intercepts are constrained to be equal across groups.
- Strict Invariance: Extends strong invariance by also constraining residual variances to be equal across groups.
The goal is to progressively add equality constraints and evaluate the impact on model fit.
7.3.1 Testing and criteria for invariance
Assessing whether parameter constraints are violated involves:
- Formal Model Comparison Tests: Using chi-square difference tests (likelihood ratio tests) to compare nested models. These can be sensitive to large sample sizes.
- Informal Model Comparison: Examining changes in fit indices (e.g., CFI, RMSEA) between nested models.
- Overall Model Fit: Evaluating the absolute fit of the most constrained model (e.g., using chi-square or fit indices).
🔑 Important: While formal χ2 difference tests are standard, changes in fit indices like CFI (e.g., ΔCFI<0.01) and RMSEA (e.g., ΔRMSEA<0.015) provide more robust criteria, especially in large samples.
7.3.2 Measurement invariance in lavaan
lavaan facilitates measurement invariance testing using the group.equal argument within the cfa() function.
| Step | Model Type | group.equal Argument | Description |
|---|---|---|---|
| 1 | Configural invariance | Not specified | Same factor structure, all parameters freely estimated. |
| 2 | Weak invariance | "loadings" | Factor loadings constrained to be equal across groups. |
| 3 | Strong invariance | c("loadings", "intercepts") | Factor loadings and intercepts constrained to be equal. |
| 4 | Strict invariance | c("loadings", "intercepts", "residuals") | Loadings, intercepts, and residual variances equal. |
Model comparisons are typically performed using anova() to assess the significance of adding constraints.
🔑 Important: Begin with configural invariance. Then, iteratively add constraints (loadings, then intercepts) and compare each step to the preceding one. If a step leads to a significant deterioration in fit, stop and retain the previous level of invariance.
7.3.3 Example of invariance testing
Consider a two-group analysis:
- Configural Invariance: Fit a model where the factor structure is identical for both groups, but all parameters (loadings, intercepts, variances, means) are estimated independently.
- Weak Invariance: Constrain the factor loadings to be equal across both groups. Compare this model to the configural model using a χ2 difference test. If the difference is not significant, weak invariance is established.
- Strong Invariance: Constrain both factor loadings and intercepts to be equal. Compare this model to the weak invariance model.
If strong invariance is achieved, latent means can be meaningfully compared across groups. The output will detail fit measures for each model and the results of the χ2 difference tests.
🔑 Important: When interpreting
anova()results for invariance testing, a non-significant p-value (Pr(>Chisq)) indicates that the added constraints did not significantly worsen model fit, supporting the assumption of equality for the constrained parameters.
🔑 Important: The ability to compare latent variable means across groups is critically dependent on achieving at least strong (scalar) measurement invariance. Without it, observed mean differences may be confounded by measurement bias.
8. Advanced SEM topics: Multiple groups, measurement invariance, and data handling (part 2)
8.1 Addressing measurement invariance violations
When measurement invariance is not fully established across groups, several strategies can be employed:
- Group Selection: Remove specific groups or utilize subgroups if invariance violations are concentrated.
- Partial Invariance: Focus on achieving invariance for a subset of parameters, particularly factor loadings or intercepts, for specific items that exhibit differential functioning. The decision to retain or remove problematic items is not definitively settled in the literature.
- Explaining Differential Item Functioning (DIF): Investigate the root causes of non-invariance. This may involve identifying specific items that behave inconsistently across groups.
- Model Modification (Cautiously): While data-driven respecifications using modification indices can identify parameters violating equality constraints, they should be used with extreme caution due to the risk of overfitting and misleading results, especially when numerous modifications are required.
- MIMIC Models: Incorporate the grouping variable as an exogenous covariate that directly influences the observed indicators. This approach aims to "explain" DIF by modeling the relationship between group membership and item responses.
- Multilevel CFA: Utilize person or country-level predictors within a multilevel CFA framework to account for differential item functioning.
🔑 Important: Identifying the specific parameters responsible for non-invariance is complex and requires careful consideration beyond simple modification indices.
8.2 Handling missing data
Missing data is a common challenge in SEM, with different mechanisms dictating appropriate handling strategies.
-
Missing Data Mechanisms:
- Missing Completely at Random (MCAR): Data is missing randomly, independent of any observed or unobserved variables. Listwise deletion is acceptable here, though it leads to data loss.
- Missing at Random (MAR): The probability of data missing depends on observed, non-missing data, but not on the missing data itself. Listwise deletion is inappropriate as it leads to biased estimates.
- Not Missing at Random (NMAR): The probability of data missing depends on the missing values themselves. Specialized modeling techniques are required to account for this mechanism.
-
Approaches for MAR Data in SEM:
- Multiple Imputation (MI): Missing values are imputed multiple times to create several complete datasets. The SEM is then fitted to each dataset, and results are pooled to obtain final estimates and standard errors.
- Full Information Maximum Likelihood (FIML): This method uses all available information from incomplete cases by calculating the likelihood based on observed data for each individual, thereby avoiding biased estimates.
- Two-Stage Approach: This involves estimating the mean vector and covariance matrix using available data and then performing SEM on these estimated statistics.
🔑 Important: MAR is the most common scenario for missing data in SEM; failing to address it with methods like FIML or MI can lead to biased parameter estimates and incorrect standard errors.
8.2.1 Missing data handling in lavaan
lavaan offers several options for handling missing data:
| Option | Description | Default |
|---|---|---|
listwise | Excludes any case with at least one missing value. | Yes |
fiml | Full Information Maximum Likelihood estimation (uses all available data). | No |
ml | Equivalent to fiml. | No |
two.stage | Two-stage estimation approach using an EM algorithm for initial statistics. | No |
For multiple imputation, users typically create imputed datasets externally (e.g., using the mice package) and then employ lavaanList() or the runMI() function from the semTools package.
🔑 Important: While
listwisedeletion is the default,fiml(orml) is generally preferred for MAR data as it retains all available information and provides unbiased estimates.
8.3 Non-normal data and robust estimators
Real-world data frequently deviates from normality, necessitating robust estimation methods.
-
Types of Non-normality:
- Categorical/Limited-Dependent Outcomes: Binary, ordinal, nominal, count, or censored data. Specialized estimators like WLSMV (Weighted Least Squares Mean and Variance adjusted) or logit/probit models are used.
- Continuous Non-normal Data: Data exhibiting skewness, or excessive kurtosis (too flat or too peaked).
-
Strategies for Continuous Non-normal Data:
- Asymptotically Distribution-Free (ADF) Estimation: Estimators like Browne's WLS (Weighted Least Squares) make no normality assumptions but require very large sample sizes (typically N > 5000).
- Robust ML Estimation:
- Consistent Parameter Estimates: Standard Maximum Likelihood (ML) parameter estimates remain consistent even with non-normal data, provided the model is correctly specified and identified.
- Robust Standard Errors: Non-normality typically leads to underestimated standard errors. Robust standard errors correct for this, providing more accurate estimates of precision.
- Robust Scaled Test Statistic: Non-normality inflates the standard Chi-square test statistic. Scaled test statistics, such as the Satorra-Bentler scaled statistic, adjust this value to better reflect the model's fit.
- Bootstrapping: A resampling technique used to estimate the sampling distribution of statistics, providing robust standard errors and confidence intervals.
🔑 Important: Robust ML estimation (using robust standard errors and scaled test statistics) is the most commonly used and pragmatic approach for handling continuous non-normal data in SEM.
8.3.1 Robust ML implementation in lavaan
lavaan provides several options for robust estimation:
| Parameter | Setting | Description | Notes |
|---|---|---|---|
se | "robust" | Computes robust standard errors. | Corrects standard errors for non-normality. |
test | "Satorra-Bentler" | Computes the Satorra-Bentler scaled test statistic. | Adjusts the Chi-square test statistic for non-normality. |
estimator | "MLM" | Combines robust standard errors and Satorra-Bentler scaled statistic. | A common shortcut for robust ML. |
estimator | "MLR" | Similar to MLM, also suitable for missing data (missing = "ml"). | Often preferred when missing data is present. |
When using robust estimators, fit indices like CFI and TLI may have robust versions reported, offering more accurate fit assessments. Standard errors are typically slightly larger with robust methods, reflecting increased uncertainty due to non-normality.
🔑 Important: Using
estimator = "MLR"withmissing = "ml"is a robust choice for SEM when dealing with both non-normal and MAR missing data.
9. Advanced SEM topics: multiple groups, measurement invariance, and data handling (part 3)
9.1 Robust estimation and bootstrapping
Advanced SEM techniques often address issues arising from non-normal data and incomplete information, necessitating specialized estimators and resampling methods.
9.1.1 Robust estimators
Standard maximum likelihood (ML) estimation assumes multivariate normality. When this assumption is violated, particularly with skewed or heavy-tailed distributions, robust estimators are employed to provide more accurate standard errors and test statistics.
These estimators adjust for the violation of distributional assumptions.
The lavaan package offers robust estimators like "MLM" and "MLR" (based on scaling corrections). The mimic option in lavaan allows specifying the software (e.g., "EQS", "Mplus") that inspired the robust estimation method, offering compatibility with established practices.
| Estimator | Minimum Function Value | Test Statistic Value |
|---|---|---|
| ML | 85.022 | 81.141 |
| Robust | 85.306 | 81.908 |
🔑 Important: Robust estimators aim to correct standard errors and test statistics when data deviates from multivariate normality, providing more reliable inference.
9.1.2 Nonparametric bootstrap for parameter estimates
The nonparametric bootstrap is a resampling technique used to estimate the sampling distribution of parameter estimates.
- Procedure:
- Generate a bootstrap sample by randomly selecting cases from the original dataset with replacement.
- Fit the SEM model to this bootstrap sample.
- Extract the estimated parameter values.
- Repeat this process many times (typically R>1000).
- The bootstrap standard errors are the square roots of the diagonal elements of the covariance matrix of the collected parameter estimates.
🔑 Important: This method treats the original sample as the population, generating multiple simulated datasets to approximate the sampling variability of model parameters.
9.1.3 Bollen-Stine bootstrap for test statistics
Estimating the standard error using a nonparametric bootstrap is suitable for parameter estimates. However, for the test statistic (e.g., χ2), a modified bootstrap procedure is required.
This is because the standard nonparametric bootstrap reflects not only sampling variability but also model misfit.
- Bollen-Stine bootstrap procedure:
- The original sample data is first transformed so that the sample covariance matrix aligns with the model-implied covariance matrix. This step effectively samples from a distribution where the model is correctly specified.
- Then, the nonparametric bootstrap is applied to these transformed data.
- The bootstrap p-value for the test statistic is calculated as the proportion of bootstrap test statistics that exceed the original sample's test statistic value.
🔑 Important: The Bollen-Stine bootstrap provides a model-based adjusted p-value for the global fit test statistic, accounting for both sampling variability and potential misfit.
9.1.4 Bootstrapping in lavaan
The lavaan package simplifies the implementation of bootstrapping for both standard errors and test statistics.
| Command parameter | Functionality |
|---|---|
se = "bootstrap" | Computes bootstrap standard errors. |
test = "bootstrap" | Computes bootstrap-based p-values for the test statistic. |
When se = "bootstrap" is used, the parameterEstimates() output includes bootstrap-based confidence intervals. The bootstrapLavaan() function can be utilized to specifically compute Bollen-Stine p-values by specifying type = "bollen.stine".
📝 Example:
# Bootstrapping standard errors fit <- cfa(HS.model, data = HolzingerSwineford1939, se = "bootstrap", bootstrap = 1000) # Bootstrapping the test statistic (Bollen-Stine p-value) fit <- cfa(HS.model, data = HolzingerSwineford1939, test = "bootstrap", bootstrap = 1000)
🔑 Important:
lavaan's implementation of bootstrapping streamlines the process, offering efficient computation of robust standard errors and Bollen-Stine p-values.
🔑 Important: For the Bollen-Stine bootstrap p-value calculation, ensure to use a sufficiently large number of bootstrap replications (e.g., R=1000 or more) for reliable results.
© 2026 Maeve. All rights reserved. This content is protected by copyright.