Once the model has been specified and the starting values have been set, lavaan proceeds to estimate the free model parameters. The goal of estimation is to find the values of the free parameters, collected in the parameter vector \boldsymbol{\vartheta}, for which the model fits the data as well as possible according to some statistical criterion.
The word “data” requires some clarification, because SEM differs here from familiar regression methods. In ordinary least squares regression, the observations are the individual cases, and the residuals that are minimized are computed case by case. In SEM, the model is (most often) a statement about the population moments of the observed variables: typically a covariance structure, possibly with a mean structure. Estimation therefore compares the model with a summary of the data rather than with the individual cases. In the simplest and most common setting, all observed variables are continuous and jointly modeled, and the data are summarized by the sample covariance matrix \mathbf{S}: for P observed variables, P(P+ 1)/2 nonredundant numbers. The model, on its side, implies a covariance matrix \boldsymbol{\Sigma} of the same dimensions. Its elements are not free numbers but functions of the model parameters: fixing the values of the loadings, the factor (co)variances, and the residual variances of a factor model determines every entry of \boldsymbol{\Sigma}. To make this dependence explicit, the model-implied covariance matrix is written as \boldsymbol{\Sigma}(\boldsymbol{\vartheta}), a matrix-valued function of the parameter vector \boldsymbol{\vartheta}; chapter 4 gave the explicit form of this function for the LISREL and RAM representations. Estimation then means: find the \boldsymbol{\vartheta} for which \boldsymbol{\Sigma}(\boldsymbol{\vartheta}) resembles \mathbf{S} as closely as possible, in a sense that is made precise by the estimator. When a mean structure is included, the sample mean vector \bar{\mathbf{y}} joins the data side, and the model-implied mean vector \boldsymbol{\mu}(\boldsymbol{\vartheta}) the model side.
Not every analysis fits this simple picture. For ordered categorical indicators, the summary of the data consists of thresholds and polychoric correlations (chapter 14); with conditional_x = TRUE, the moments are taken conditionally on the exogenous covariates (Section 5.6.4); and for two-level data, there are within-level and between-level moments (chapter 16). Some analyses cannot be reduced to summary statistics at all: with missing data under full information maximum likelihood, the likelihood is evaluated per missing data pattern (Section 7.3.4); with random slopes in a two-level model, the model-implied covariance matrix differs from cluster to cluster (Section 16.13); and pairwise maximum likelihood works from the bivariate frequency tables of the ordinal indicators (Section 7.5). What remains in all these cases is the two-sided picture: on one side the data, in whatever form the estimator needs them, on the other side the model as a function of \boldsymbol{\vartheta}.
To illustrate, consider this one-factor model with four indicators:
lhs op rhs free ustart start
1 f =~ y1 0 1 1.000
2 f =~ y2 1 NA 0.732
3 f =~ y3 2 NA 0.653
4 f =~ y4 3 NA 0.200
5 y1 ~~ y1 4 NA 1.494
6 y2 ~~ y2 5 NA 1.132
7 y3 ~~ y3 6 NA 1.009
8 y4 ~~ y4 7 NA 1.192
9 f ~~ f 8 NA 0.050
Because of the do_fit = FALSE argument, no estimation has taken place. lavaan completed all the preparatory steps, including the computation of starting values for all the (eight) free parameters in the model, and then stopped. The data side, the sample covariance matrix \mathbf{S}, can be obtained as:
The two matrices are very different. This is to be expected, because the starting values only provide a starting point. If we estimate the model, the model-implied covariance matrix comes much closer to the sample covariance matrix:
fit <-sem(model, data = Demo.twolevel)lavInspect(fit, "implied")
lhs op rhs free ustart start est
1 f =~ y1 0 1 1.000 1.000
2 f =~ y2 1 NA 0.732 0.734
3 f =~ y3 2 NA 0.653 0.652
4 f =~ y4 3 NA 0.200 0.192
5 y1 ~~ y1 4 NA 1.494 1.018
6 y2 ~~ y2 5 NA 1.132 1.203
7 y3 ~~ y3 6 NA 1.009 1.180
8 y4 ~~ y4 7 NA 1.192 2.311
9 f ~~ f 8 NA 0.050 1.970
Note that the first row in the parameter table is not a free parameter. This parameter, which corresponds to the first factor loading, has been fixed to unity in order to set the scale of the latent variable. The coef() function can be used to extract the free model parameters only:
To explain how these estimates are obtained, and the range of approaches that is available, two conceptually distinct ingredients are needed:
an estimator, which defines the criterion by which the model-implied moments are compared with the data, and hence how \boldsymbol{\vartheta} is recovered from the data;
an optimization algorithm, which, for criterion-based estimators, searches for the minimum of that criterion with respect to \boldsymbol{\vartheta}.
The most common class of estimators minimizes a scalar discrepancy function that measures the gap between the data and the model-implied moments; different choices of the discrepancy function yield different estimators (ML, GLS, WLS, and their variants) with different statistical properties (Browne & Arminger, 1995). The precise notation for these functions, with the sample moments and the model-implied moments collected in vectors, is introduced in Section 7.4.1. Some estimators, however, do not involve a global fitting criterion; instead they use multi-stage estimation, obtaining different classes of parameters in separate stages. In instrumental-variable methods such as MIIV (Bollen, 1996), the directed effects (factor loadings and regression coefficients) are estimated equation by equation in a first stage, while the undirected effects (variances and covariances) follow in a second stage. Other multi-stage approaches apply a closed-form solution at every stage: examples include Bentler’s 1982 method (Bentler, 1982), Guttman’s multiple-group method (Guttman, 1952), and the James-Stein estimators (Burghgraeve et al., 2021). These estimators are the subject of chapter 17; Section 7.8 gives an overview.
For criterion-based estimators, lavaan uses an iterative optimization algorithm, by default a quasi-Newton method, with the Gauss-Newton and the Expectation-Maximization (EM) algorithms as alternatives. These algorithms start from the initial parameter values described in the preceding chapter (Section 6.1) and repeatedly update \boldsymbol{\vartheta} until the changes between successive iterations fall below a convergence threshold. Non-iterative estimators bypass this step entirely. The algorithm is selected automatically; it can be overridden via the optim_method argument.
The optimizer is a replaceable component. Throughout this book, statements such as “the default optimizer is a quasi-Newton method” describe the current configuration, not a fixed property of the estimators. The discrepancy functions and their gradients on the one hand, and the algorithm that minimizes them on the other, are separate components: any optimizer that can minimize a smooth function under bounds can drive lavaan’s fit functions, and the optim_method argument selects among the available choices. The current default is a bounded quasi-Newton method, and it will remain available; but the default may change at a major version boundary, for instance in favor of a Gauss-Newton/Fisher-scoring routine that exploits the structure of SEM objectives. For well-behaved problems, different optimizers agree to within the convergence tolerance; parameter estimates are defined by the discrepancy function, not by the algorithm that happens to minimize it. The algorithms themselves are described in Section 7.10; the routines behind the current defaults are named in the implementation notes at the end of this chapter.
Beyond the basic case, complications may arise when data are incomplete (missing values), when the observed variables are non-normally distributed, or when parameters are subject to equality or inequality constraints. Specialized procedures for each situation are described in the sections below.
7.2 Overview of estimators
If all variables are continuous, maximum likelihood (ML) is the most widely used estimator. But lavaan also offers alternative estimators, such as GLS, WLS, and IV. Table 7.1 lists the estimators available in lavaan.
Table 7.1: Estimators in lavaan. These estimators determine the point estimates \hat{\boldsymbol{\vartheta}}.
Estimator
Description
Notes
"ML"
Maximum Likelihood
Normal theory based; default for continuous data
"GLS"
Generalized Least Squares
Normal theory based
"WLS"
Weighted Least Squares
Asymptotically Distribution Free (ADF)
"DWLS"
Diagonally Weighted Least Squares
Default for categorical data
"DLS"
Distributionally-weighted LS
Uses Gauss-Newton optimizer by default
"ULS"
Unweighted LS
Weight matrix is identity
"PML"
Pairwise ML
Mostly used for categorical data
"RBM"
Reduced-Bias M-estimation
Penalized ML; continuous data only
"IV"
Instrumental Variables
Multi-stage; (mostly) non-iterative
"fabin2"
Instrumental Variables (OLS)
Non-iterative; CFA only
"fabin3"
Instrumental Variables (2SLS)
Non-iterative; CFA only
"bentler1982"
Bentler’s 1982 method
Non-iterative; CFA only
"MGM"
Multiple-group method
Non-iterative; CFA only
"JS"
James-Stein (scaling indicators)
Non-iterative; recursive SEM
"JSA"
James-Stein (aggregated indicators)
Non-iterative; recursive SEM
Four estimators support ordered categorical (ordinal) observed variables: WLS, DWLS, ULS, and PML. To declare variables as ordinal, use the ordered argument of the fitting function:
fit <-cfa(model, data = dat, ordered =TRUE) # all variables orderedfit <-cfa(model, data = dat, ordered =c("y1", "y2")) # specific variables
When ordered variables are present, lavaan automatically switches the default estimator from ML to DWLS.
The WLS, DWLS, and ULS estimators (and their robust variants, such as WLSMV) can also be used for two-level data (see the cluster argument), with continuous, ordinal, or mixed endogenous variables, and optionally exogenous covariates at either level. For categorical two-level data, the estimator must be requested explicitly (e.g., estimator = "WLSMV"). The summary statistics of the unrestricted two-level model are estimated first, stage-wise (variable by variable, then pair by pair) in the categorical setting, in the spirit of the two-level WLSMV approach of Mplus(Asparouhov & Muthén, 2007). The structured model is then fitted by (D)WLS to these statistics. The details are discussed in the chapter on multilevel SEM (Section 16.11.1 and Section 16.11).
Most estimators can also be fitted from a sample covariance matrix and, optionally, a mean vector and sample size, rather than from raw data. The exceptions are ML with missing = "ml" (FIML) and PML: both require case-level observations to form their respective casewise or pairwise likelihoods. How to supply sample statistics to lavaan is described in Section 5.2.
The SEM literature sometimes refers to ‘estimators’ with the name MLR or WLSMV. These ‘estimators’ originate from the Mplus software and are variants of the original estimators. However, these variants do not change the estimator itself (i.e., the point estimates of estimator = "ML" and estimator = "MLR" are identical). They merely replace the default standard errors and test statistic with robust alternatives. Table 7.2 lists these variants available in lavaan. Standard errors and test statistics are discussed in detail in the next chapter (Section 8.4 and Section 8.5).
Table 7.2: Mplus-style variant estimators in lavaan. These variants share the point estimates of their base estimator; they differ only in the computation of standard errors and the test statistic.
Estimator
Base
Standard errors
Test statistic
"MLM"
ML
"robust.sem"
"satorra.bentler"
"MLMV"
ML
"robust.sem"
"scaled.shifted"
"MLMVS"
ML
"robust.sem"
"mean.var.adjusted"
"MLR"
ML
"robust.huber.white"
"yuan.bentler.mplus"
"WLSM"
DWLS
"robust.sem"
"satorra.bentler"
"WLSMV"
DWLS
"robust.sem"
"scaled.shifted"
"WLSMVS"
DWLS
"robust.sem"
"mean.var.adjusted"
"ULSM"
ULS
"robust.sem"
"satorra.bentler"
"ULSMV"
ULS
"robust.sem"
"scaled.shifted"
"ULSMVS"
ULS
"robust.sem"
"mean.var.adjusted"
The default estimator for continuous data is ML. The default estimator in the categorical setting is DWLS. Switching to another estimator can be done by using the estimator argument when calling the fitting function. For example:
fit <-cfa(model, data = dat, estimator ="GLS")summary(fit, est =FALSE)
The estimator used is always shown at the top of the summary output.
7.3 Maximum likelihood estimation
7.3.1 The loglikelihood function
Maximum likelihood (ML) is the default estimator in lavaan for models with continuous observed variables. It rests on the assumption that the observed data \mathbf{y}_1, \ldots, \mathbf{y}_N are independent draws from a multivariate normal distribution, \mathbf{y}\sim \mathcal{N}(\boldsymbol{\mu}(\boldsymbol{\vartheta}),
\boldsymbol{\Sigma}(\boldsymbol{\vartheta})), where \boldsymbol{\mu}(\boldsymbol{\vartheta}) and \boldsymbol{\Sigma}(\boldsymbol{\vartheta}) are the model-implied mean vector and covariance matrix as functions of the parameter vector \boldsymbol{\vartheta}. When data are complete, the log-likelihood is:
where \bar{\mathbf{y}} is the observed sample mean vector and \mathbf{S} is the sample covariance matrix (with divisor N). The maximum likelihood estimator (MLE) \hat{\boldsymbol{\vartheta}} maximizes \text{logl}(\boldsymbol{\vartheta}) over \boldsymbol{\vartheta}.
7.3.2 The unrestricted model
In the unrestricted (or \mathsf{H}_1) model, all elements of \boldsymbol{\mu} and \boldsymbol{\Sigma} are free parameters. When data are complete, their MLEs are \hat{\boldsymbol{\mu}}=
\bar{\mathbf{y}} and \hat{\boldsymbol{\Sigma}}= \mathbf{S}. Substituting into Equation 7.1 and using \mathrm{tr}[\mathbf{S}\,\mathbf{S}^{-1}] =
P, the loglikelihood of the unrestricted model simplifies to:
Because the unrestricted model places no restrictions on \boldsymbol{\mu} and \boldsymbol{\Sigma}, it fits the data exactly. Its loglikelihood therefore serves as an upper bound against which any restricted model (\mathsf{H}_0) can be compared.
7.3.3 The ML discrepancy function
The standard likelihood ratio test (LRT) comparing the restricted model (\mathsf{H}_0) against the unrestricted model (\mathsf{H}_1) is:
where F_{\mathrm{ML}}(\boldsymbol{\vartheta}) is known as the normal-theory ML discrepancy function. The constant -\frac{NP}{2}\ln(2\pi) appears in both loglikelihoods and cancels in the difference. Working out the remaining algebra using Equation 7.1 and Equation 7.2, and using \mathrm{tr}\!\left[\boldsymbol{\Sigma}(\boldsymbol{\vartheta})^{-1}(\bar{\mathbf{y}}-\boldsymbol{\mu}(\boldsymbol{\vartheta}))
(\bar{\mathbf{y}}-\boldsymbol{\mu}(\boldsymbol{\vartheta}))'\right] =
(\bar{\mathbf{y}}-\boldsymbol{\mu}(\boldsymbol{\vartheta}))'\boldsymbol{\Sigma}(\boldsymbol{\vartheta})^{-1}
(\bar{\mathbf{y}}-\boldsymbol{\mu}(\boldsymbol{\vartheta})), gives:
When the mean structure is saturated (no restrictions on \boldsymbol{\mu}), the quadratic term vanishes because \boldsymbol{\mu}(\boldsymbol{\vartheta})= \bar{\mathbf{y}} at the optimum, and the discrepancy function reduces to:
F_{\mathrm{ML}}(\boldsymbol{\vartheta}) =
\mathrm{tr}\!\left[\mathbf{S}\,\boldsymbol{\Sigma}(\boldsymbol{\vartheta})^{-1}\right]
+ \ln|\boldsymbol{\Sigma}(\boldsymbol{\vartheta})| - \ln|\mathbf{S}| - P.
\tag{7.4}
Both forms are non-negative and equal zero if and only if the model fits the data perfectly. Because \text{logl}(\bar{\mathbf{y}}, \mathbf{S}) is a constant with respect to \boldsymbol{\vartheta}, maximizing the loglikelihood is equivalent to minimizing F_{\mathrm{ML}}.
To illustrate ML estimation, consider the classic Holzinger & Swineford example:
The value of the discrepancy function at the solution can be retrieved as:
fitMeasures(fit_ml, "fmin")
fmin
0.142
For historical reasons1, the fmin value computed by lavaan is half the value of F_{\mathrm{ML}}(\hat{\boldsymbol{\vartheta}}). Therefore, to obtain the conventional chi-square test statistic T_{ML} = N\cdot
F_{\mathrm{ML}}(\hat{\boldsymbol{\vartheta}}), multiplication by two is needed:
N <-nobs(fit_ml) # N = 301fmin <-fitMeasures(fit_ml, "fmin")T_ml <-2* N * fminround(unname(T_ml), 3)
[1] 85.306
The loglikelihood value at the solution can be retrieved from a fitted lavaan object:
logLik(fit_ml)
'log Lik.' -3737.745 (df=21)
or equivalently:
fitMeasures(fit_ml, "logl")
logl
-3737.745
The loglikelihood value for the unrestricted (\mathsf{H}_1) model can be obtained as follows:
fitMeasures(fit_ml, "unrestricted_logl")
unrestricted.logl
-3695.092
The LRT corresponds to the familiar chi-square test statistic:
When the model also includes explicit mean or intercept parameters, the mean structure is estimated simultaneously:
fit_ml_mean <-cfa(model, data = HolzingerSwineford1939, meanstructure =TRUE)
Because the mean structure is unrestricted in this model, the model-implied mean vector matches the sample mean vector, and the value of the discrepancy function is unchanged:
fitMeasures(fit_ml_mean, "fmin")
fmin
0.142
A more detailed description of how ML estimation works for this example (including full R code) can be found in Rosseel and Vidal (2025).
7.3.4 Full Information ML for missing data
When data are incomplete, a popular approach is Full Information Maximum Likelihood (FIML) (Enders, 2022). Rather than discarding incomplete cases (listwise deletion) or imputing missing values, FIML constructs a casewise likelihood that uses all available information for each observation. For the i-th case with observed variable set o_i, the casewise log-likelihood contribution is:
where the subscript o_i selects the rows and columns corresponding to the observed variables for case i, and |o_i| denotes their count. The full FIML log-likelihood is \sum_i \text{logl}_i(\boldsymbol{\vartheta}), and this is maximized over \boldsymbol{\vartheta}.
FIML is requested in lavaan via the missing argument:
fit <-sem(model, data = dat, missing ="ml") # or missing = "fiml"
FIML requires a mean structure; lavaan adds one automatically when missing = "ml" is set. Under the assumption that data are missing at random (MAR), FIML is asymptotically unbiased and efficient, and more powerful than listwise deletion.
FIML can also be combined with conditional_x = TRUE (single-level models with continuous data). The exogenous covariates must then be complete: cases with missing x-values are removed listwise, and missing = "ml.x" is not available in this combination. Internally, the casewise likelihood is expressed in conditional form, f(y_i \mid x_i), using only the observed y-values of each case (the corresponding internal kernels are mapped in Section 7.12). The same holds for the two-stage estimators (missing = "two.stage" and "robust.two.stage"), albeit only for estimator = "ML".
7.3.5 Auxiliary variables: the aux= argument
The validity of FIML depends on its MAR assumption, and MAR is a statement about the variables in the analysis: the missingness must be explainable by the variables that are part of the model. In practice, the best predictors of missingness (or of the incomplete variables themselves), such as background characteristics, earlier waves, or administrative variables, are often of no substantive interest, and putting them in the structural model would change the very model one wants to fit. The solution is to include them as auxiliary variables in the saturated-correlates style of Graham (2003): each auxiliary variable is added as one more observed variable that is freely correlated with every model variable (and with the other auxiliaries), with a free mean. Such a variable is structurally inert, but informative for the casewise likelihood. Writing out this block by hand (a full set of ~~ lines plus means) is tedious and error-prone; the aux= argument of the fitting functions does it automatically:
lavaan NOTE:
auxiliary (aux) variable(s) added to the model as saturated correlates
(estimated with FIML and hidden from the output): ageyr
The printed note documents what happened: ageyr was added as a saturated correlate, the model was estimated with casewise FIML over the enlarged variable set, and the auxiliary parameters (here eleven of them: a mean, a variance, and nine covariances) are hidden from summary() and parameterEstimates(). They do exist (compare length(coef(fit_aux)) with the number of rows in the parameter estimates output), and the degrees of freedom are unaffected, because the auxiliary block is saturated by construction. Estimates and standard errors of the model parameters change to the extent that the auxiliaries are informative; with a weakly correlated auxiliary such as ageyr the shift is modest, and auxiliaries are most useful when they correlate substantially with the incomplete variables or predict the missingness. Some practical notes: aux= is available for continuous, single-level data; with missing = "ml" it requires an ML-family estimator, and it implies meanstructure = TRUE and fixed_x = FALSE (the auxiliaries must be allowed to correlate with all other variables, covariates included). With missing = "two.stage" or "robust.two.stage", the same aux= argument uses a different mechanism (after Savalei & Bentler, 2009): the auxiliaries enter the first-stage EM estimation of the saturated moments, and the second stage then fits the model to the model-variable block of those moments, with the stage-1 uncertainty propagated into the standard errors.
7.3.6 Wishart ML
The normal ML approach uses the maximum likelihood estimator of \boldsymbol{\Sigma}, which is the sample covariance matrix with divisor N. An alternative, often used in older SEM software, is to base estimation on the unbiased estimator
which, under normality, follows a Wishart distribution with N- 1 degrees of freedom. This approach applies to covariance structure analysis only (not to models with a restricted mean structure) and requires complete data.
Replacing \mathbf{S} by \mathbf{S}_{N-1} in Equation 7.4 gives the Wishart ML (WML) discrepancy function:
F_{\mathrm{WML}}(\boldsymbol{\vartheta}) =
\mathrm{tr}\!\left[\mathbf{S}_{N-1}\,\boldsymbol{\Sigma}(\boldsymbol{\vartheta})^{-1}\right]
+ \ln|\boldsymbol{\Sigma}(\boldsymbol{\vartheta})| - \ln|\mathbf{S}_{N-1}| - P.
\tag{7.6}
The LRT derived from the Wishart distribution of \mathbf{S}_{N-1} uses N- 1 as the multiplier:
The model-implied covariance \boldsymbol{\Sigma}(\boldsymbol{\vartheta}) is said to be invariant with respect to a constant scaling factor (ICSF) if, for any \boldsymbol{\vartheta} and any positive constant \alpha, there exists a \boldsymbol{\vartheta}^{*} such that \boldsymbol{\Sigma}(\boldsymbol{\vartheta}^{*}) = \alpha\,\boldsymbol{\Sigma}(\boldsymbol{\vartheta}). Most structural models in use satisfy this condition. Under ICSF, given the normal ML estimate \hat{\boldsymbol{\vartheta}}_N, there exists a Wishart ML estimate \hat{\boldsymbol{\vartheta}}_W with \boldsymbol{\Sigma}(\hat{\boldsymbol{\vartheta}}_W) =
\frac{N}{N-1}\boldsymbol{\Sigma}(\hat{\boldsymbol{\vartheta}}_N), and the two discrepancy functions achieve the same minimum:
As a consequence, the fmin value reported by lavaan is the same for both approaches. The chi-square test statistics differ, however, because the multipliers are N for normal ML and N- 1 for Wishart ML.
In lavaan, Wishart-based ML is requested via the likelihood argument:
fit_wml <-cfa(model, data = HolzingerSwineford1939, likelihood ="Wishart")
The value for the discrepancy function at the solution is the same as for normal ML:
fitMeasures(fit_wml, "fmin")
fmin
0.142
The chi-square test statistic uses N- 1 instead of N:
Compare this with the normal ML value obtained earlier (85.306). The two statistics differ only by the factor (N- 1)/N= 0.9967.
7.3.7 The multiple group setting
In a multiple group analysis, a discrepancy function is defined for each group, and the total discrepancy function is a weighted sum of the group-specific values, with weights proportional to the relative group sizes:
is the discrepancy function for group g. Different groups may involve different sets of observed variables, so P_g can vary across groups.
The same N_g/N weighting applies to the FIML and Wishart ML variants. For the total LRT statistic, the group-level multiplier is N_g for normal ML (and FIML) and N_g - 1 for Wishart ML, giving respectively:
To illustrate, the Holzinger & Swineford example is refitted with two groups and equal factor loadings across groups:
fit <-sem(model, data = HolzingerSwineford1939, group ="school", group_equal ="loadings")
The per-group discrepancy values are part of the optimization results returned by lavInspect(fit, "optim") (each value is half of F_{\mathrm{ML}}^{(g)}, consistent with lavaan’s convention of halving the ML criterion throughout):
fmin_g <-lavInspect(fit, "optim")$fx.groupfmin_g
[1] 0.2205920 0.1904097
We can use lavInspect() to obtain the total and group-specific sample sizes:
N_total <-lavInspect(fit, "ntotal")N_total
[1] 301
N_g <-lavInspect(fit, "nobs")N_g
[1] 156 145
The total value for the discrepancy function is the weighted sum of the group-specific values:
This corresponds to the fmin value reported by fitMeasures():
fitMeasures(fit, "fmin")
fmin
0.206
The LRT (or chi-square test statistic) can be obtained as follows:
lrt <-2*sum(N_g * fmin_g)round(lrt, 3)
[1] 124.044
which matches the value reported by fitMeasures():
fitMeasures(fit, "chisq")
chisq
124.044
7.4 The weighted least squares family
7.4.1 The general framework
A broad family of estimators can be defined as follows. Let \mathbf{s} denote a vector of sample statistics. If we only consider a covariance structure, \mathbf{s} corresponds to the half-vectorization of the sample covariance matrix, \mathbf{s}= \mathrm{vech}(\mathbf{S}). If we add a mean structure, \mathbf{s} also contains the elements of the sample mean vector \bar{\mathbf{y}}. In the categorical setting with ordinal indicators, \mathbf{s} contains the thresholds and the polychoric correlations. In short, \mathbf{s} contains all the necessary summary statistics. Similarly, let \boldsymbol{\sigma}(\boldsymbol{\vartheta}) be the corresponding vector of model-implied moments.
The Weighted Least Squares (WLS) discrepancy function is:
where \mathbf{W} is some positive definite weight matrix with rows and columns that correspond to the elements of \mathbf{s} and \boldsymbol{\sigma}(\boldsymbol{\vartheta}). The general idea is that summary statistics that exhibit large variability (variance) across samples are weighted less when computing the value of the discrepancy function. In addition, some members of the WLS family take the covariances among the summary statistics into account. Different choices of \mathbf{W} give rise to different members of the WLS family. Five cases are available in lavaan:
WLS: Weighted Least Squares (also called Asymptotically Distribution-Free, or ADF) where \mathbf{W} is a full matrix;
DWLS: Diagonally Weighted Least Squares, where \mathbf{W} is a diagonal matrix;
GLS: Generalized Least Squares, where \mathbf{W} is constructed assuming normality;
ULS: Unweighted Least Squares, where \mathbf{W}= \mathbf{I};
DLS: Distributionally-weighted Least Squares, where \mathbf{W} is a weighted sum of the WLS and GLS weight matrices.
The GLS and DLS estimators are only available for continuous data, while the other three are available for both continuous and categorical data. The five WLS-type estimators are discussed in more detail in the following subsections.
One limitation of the WLS family of estimators is that they offer little support for missing values. Unlike ML, where missing values can be conveniently handled using FIML (missing = "ml") under the MAR assumption, the least squares estimators usually fall back on listwise deletion.
One exception is the categorical setting in combination with the WLS, DWLS, or ULS estimators. When the (polychoric or tetrachoric) correlation matrix is computed, pairwise deletion (missing = "pairwise") can be used. In that case, instead of dropping all cases as soon as one variable is missing, lavaan computes the correlation matrix by using all available data pairs for each pair of variables.
A second exception is two-stage estimation for the continuous-data least squares estimators (WLS, DWLS, ULS, GLS, and DLS). When missing = "two.stage" (or "robust.two.stage") is requested, the unrestricted (\mathsf{H}_1) model is first estimated with the EM algorithm under the MAR assumption (the algorithm is derived in appendix D.9.7), and the resulting moments replace the sample statistics \mathbf{s} in the discrepancy function. The standard errors and the test statistic are corrected to reflect the uncertainty of this first stage: the asymptotic covariance matrix of the EM moments (appendix D.9.6; see also the overview in Section 5.6.2) takes the place of \boldsymbol{\Gamma}, and the resulting two-stage standard errors are described in Section 8.4.11. Note that listwise deletion remains the default in the presence of missing values; the two-stage approach must be requested explicitly.
Finally, a generic alternative that works with every estimator, least squares and categorical data included, is multiple imputation, as implemented in the dedicated lavaan.mi package (the successor of the runMI() function formerly provided by semTools). The missing values are imputed m times (by any imputation engine, e.g. the mice package), the same lavaan model is fitted to each completed dataset, and the results are pooled: parameter estimates and standard errors by Rubin’s rules, and test statistics by dedicated pooling methods. Under MAR and a reasonable imputation model, this makes the least squares estimators comparable to FIML in their handling of missing data, at the cost of the extra imputation step, which is also one more component that can be misspecified. For ML-family estimation with continuous data, FIML (with auxiliaries via aux=, Section 7.3.5) remains the simpler option.
7.4.2 The WLS estimator
When normality cannot be assumed, the weight matrix should be estimated from the data without imposing distributional assumptions. Browne (1984) proposed the Asymptotically Distribution-Free (ADF) estimator, which uses a consistent non-parametric estimator \boldsymbol{\Gamma} of (N times) the asymptotic covariance matrix of the sample statistics. The weight matrix is \mathbf{W}=
\boldsymbol{\Gamma}^{-1}, and the resulting estimator is called WLS in lavaan (estimator = "WLS"):
fit_wls <-cfa(model, data = dat, estimator ="WLS")
The ADF estimator is asymptotically efficient under arbitrary continuous distributions, but requires the estimation of \boldsymbol{\Gamma}. Further information about this \boldsymbol{\Gamma} matrix when data are continuous can be found in section Section 5.6.2. Several options affect the computation of \boldsymbol{\Gamma} as it is used by the WLS estimator:
gamma_unbiased: when set to TRUE, an unbiased estimate of the Gamma matrix is computed (currently, the default is FALSE in line with tradition);
gamma_n_minus_one: when set to TRUE, the final matrix is divided by N- 1 instead of N; the default is FALSE;
gamma_wls_mplus: when set to TRUE, the computation of the Gamma matrix as used in WLS estimation is slightly adjusted, to mimic the results of Mplus.
The last option is triggered automatically if the option mimic = "Mplus" is used.
Despite its theoretically attractive properties, the WLS estimator is seldom used in practice. The reason is that the \boldsymbol{\Gamma} matrix can become very large and its inversion may become numerically unstable, particularly in smaller samples. Rules of thumb suggest N \geq 200 \cdot P, requiring sample sizes that are often not met in practice.
7.4.3 The DWLS estimator
An alternative to WLS that is more stable in smaller sample sizes is the Diagonally Weighted Least Squares (DWLS) estimator (estimator = "DWLS"):
fit_dwls <-cfa(model, data = dat, estimator ="DWLS")
The \mathbf{W}_{\mathrm{dwls}} matrix is constructed using the following steps:
The full \boldsymbol{\Gamma} matrix is computed;
The diagonal elements g_{ii} of \boldsymbol{\Gamma} are extracted;
The nonzero elements g_{ii} are inverted to obtain the weights w_{ii} = 1/g_{ii};
The diagonal matrix \mathbf{W}_{\mathrm{dwls}} is constructed by placing the w_{ii} elements on the main diagonal.
The steps are made explicit to avoid the common misunderstanding that \mathbf{W}_{\mathrm{dwls}} is constructed by setting the off-diagonal elements of \boldsymbol{\Gamma}^{-1} to zero, as is sometimes suggested in the SEM literature. In fact, a major advantage of DWLS is that the inverse of \boldsymbol{\Gamma} is not needed (Muthén, 1993).
The discrepancy function for DWLS can be written as:
For point estimation, DWLS often performs better than full WLS in smaller samples (Rhemtulla et al., 2012). The cost of using a sub-optimal weight matrix, however, is that the standard errors and test statistic must be corrected. The details are discussed in the next chapter (Section 8.4.4 and Section 8.5.3).
In the SEM literature, the DWLS estimator has been used almost exclusively in the categorical setting. Nevertheless, it works equally well with continuous variables. Some care is needed, however, to interpret the resulting fit measures (such as CFI, RMSEA, and SRMR), as the familiar cut-off values (which are based on ML) no longer apply.
7.4.4 The GLS estimator
The GLS estimator is only suitable when all the variables are continuous, and the data are single-level (by default, incomplete cases are removed listwise; but see the two-stage approach described in Section 7.4.1). If, in addition, we assume multivariate normality, the \boldsymbol{\Gamma} matrix simplifies to:
fit_gls <-cfa(model, data = dat, estimator ="GLS")
The GLS estimator is asymptotically equivalent to ML under normality, but is rarely preferred in practice.
If we let \mathbf{s}= [\mathbf{y}^{\prime},
\text{vech}(\mathbf{S}_{N-1})]^{\prime} and take the (block diagonal) structure of \mathbf{W}_{\mathrm{gls}} into account, the discrepancy function can be rewritten as follows:
When a correlation structure is fitted (correlation = TRUE), the default estimator is maximum likelihood, but the GLS and WLS estimators of this section remain available for it; the correlation-structure analysis is discussed together with the standardized solution in Section 12.5.
7.4.5 The ULS estimator
At the extreme end of the WLS family, Unweighted Least Squares (ULS) sets \mathbf{W}= \mathbf{I} (the identity matrix). The discrepancy function reduces to a simple sum of squared discrepancies:
fit_uls <-cfa(model, data = dat, estimator ="ULS")
ULS is often recommended as an alternative to DWLS when data are categorical (Forero et al., 2009). ULS can also be used for (non-normal) continuous data, although (unlike the other members of the WLS family) the parameter estimates depend on the scale of measurement. In addition, just like for the DWLS estimator, the conventional standard errors and test statistic are not valid (but lavaan will apply the necessary corrections automatically), and the same care is needed when interpreting the resulting fit measures (such as CFI, RMSEA, and SRMR): the familiar cut-off values are based on ML and no longer apply. Finally, because the identity weight matrix ignores the sampling variability of the sample statistics altogether, ULS is somewhat less efficient than the other members of the WLS family: its estimates tend to have a larger sampling variability than those of DWLS, and in particular of WLS, when the latter are well behaved.
7.4.6 The DLS estimator
The most recent member of the WLS family is the Distributionally-weighted Least Squares (DLS) estimator, proposed by Du and Bentler (2022). It is positioned between the two extremes of the family: ADF (which makes no distributional assumption but is unstable in finite samples, because the fourth-order moments needed for \boldsymbol{\Gamma} are estimated with high variability) and NT-GLS (which is stable in finite samples, but uses a misspecified weight matrix when the data are non-normal). DLS interpolates between the two by constructing the weight matrix from a convex combination of the ADF and the normal-theory estimates of \boldsymbol{\Gamma}:
Two values of a recover known estimators: when a = 0, \mathbf{W}_{\mathrm{dls}} reduces to \boldsymbol{\Gamma}^{-1} and DLS coincides with WLS; when a = 1, \mathbf{W}_{\mathrm{dls}} reduces to (\boldsymbol{\Gamma}^{\mathrm{NT}})^{-1} and DLS coincides with NT-GLS. Intermediate values combine the finite-sample stability of the normal-theory contribution with a degree of robustness to non-normality from the ADF contribution.
The normal-theory ingredient \boldsymbol{\Gamma}^{\mathrm{NT}} can be evaluated in two ways. If it is computed from the sample covariance matrix \mathbf{S}, the resulting estimator is denoted \mathrm{DLS}_S; if it is computed from the model-implied covariance matrix \boldsymbol{\Sigma}(\boldsymbol{\vartheta}) (and therefore re-evaluated at every iteration of the optimizer), it is denoted \mathrm{DLS}_M. Du and Bentler (2022) report that \mathrm{DLS}_M generally yields more accurate parameter estimates than \mathrm{DLS}_S.
In lavaan, DLS estimation is requested by setting estimator = "DLS":
fit_dls <-cfa(model, data = dat, estimator ="DLS")
Three options govern the behavior of DLS, and are passed via the estimator_args argument:
dls_a: the value of the tuning parameter a; the current default is 1, which corresponds to NT-GLS;
dls_gamma_nt: how \boldsymbol{\Gamma}^{\mathrm{NT}} is evaluated. The default is "model" (\mathrm{DLS}_M); setting it to "sample" selects \mathrm{DLS}_S;
dls_ftimes_nminus1: when set to TRUE, the discrepancy function is multiplied by N- 1 instead of N; the default is FALSE.
For example, to obtain \mathrm{DLS}_M with a = 0.5:
fit_dls <-cfa(model, data = dat, estimator =list(estimator ="DLS", dls_a =0.5))
In this case, the estimator argument is a list, where the first element defines the estimator, and the remaining elements contain options that change the behavior of this estimator.
Because \boldsymbol{\Gamma}^{\mathrm{NT}} depends on \boldsymbol{\vartheta} when dls_gamma_nt = "model", the gradient of F_{\mathrm{DLS}} contains terms that are absent in standard WLS or GLS. To exploit the least-squares structure of the discrepancy function, lavaan solves DLS by default with a damped Gauss-Newton optimizer (optim_method = "gn", see Section 7.10.3) rather than with the quasi-Newton optimizer used for the other WLS-family estimators. Choosing an appropriate value of a is itself a research question: Du and Bentler (2022) propose a bootstrap procedure that selects the value of a minimizing the root mean square error of the parameter estimates.
7.5 Pairwise maximum likelihood
When a model includes endogenous ordered categorical variables, the default estimator in lavaan is DWLS (see Section 7.4.3). By contrast, in the Item Response Theory (IRT) literature, marginal maximum likelihood is the prevailing choice. This approach is a full-information estimator with several theoretical advantages, notably its natural handling of missing data under the MAR assumption. However, marginal ML becomes computationally demanding as the number of latent variables grows, since evaluating the (log)likelihood requires integrating over all latent dimensions.
Pairwise maximum likelihood (PML), introduced for SEM with ordinal indicators by Katsikatsou et al. (2012), adopts a different strategy. It replaces the full multivariate likelihood with a composite pseudo-likelihood constructed from bivariate likelihoods. This avoids the high-dimensional integration problem (only two-dimensional integrals are needed) while preserving many desirable properties of full ML, such as consistency, asymptotic normality, and likelihood ratio–type tests for overall model fit and nested model comparisons. The tutorials section of the lavaan website contains a comprehensive tutorial on PML and its implementation in lavaan (authored by Myrsini Katsikatsou), including worked examples.
7.5.1 The pairwise log-likelihood
Let \mathbf{y}= (y_1, \ldots, y_{P})^{\prime} be a vector of P ordinal indicators, and assume the standard underlying-response-variable formulation: each y_p is the discretization of an underlying continuous variable y_p^{\star}, with \mathbf{y}^{\star} \sim
\mathcal{N}_{P}(\mathbf{0}, \mathbf{P}) where \mathbf{P} is a polychoric correlation matrix, and y_p = a if and only if \tau_{p,a-1} < y_p^{\star} \le \tau_{p,a} for thresholds -\infty = \tau_{p,0} < \tau_{p,1} < \ldots < \tau_{p,c_p} = +\infty. The parameter vector \boldsymbol{\vartheta} collects the model parameters that determine \mathbf{P} together with the thresholds.
The pairwise log-likelihood is the sum over all pairs of indicators of their bivariate log-likelihood contributions:
with \rho_{pp'} the model-implied polychoric correlation between y_p^{\star} and y_{p'}^{\star}. The PML estimator \hat{\boldsymbol{\vartheta}} is the value of \boldsymbol{\vartheta} that maximizes pl(\boldsymbol{\vartheta}).
Two features of Equation 7.12 are worth highlighting. First, all probabilities involve only the bivariate normal CDF \Phi_2, regardless of the dimension P of the indicator vector. Second, unlike DWLS or WLSMV, which estimate thresholds and polychoric correlations in two preliminary stages and then fit the structural model in a third stage, PML estimates all model parameters (including the thresholds) simultaneously by maximizing pl(\boldsymbol{\vartheta}) in a single optimization.
7.5.2 Usage in lavaan
PML estimation is requested by setting estimator = "PML":
fit_pml <-sem(model, data = dat, estimator ="PML")
The standard summary() output displays the value of the pairwise log-likelihood together with the adjusted pairwise LRT (PLRT) for overall fit, its (non-integer) degrees of freedom, the corresponding p-value, and the Satterthwaite scaling factor. For comparing two nested models, lavTestLRT() returns the adjusted PLRT along with the PL-AIC and PL-BIC of each model.
7.5.3 Missing data: complete-pairs and available-cases PL
PML lends itself naturally to handling item nonresponse, because each pair of variables can be processed independently. Two adaptations of PML are available in lavaan(Katsikatsou et al., 2022):
Complete-pairs PL (CP). (missing = "pairwise") Each pair (p, p') contributes only those observations for which both y_{ip} and y_{ip'} are observed; the pair’s contribution to the pairwise log-likelihood is computed using only those observations. Cases with missingness on one variable of a pair are omitted for that pair, but contribute to other pairs.
Available-cases PL (AC). (missing = "available.cases") In addition to the bivariate contributions of CP, AC includes univariate likelihood contributions for cases in which only one of the two variables in a pair is observed. This recovers all the marginal information in the data.
By default, the lavaan fit functions fall back to listwise deletion when the data contain missing values. The CP and AC adaptations are requested via the missing argument:
fit_cp <-sem(model, data = dat, estimator ="PML", missing ="pairwise")fit_ac <-sem(model, data = dat, estimator ="PML", missing ="available.cases")
Under the standard missing-at-random (MAR) assumption, CP and AC are not, in general, unbiased; however, simulations for SEM with ordinal indicators (Katsikatsou et al., 2022) report close-to-zero standardized bias for loadings and factor correlations, with the two methods performing nearly identically except on the threshold estimates (where AC tends to be less biased but with slightly underestimated standard errors). For loadings and factor correlations, CP and AC can therefore be used interchangeably, and either is preferable to listwise deletion when the data are not strictly MCAR.
7.6 Estimating models with composites
Models that combine common factors and composites (the <~ operator; Section 4.4) require no new estimation procedures: the composites enter the model exclusively through the model-implied moments of Equation 4.11, and any discrepancy function that operates on those moments applies unchanged. In particular, the ML discrepancy function of Section 7.3, including its robust companions (MLM, MLMV, MLR), as well as the least-squares family (GLS, WLS, ULS) and the bootstrap all work for models with composites; this ability to apply the full set of SEM methods to composite models is the main point of the factor- and composite-based framework of Schamberger et al. (2025). The categorical-data methods of the categorical-data chapter are available as well (under the default "Delta" parameterization): a composite model can contain ordinal indicators elsewhere in the model, and a composite may even be formed from the latent responses of ordinal indicators, with WLSMV-style robust standard errors and test statistics. What does change is the handling of derived parameters around the objective function, described below. (Not supported in combination with composites, at the time of writing: conditional_x = TRUE, parameterization = "Theta", the RAM representation, and the sam() function; each of these stops with an informative error message.)
7.6.1 Derived parameters
As explained in Section 4.4, the definition c = \mathbf{w}^{\prime}\mathbf{y}_c fixes both the variance and the mean of a composite as functions of other parameters: the total variance of c must equal \mathbf{w}^{\prime}\boldsymbol{\Theta}_c\mathbf{w}, and its intercept must equal \mathbf{w}^{\prime}\boldsymbol{\nu}_c. Consequently, the \boldsymbol{\Psi} and \boldsymbol{\alpha} entries of a composite are not free parameters; they are derived quantities, recomputed every time a new parameter vector is turned into model matrices, that is, at every evaluation of the objective function during optimization.
For an exogenous composite this is trivial: its \boldsymbol{\Psi} diagonal entry is set directly to \mathbf{w}^{\prime}\boldsymbol{\Theta}_c\mathbf{w}. For an endogenous composite (one that appears on the left-hand side of a regression), the requirement concerns the total variance [(\mathbf{I} - \mathbf{B})^{-1}\boldsymbol{\Psi}(\mathbf{I} - \mathbf{B}^{\prime})^{-1}]_{cc}, so the residual variance must be solved for. When the structural part is acyclic (no feedback loops), lavaan back-solves analytically: visiting each endogenous composite in turn, it computes the model-based variance contributed by its ancestors and sets the residual to the difference. This value may be negative, which is acceptable here because it is a derived quantity, not a variance parameter with a boundary. For cyclic (non-recursive) models, the same target is reached numerically with a small internal quasi-Newton optimization.
7.6.2 Scaling and identification
Weights are only identified up to a scale factor, so each composite needs a scaling convention: the same issue, and the same solution, as for common factors. By default, the first weight is fixed to 1 (the analogue of the marker-indicator convention); with std_lv = TRUE, all weights are free and the composite is instead given unit variance (internally, by rescaling such that \mathbf{w}^{\prime}\boldsymbol{\Theta}_c\mathbf{w} = 1).
7.6.3 The composites_cov option
The covariance block of the composite indicators, \boldsymbol{\Theta}_c, can be handled in two ways, controlled by the composites_cov option:
"fixed" (the default for single-level models): the entries are fixed to their sample counterparts. Since the model does not restrict these moments in any way, fixing them at the values that would maximize the fit in any case is a computational shortcut, not a substantive restriction: it removes the corresponding parameters and the corresponding sample statistics from the problem. The degrees-of-freedom count accounts for this (Section 4.4).
"free": the same entries are estimated as free parameters. The parameter count and the moment count both increase by the same amount, and the chi-square statistic, the degrees of freedom, and the estimates of all remaining parameters are identical to the "fixed" variant. This route is the default for multilevel models, where the same indicators may serve as composite indicators at more than one level: their within- and between-level covariance blocks are then both part of the model, and fixing each of them at “the” sample values would over-constrain the decomposition.
7.7 Handling equality and inequality constraints
Up to this point we have assumed that the optimizer is free to search the entire parameter space when looking for \hat{\boldsymbol{\vartheta}}. In practice, users often impose restrictions on \boldsymbol{\vartheta}: equality constraints (two factor loadings forced to be equal, a sum of regression coefficients required to equal one, a product of two parameters fixed to a constant) or inequality constraints (a residual variance bounded below by zero, one loading required to exceed another). This section explains how lavaan classifies these constraints internally, and which optimization strategy is used in each case.
7.7.1 Where constraints come from
Constraints can be specified in three ways. The first is implicit equality, expressed in the model syntax by labeling (at least) two parameters with the same name:
model <-'f =~ x1 + a*x2 + a*x3'# the two loadings must be equal
In a multiple-group analysis, similar constraints are generated automatically when arguments such as group_equal = "loadings" are used.
The second way is explicit equality, using the == operator. The constraint may be linear in the parameters,
The third way is inequality, either via the > and < operators in the model syntax, or through finite lower/upper bounds attached to individual parameters in the parameter table (the latter were discussed in the previous chapter, Section 6.2):
model <-' y ~ a*x1 + b*x2 a > 0 b < a'
Internally, every constraint is recorded in two places: as extra rows in the parameter table (with op equal to ==, > or <), and, once the model is built, as dedicated slots on the internal model object (the functions involved are listed in the implementation notes, Section 7.12.2). The following code illustrates the added rows in the parameter table:
model <-' f =~ x1 + a*x2 + b*x3 + c*x4 a == 3*b a * b == c^2'fit <-sem(model, data = HolzingerSwineford1939)parTable(fit)[, c("lhs", "op", "rhs", "free", "start", "est")]
lhs op rhs free start est
1 f =~ x1 0 1.000 1.000
2 f =~ x2 1 0.632 0.791
3 f =~ x3 2 0.669 0.264
4 f =~ x4 3 0.394 0.457
5 x1 ~~ x1 4 0.679 0.582
6 x2 ~~ x2 5 0.691 1.082
7 x3 ~~ x3 6 0.637 1.092
8 x4 ~~ x4 7 0.675 1.127
9 f ~~ f 8 0.050 0.777
10 a == 3*b 0 0.000 0.000
11 a*b == c^2 0 0.000 0.000
The summary() function will (by default) not show the constraints, but this can be overridden by the remove_eq (or remove_ineq) arguments:
summary(fit, header =FALSE, remove_eq =FALSE)
Parameter Estimates:
Standard errors Standard
Information Expected
Information saturated (h1) model Structured
Latent Variables:
Estimate Std.Err z-value P(>|z|)
f =~
x1 1.000
x2 (a) 0.791 0.176 4.505 0.000
x3 (b) 0.264 0.059 4.505 0.000
x4 (c) 0.457 0.101 4.505 0.000
Variances:
Estimate Std.Err z-value P(>|z|)
.x1 0.582 0.185 3.137 0.002
.x2 1.082 0.138 7.857 0.000
.x3 1.092 0.091 12.026 0.000
.x4 1.127 0.099 11.349 0.000
f 0.777 0.205 3.784 0.000
Constraints:
|Slack|
a - (3*b) 0.000
a*b - (c^2) 0.000
7.7.2 Constraint functions and slack values
Conceptually, each constraint can be written as a scalar-valued function of \boldsymbol{\vartheta}. lavaan stacks these functions into two vector-valued constraint functions:
An equality constraint function \mathbf{c}_{\text{eq}}(\boldsymbol{\vartheta}) that returns a vector of slack values whose i-th element is zero exactly when the i-th equality constraint is satisfied. For a constraint of the form g_i(\boldsymbol{\vartheta}) = c_i, the slack is simply g_i(\boldsymbol{\vartheta}) - c_i.
An inequality constraint function \mathbf{c}_{\text{in}}(\boldsymbol{\vartheta}) that returns a vector of slack values whose i-th element is non-negative exactly when the i-th inequality is satisfied. Bounds on individual parameters are folded into the same function: a lower bound \vartheta_j \ge L contributes the slack \vartheta_j - L, and an upper bound \vartheta_j \le U contributes U - \vartheta_j.
The bodies of these functions are constructed at model-build time by direct substitution of parameter labels for the corresponding entries of the parameter vector. To illustrate, consider the syntax
so that \mathbf{c}_{\text{eq}}(\boldsymbol{\vartheta}) returns a length-two vector of zeros at any \boldsymbol{\vartheta} that satisfies both constraints, and a non-zero vector elsewhere.
Two derived quantities are computed from each constraint function and play a central role in the remainder of this section. The constraint Jacobian
(with an analogous \mathbf{R}_{\text{in}} for the inequality constraints) is the linearization of the constraint surface at \boldsymbol{\vartheta}. When all constraints are linear in \boldsymbol{\vartheta}, this Jacobian is a constant matrix and the constraint can be written as \mathbf{R}_{\text{eq}}\, \boldsymbol{\vartheta}= \mathbf{b}_{\text{eq}} for some constant right-hand-side vector \mathbf{b}_{\text{eq}}. When at least one constraint is nonlinear, \mathbf{R}_{\text{eq}} depends on \boldsymbol{\vartheta} and must be recomputed at every iteration of the optimizer. lavaan distinguishes the two cases empirically, by evaluating the Jacobian at two random parameter vectors and checking whether it changes.
If equality constraints are present in the model, the row rank of \mathbf{R}_{\text{eq}} is used to adjust the degrees of freedom. In many settings, the row rank simply corresponds to the number of rows of \mathbf{R}_{\text{eq}} (and therefore the number of equality constraints), but if some equality constraints turn out to be redundant, the row rank will be less than the number of rows.
Internally, lavaan classifies the equality constraints of a fitted model into one of four mutually exclusive categories:
None: no equality constraints of any kind;
Simple: the only equality constraints are implicit, produced by shared labels or by group_equal. Such constraints are easy to enforce: lavaan could in principle estimate just one value per group of equality-constrained parameters. This special case is the subject of Section 7.7.7;
Linear: one or more == constraints are present and all of them are linear in \boldsymbol{\vartheta}. Their Jacobian \mathbf{R}_{\text{eq}} is therefore a constant matrix and the constrained problem can be reduced to an unconstrained one (Section 7.7.6);
Nonlinear: at least one == constraint is nonlinear in \boldsymbol{\vartheta}. The Jacobian must be recomputed at every iteration, and a proper constrained optimizer is required.
The classification is recorded in the internal model object alongside the constraint functions, Jacobians and right-hand sides (the flag names are listed in Section 7.12.2).
7.7.4 Inequality constraints: simple vs general
For inequalities, the classification has only three categories:
None: no inequality constraints, no parameter bounds;
Simple: all inequalities are box constraints, that is, finite lower and/or upper bounds on individual parameters, with no > or < constraint that involves more than one parameter. Box constraints do not require constrained optimization; they are passed directly to the (bounded) default optimizer as lower and upper limits on the parameters;
General: at least one inequality involves a combination of parameters. A constrained optimizer is required.
7.7.5 Unconstrained vs constrained optimization
Optimization algorithms split into two broad families. Unconstrained optimizers, of which lavaan’s default quasi-Newton optimizer is a representative example, search the parameter space without any restriction beyond optional box bounds on individual parameters. They are fast, robust, and relatively insensitive to imperfect starting values. Constrained optimizers can additionally enforce equality constraints and general inequality constraints directly, but they are typically slower, and considerably more sensitive to the quality of the starting values. For this reason, lavaan avoids a constrained optimizer whenever the problem can instead be reformulated into an unconstrained one.
The combination of the equality category and the inequality category determines which of the two routes is taken. A schematic overview summarizes the routing in Table 7.3.
Table 7.3: Routing of constrained problems in lavaan. Rows correspond to the equality-constraint category (Section 7.7.3), columns to the inequality-constraint category (Section 7.7.4). The “unconstrained” route uses the default quasi-Newton optimizer on a reduced parameter vector from which all (linear) equality constraints have been eliminated. The “constrained” route uses an augmented-Lagrangian method that calls the unconstrained optimizer for its inner loop (see the implementation notes at the end of this chapter).
ineq: none
ineq: simple
ineq: general
eq: none
unconstrained
unconstrained
constrained
eq: simple
unconstrained
unconstrained
constrained
eq: linear
unconstrained
constrained
constrained
eq: nonlinear
constrained
constrained
constrained
The pattern in the table reflects two simple facts. First, any nonlinear equality constraint forces the constrained route, because the constraint surface cannot be parameterized in closed form. Second, any general inequality also forces the constrained route, because the active set (the subset of inequalities that hold with equality at the optimum) is not known ahead of time. Conversely, when the only equality constraints are linear (or simple), and the only inequality constraints are box constraints, the constrained problem can always be transformed into an unconstrained one and the default unconstrained optimizer can be used. The two transformations that make this possible are described in the next two subsections.
Two post-fit details deserve a brief mention here. First, after convergence along the constrained route, lavaan classifies each inequality constraint as active (binding at the solution) or inactive using strict complementarity: a constraint is treated as binding only when its slack value is (near) zero and its Lagrange multiplier makes a non-negligible contribution to the gradient. This classification does not affect the point estimates, but it determines how the constraint is treated when standard errors and degrees of freedom are computed (see the next chapter). Second, when equality constraints coexist with bounds or general inequalities (the “constrained” cells of Table 7.3), the null-space reduction of the next subsection is not used during optimization; a null-space basis of the equality Jacobian is then constructed after fitting whenever downstream computations need to restrict a matrix to the directions that satisfy the equality constraints.
7.7.6 Reducing linear equality constraints to an unconstrained problem
The setting of this subsection is the row “eq: linear” and the column “ineq: none” of Table 7.3: K_{\text{eq}} linear equality constraints in T free parameters, with no inequalities and no nonlinear constraints. The constraint set can then be written as
where \mathbf{R}_{\text{eq}} is the constant K_{\text{eq}}\times T Jacobian and \mathbf{b}_{\text{eq}} collects the right-hand-side constants. Following Nocedal and Wright (2006, sec. 15.3), let
be the QR decomposition of \mathbf{R}_{\text{eq}}^{\prime} (with \mathbf{U} the upper-triangular factor, written so to avoid a clash with the Jacobian \mathbf{R}_{\text{eq}}). The columns of \mathbf{Q}_1 (T\times K_{\text{eq}}) span the range of \mathbf{R}_{\text{eq}}^{\prime}, and the columns of \mathbf{Q}_2 (T\times (T-K_{\text{eq}})) span its null space. Any \boldsymbol{\vartheta} that satisfies Equation 7.15 can therefore be written in the form
where \mathbf{Z}_{\text{eq}}= \mathbf{Q}_2 is the null-space basis, \mathbf{k}_0 is a particular solution of Equation 7.15, and \boldsymbol{\vartheta}_r\in \mathbb{R}^{T-K_{\text{eq}}} is a reduced parameter vector of dimension T-K_{\text{eq}}. The crucial observation is that, by construction, every value of \boldsymbol{\vartheta}_r produces a \boldsymbol{\vartheta} that automatically satisfies all linear equality constraints. The optimizer can therefore run unconstrained over \boldsymbol{\vartheta}_r, and lavaan benefits from the speed and stability of unconstrained optimization.
This transformation is computed once when the model is built, and the matrices \mathbf{Z}_{\text{eq}} and \mathbf{k}_0 are stored with the model (the implementation notes show the code, Section 7.12.2). Each time the discrepancy function or its gradient must be evaluated during estimation, \boldsymbol{\vartheta} is recovered from \boldsymbol{\vartheta}_r via Equation 7.17, and gradients with respect to \boldsymbol{\vartheta}_r are obtained from gradients with respect to \boldsymbol{\vartheta} by left-multiplication with \mathbf{Z}_{\text{eq}}^{\prime}. After convergence, the standard errors of \hat{\boldsymbol{\vartheta}} are obtained from an augmented (or bordered) information matrix, in which \mathbf{R}_{\text{eq}} acts as a Lagrangian border; that procedure is documented in the next chapter (Section 8.2.5).
7.7.7 The ceq_simple option
lavaan has two code paths for simple equality constraints (those produced implicitly by shared labels or by group_equal), and the option ceq_simple, currently FALSE by default, selects between them in the special case where only simple equality constraints are present.
The older path handles simple equality constraints separately from explicit == constraints. It relies on a 0/1 indicator matrix of dimension T\times T^{\star} (where T^{\star} <
T is the number of unique free parameters, after collapsing the duplicates) that maps the duplicated free parameter vector to its unique-parameter representation. The current path unifies the two: simple equality constraints are reformulated as == constraints in the parameter table, and the linear-constraint reduction of Section 7.7.6 is applied uniformly. The implementation notes at the end of this chapter record when the switch was made.
With ceq_simple = FALSE (the default), simple equality constraints are treated as ordinary linear == constraints. The QR/null-space reduction of Section 7.7.6 is used, and the optimizer searches over the reduced parameter vector \boldsymbol{\vartheta}_r. The Jacobian \mathbf{R}_{\text{eq}}, the constraint function \mathbf{c}_{\text{eq}}, and all related quantities are populated as for any other linear constraint.
With ceq_simple = TRUE, simple equality constraints are not reformulated as == rows in the parameter table. Instead, lavaan builds the legacy T\times T^{\star} indicator matrix \mathbf{L} and uses it directly as a projection from the duplicated to the unique-parameter space. The optimizer’s view of the problem (the parameter vector and its gradient) is then expressed in the reduced unique-parameter space: the gradient in the duplicated space is collapsed by left-multiplication with \mathbf{L}^{\prime}. (The model Jacobian \boldsymbol{\Delta} and the information matrix used for the standard errors, by contrast, are kept in the duplicated space; see Section 8.2.5.) No QR factorization is performed and no explicit \mathbf{c}_{\text{eq}} has to be evaluated. This path is somewhat faster on very large models with many such equality constraints, but it is more difficult to combine with later computations that involve both simple equality constraints and explicit == or > constraints. This is the historical reason it is no longer the default.
To illustrate, consider the following example where we first use ceq_simple = FALSE (the default) and then ceq_simple = TRUE:
lhs op rhs free label plabel est
1 f =~ x1 0 .p1. 1.000
2 f =~ x2 1 a .p2. 0.586
3 f =~ x3 2 a .p3. 0.586
4 f =~ x4 3 a .p4. 0.586
5 x1 ~~ x1 4 .p5. 0.500
6 x2 ~~ x2 5 .p6. 1.132
7 x3 ~~ x3 6 .p7. 0.915
8 x4 ~~ x4 7 .p8. 1.088
9 f ~~ f 8 .p9. 0.859
10 .p2. == .p3. 0 0.000
11 .p2. == .p4. 0 0.000
If ceq_simple = FALSE, the implicit equality constraints are translated to explicit equality constraints, as can be seen in the parameter table. Treating these simple equality constraints as linear equality constraints, the vector of 8 free parameters will be transformed to a reduced vector that is passed to the (unconstrained) optimizer.
lhs op rhs free label plabel est
1 f =~ x1 0 .p1. 1.000
2 f =~ x2 1 a .p2. 0.586
3 f =~ x3 1 a .p3. 0.586
4 f =~ x4 1 a .p4. 0.586
5 x1 ~~ x1 2 .p5. 0.500
6 x2 ~~ x2 3 .p6. 1.132
7 x3 ~~ x3 4 .p7. 0.915
8 x4 ~~ x4 5 .p8. 1.088
9 f ~~ f 6 .p9. 0.859
If ceq_simple = TRUE, the free column in the parameter table contains only 6 unique free parameters, although the first free parameter occurs three times. Only the 6 unique parameters are passed to the (unconstrained) optimizer.
Both approaches should lead to identical results. If a model contains a large number of simple equality constraints (e.g., when group_equal is used with a large number of groups), it is more efficient to use ceq_simple = TRUE. If only a few simple equality constraints are needed, the default (ceq_simple = FALSE) is adequate.
7.8 Multi-stage estimators
As noted at the start of this chapter, not every estimator in lavaan minimizes a single global discrepancy function. Multi-stage estimators obtain one class of parameters at a time: the directed effects (factor loadings and regression coefficients) in a first stage, the undirected effects (variances and covariances) in a second stage, and the mean-structure parameters in a third. Each stage has a closed-form solution, so that the estimator is non-iterative, or nearly so. It always returns a solution, needs no starting values or bounds, is fast, and confines a misspecification to the equations in which it occurs, at the cost of some efficiency under a correctly specified model. These estimators are the subject of chapter 17; this section only gives an overview.
Three such estimators are available, and they share most of their machinery:
the instrumental-variable estimator (estimator = "IV", described in Section 17.3): Bollen’s model-implied instrumental variables with two-stage least squares, or its k-class relatives LIML and Fuller, in the first stage. It is the most general of the three, covering any model that can be written as an errors-in-variables system, including higher-order factors and ordered categorical indicators;
the James-Stein estimators (estimator = "JS" and "JSA", described in Section 17.4), which replace the latent variables in each equation by their conditional expectation given the marker indicator, or given a reliability-weighted aggregate of the indicators; continuous data and recursive models only;
the multiple-group method (estimator = "MGM", described in the section Section 17.5): Guttman’s sum-score method for CFA models, extended with measurement-invariance constraints, residual covariances, cross-loadings, and factors without a marker.
Common to the three are the second stage for the variances and covariances (unweighted, generalized, or reweighted least squares on the residual moments), a joint generalized least squares solve of the mean structure, support for multiple groups with cross-group equality constraints, the two-stage treatment of missing data, analytic delta-method standard errors, and Browne’s residual-based test statistic as the default test; see Section 17.2. Two older non-iterative CFA estimators, the FABIN family ("fabin2", "fabin3") and Bentler’s 1982 method ("bentler1982"), are kept for reference and for the starting values of chapter 6; see Section 17.6.
The constraint syntax of Section 7.7 does not carry over unchanged to estimators without a global criterion. Simple and general linear equality constraints within a stage are supported by the IV and James-Stein estimators, and simple constraints (including the cross-group constraints of measurement invariance) by the multiple-group method. Constraints that span the two stages, nonlinear constraints, inequality constraints, and parameter bounds are not supported; see Section 17.2.5. A comparison of the three estimators is given in Section 17.7.
7.9 Which analyses need the raw data?
Historically, SEM was a technique for summary statistics: the classic programs only needed a covariance matrix and a sample size, and journal articles routinely printed the correlation table precisely so that others could reproduce (or re-analyze) the results. lavaan still supports this fully (Section 5.2), and the question of which results can and cannot be recovered from summary statistics alone is worth answering systematically: for reproducibility, for privacy-restricted data sharing, and for package developers who build on moments-only workflows.
The principle is simple. With two exceptions, every estimator in this chapter is a function of the sample moments alone: the criterion-based estimators minimize a discrepancy between the observed statistics and their model-implied counterparts, and the multi-stage estimators of Section 7.8 map the same statistics to the estimates in closed form. The estimates are then reproducible from summary statistics, provided the ingredients of the estimator (the weight matrix, for the WLS family) are supplied as well. The two exceptions are the estimators whose objective function is a sum over cases: direct FIML for incomplete data and pairwise maximum likelihood. For all others, the distinction concerns the standard errors and test statistics: some are functions of the summary statistics (possibly augmented with \boldsymbol{\Gamma}), while others are computed from the individual cases and cannot be recovered once only the summary statistics are available.
A raw-data fit is reproduced from the summary statistics exactly (estimates, standard errors, and test statistics) when everything it computes is a function of the moments:
ML and GLS, with their standard (normal-theory) inference: nothing beyond (\bar{\mathbf{y}}, \mathbf{S}, N) is needed;
the robustified ML variants MLM, MLMV, MLMVS and, more generally, any Satorra–Bentler-style scaled or adjusted test: these additionally require the ADF estimate of \boldsymbol{\Gamma} (Section 5.6.2), supplied via the nacov= argument;
the least squares estimators for ordered data (WLSMV, WLSM, ULSMV, DWLS, …): these require the sample thresholds and (polychoric) correlations plus the WLS.V and NACOV matrices;
continuous WLS and the ULS family: the weight matrix is estimator-specific, so the same estimator must be used when the moments are computed and when the model is refitted (for ULS, lavaan then reverts to normal-theory robust standard errors and the browne.residual.nt test, which are moment-based);
two-stage estimation for incomplete continuous data (missing = "two.stage" and "robust.two.stage"): the stage-1 EM moments and their asymptotic covariance matrix are themselves summary statistics, so the complete two-stage inference can be reproduced from them;
the multi-stage estimators (IV, JS, JSA and MGM, chapter 17): their closed-form stages, their delta-method standard errors and their residual-based test statistic are all functions of the moments (Section 17.2.1), so a fit from sample_cov and sample_nobs is identical to a fit from the raw data.
In contrast, whatever depends on the individual rows of the data matrix cannot be recovered from moments:
the Huber–White sandwich of MLR (se = "robust.huber.white"), whose middle matrix is built from casewise scores;
the first-order (outer-product-of-gradients) information of MLF;
cluster-robust standard errors (cluster= without level:);
the bootstrap (se = "bootstrap", test = "bootstrap"), which resamples cases;
pairwise maximum likelihood (PML, Section 7.5), whose likelihood is a sum over cases;
direct FIML for incomplete data (missing = "ml"): the casewise likelihood needs the cases (the two-stage approach above is the alternative that works with summary statistics);
and every casewise post-estimation tool: lavScores(), lavPredict(), casewise residuals, Mahalanobis distances, …
The export side of this workflow is automated by lavH1() (Section 5.7.4): with output = "lavMoments", it returns the summary statistics together with the WLS.V/NACOV matrices and the matching options, as one object that can be passed directly as the data= argument of the fitting functions. An example with MLM, in which the moments are exported and the model is refitted from them (MLM needs the ADF \boldsymbol{\Gamma}, hence gamma = TRUE):
The scaled test statistics (and every estimate and standard error) agree to machine precision. Attempting the same with estimator = "MLR" fails with an informative error (se = "robust.huber.white" requires full data). This is not a limitation of the software but of the information content of the moments themselves.
7.10 Optimization algorithms
Every criterion-based estimator of this chapter ends in the same task: find the parameter vector \hat{\boldsymbol{\vartheta}} that minimizes a discrepancy function F(\boldsymbol{\vartheta}). Except in special cases (a saturated model, or the non-iterative estimators of Section 7.8), no closed-form solution exists, and the minimum has to be located iteratively. All iterative methods have the same basic structure. Starting from initial values \boldsymbol{\vartheta}^{(0)} (the starting values of the preceding chapter, Section 6.1), they generate a sequence
where \mathbf{d}_k is a search direction and \alpha_k > 0 a step length, and they stop when the changes become negligible and the gradient \mathbf{g}(\boldsymbol{\vartheta}) = \partial F(\boldsymbol{\vartheta})/\partial \boldsymbol{\vartheta} is (close to) zero (the convergence criteria of Section 7.11.1). What distinguishes the methods is how the direction is chosen, and in particular how much information about the curvature of F they use to choose it. This section gives a conceptual overview of the families that matter for SEM. The textbook by Nocedal and Wright (2006) covers the general theory, Dennis and Schnabel (1996) is the classic reference for the Newton-type methods, and Lee and Jennrich (1979) compare the main methods specifically for covariance structure analysis.
7.10.1 Steepest descent and Newton’s method
The most elementary choice is the direction in which F decreases fastest, \mathbf{d}_k = -\mathbf{g}(\boldsymbol{\vartheta}^{(k)}) (steepest descent). A small enough step in this direction always lowers F, but the method is notoriously slow: it uses no information about the curvature of the surface, so it zigzags in long narrow valleys, its progress depends on the scaling of the parameters, and its convergence is only linear (each iteration reduces the remaining distance to the optimum by a roughly constant factor).
Newton’s method uses the curvature explicitly. Approximating F around the current point by its second-order Taylor expansion,
with \mathbf{H}_k the Hessian (the matrix of second derivatives) of F at \boldsymbol{\vartheta}^{(k)}, and minimizing the approximation over \mathbf{d} gives the Newton direction
Close to the solution, where the quadratic approximation is accurate, Newton’s method converges quadratically: the number of correct digits roughly doubles at every iteration, and a few iterations suffice. Two drawbacks explain why it is rarely used as such. First, the Hessian is expensive: it has T(T+1)/2 distinct elements, each a second derivative of the discrepancy function (analytic expressions exist for the normal-theory discrepancy functions, see appendix D.5, but evaluating them at every iteration is costly). Second, far from the solution the Hessian need not be positive definite, in which case the Newton direction may point uphill; a practical implementation must safeguard the step by a line search or a trust region, and must modify \mathbf{H}_k when it is indefinite. The Hessian does play a role after the optimization has finished: evaluated at \hat{\boldsymbol{\vartheta}} it is the observed information matrix (Section 8.2.2), the basis of one family of standard errors.
7.10.2 Quasi-Newton methods
Quasi-Newton methods keep the Newton direction of Equation 7.19 but replace the Hessian by an approximation \mathbf{B}_k that is built up from the gradients alone. The idea is that the change in the gradient between two successive points carries information about the curvature: for a quadratic function, \mathbf{H}(\boldsymbol{\vartheta}^{(k+1)} - \boldsymbol{\vartheta}^{(k)}) =
\mathbf{g}_{k+1} - \mathbf{g}_k. Requiring the approximation to satisfy this secant condition for the latest step, and to change as little as possible otherwise, leads to a rank-two update formula for \mathbf{B}_{k+1} in terms of \mathbf{B}_k, the step \boldsymbol{\vartheta}^{(k+1)} -
\boldsymbol{\vartheta}^{(k)} and the gradient change \mathbf{g}_{k+1} - \mathbf{g}_k. The best known of these formulas is the BFGS update (after Broyden, Fletcher, Goldfarb and Shanno); the older DFP update (Davidon, Fletcher, Powell), which was used in the first ML factor analysis and LISREL programs (Jöreskog, 1967), is based on the same principle. The update preserves positive definiteness as long as the step satisfies a mild condition that a line search guarantees, so every search direction is a descent direction, and the method converges superlinearly: slower than Newton’s method in the final iterations, but without ever forming a Hessian.
The attractions for SEM are evident. Only the gradient of the discrepancy function is needed, and lavaan has analytic gradients for all its discrepancy functions; the cost per iteration is of the order of T^2 operations; the method is robust against imperfect starting values; and bounded variants exist that keep individual parameters within lower and upper limits (Section 6.2), either by projecting the step onto the feasible box or by maintaining an active set of parameters that lie on a bound. For large numbers of parameters, limited-memory variants (L-BFGS) store only a few recent steps and gradient changes instead of the full matrix \mathbf{B}_k. This is the family of lavaan’s default optimizer (Section 7.1): optim_method = "BFGS" and "L.BFGS.B" select other implementations of the same idea.
7.10.3 Gauss-Newton and Fisher scoring
The least-squares discrepancy functions of Section 7.4 have a structure that a general-purpose method ignores. Write the residual vector as \mathbf{r}(\boldsymbol{\vartheta}) = \mathbf{s}- \boldsymbol{\sigma}(\boldsymbol{\vartheta}) and the model Jacobian as \boldsymbol{\Delta}= \partial \boldsymbol{\sigma}(\boldsymbol{\vartheta})/ \partial
\boldsymbol{\vartheta}^{\prime}. For F(\boldsymbol{\vartheta}) = \mathbf{r}^{\prime}\mathbf{W}\mathbf{r}, the gradient is \mathbf{g} = -2\boldsymbol{\Delta}^{\prime}\mathbf{W}\mathbf{r}, and the Hessian is
The second term involves second derivatives of the moment structure, but it is weighted by the residuals, which are small near the solution of a well-fitting model and exactly zero when the model is linear in \boldsymbol{\vartheta}. The Gauss-Newton method omits this term, which gives the direction
Only the Jacobian is needed, the matrix \boldsymbol{\Delta}^{\prime}\mathbf{W}\boldsymbol{\Delta} is positive semi-definite by construction (so the direction is always a descent direction), and the iteration amounts to solving a sequence of linear least-squares problems, each obtained by linearizing \boldsymbol{\sigma}(\boldsymbol{\vartheta}) around the current point. Convergence is quadratic when the residuals vanish at the solution and linear otherwise, with a rate that depends on how much curvature the neglected term carries. The weakness of the method is a nearly singular \boldsymbol{\Delta}^{\prime}\mathbf{W}\boldsymbol{\Delta}, as happens when some parameters are poorly identified by the data; the step then becomes very large and unreliable. The Levenberg-Marquardt modification (Levenberg, 1944; Marquardt, 1963) adds a damping term, solving (\boldsymbol{\Delta}^{\prime}\mathbf{W}\boldsymbol{\Delta}+ \mu\mathbf{D})\,\mathbf{d} =
\boldsymbol{\Delta}^{\prime}\mathbf{W}\mathbf{r} with \mathbf{D} the diagonal of \boldsymbol{\Delta}^{\prime}\mathbf{W}\boldsymbol{\Delta} (or the identity). When \mu is large the direction approaches a scaled steepest-descent step, which is safe; when \mu \rightarrow 0 it approaches the Gauss-Newton step, which is fast. The damping parameter is adapted at every iteration from the ratio of the actual to the predicted decrease of F, so the method automatically becomes cautious far from the solution and aggressive close to it.
Fisher scoring is the maximum likelihood counterpart. In Newton’s method applied to a negative log-likelihood, the Hessian is replaced by its expected value, the expected information matrix \mathcal{I}(\boldsymbol{\vartheta}) (Section 8.2.1), which is positive definite wherever the model is identified, so that \mathbf{d}_k =
\mathcal{I}(\boldsymbol{\vartheta}^{(k)})^{-1}\,(-\mathbf{g}_k). For the normal-theory ML discrepancy function, the expected information is of the form \boldsymbol{\Delta}^{\prime}\mathbf{W}(\boldsymbol{\vartheta})\boldsymbol{\Delta}, with \mathbf{W}(\boldsymbol{\vartheta}) the normal-theory weight matrix evaluated at the current model-implied moments. Fisher scoring for ML is therefore a Gauss-Newton iteration in which the weight matrix is updated at every step, and this is why ML estimation is often described as iteratively reweighted least squares(Lee & Jennrich, 1979). The same matrices appear once more after convergence: (\boldsymbol{\Delta}^{\prime}\mathbf{W}\boldsymbol{\Delta})^{-1} and \mathcal{I}(\hat{\boldsymbol{\vartheta}})^{-1} are the “bread” of the standard errors in the next chapter (Section 8.4), so a Gauss-Newton or scoring optimizer has the ingredients of the asymptotic covariance matrix at hand when it stops.
In lavaan, optim_method = "gn" selects a damped Gauss-Newton/Fisher scoring routine of this kind. It is the current default for the DLS estimator (Section 7.4.6) and for some WLS settings, but it can be requested for any criterion-based estimator. It handles linear equality constraints by optimizing in the reduced parameter space of Section 7.7.6, and simple bounds by projected steps combined with an active set.
7.10.4 The EM algorithm
The EM algorithm(Dempster et al., 1977) is built on a different principle. It does not approximate F by a quadratic; it exploits the fact that many likelihoods would be easy to maximize if certain unobserved quantities were known: the missing values in an incomplete data set, the factor scores in a factor model, the cluster means in a two-level model. Each iteration has two steps. The E-step computes the expected value of the complete-data log-likelihood, given the observed data and the current parameter values; the M-step maximizes this expected complete-data log-likelihood, which is a complete-data problem and often has a closed-form solution. The appeal is threefold. Every cycle increases the observed-data likelihood (it never goes uphill in F), no Hessian, no Jacobian and no line search are needed, and the iterates stay in the admissible region (variances remain positive, covariance matrices positive definite) without any special provisions. The price is speed. EM converges only linearly, and the rate is governed by the fraction of missing information: when the unobserved quantities carry much of the information about a parameter (many missing values, a between-level variance close to zero), hundreds or thousands of iterations may be needed, with the log-likelihood flattening out long before the parameters have settled. Two remedies are common: acceleration schemes that extrapolate from the EM path, such as SQUAREM (Varadhan & Roland, 2008) or quasi-Newton acceleration (Jamshidian & Jennrich, 1997), and a hand-off to a quasi-Newton method once EM has brought the parameters into the neighborhood of the solution. The monograph by McLachlan and Krishnan (2008) covers the theory and its many extensions; Rubin and Thayer (1982) is the classical application to factor analysis.
lavaan uses EM in three places: for the saturated model with missing data, where the M-step is in closed form (appendix D.9.7; see also Section 5.7), for the unrestricted two-level model (Section 16.6.2), and, with optim_method = "em", for the two-level structural model itself, where the M-step is a complete-data SEM fit (Section 16.7.2). The last of these is the current default optimizer for two-level models with missing = "ml", where its robustness outweighs its slower convergence; a quasi-Newton hand-off completes the optimization by default.
7.10.5 Which method, when?
Table 7.4 summarizes the trade-offs. For a well-specified model with reasonable starting values, all of these methods converge to the same minimum of F, and the estimates do not depend on which one found it (Section 7.1). The differences appear in the difficult cases: poor starting values, parameters at a boundary, nearly unidentified parameters, or a flat likelihood surface. The quasi-Newton family is the best general-purpose choice, which is why it is the default. Gauss-Newton methods are attractive when the discrepancy function has least-squares structure and the Jacobian is cheap, which is the case in lavaan. EM is the method of choice when the complete-data problem is simple and robustness matters more than speed. When the default optimizer fails to converge, Section 7.11 discusses what to do, and switching the algorithm is one of the options.
Table 7.4: Optimization methods used in SEM and their trade-offs. The last column gives the corresponding optim_method values.
Method
Curvature information
Needs per iteration
Convergence
In lavaan
Steepest descent
none
gradient
linear, slow
only as the safe limit of damped methods
Newton
exact Hessian
gradient and Hessian
quadratic
not used for estimation; Hessian at \hat{\boldsymbol{\vartheta}} for the observed information
Quasi-Newton (BFGS family)
secant approximation from gradient changes
gradient
superlinear
the default; "BFGS", "L.BFGS.B"
Gauss-Newton / Fisher scoring
\boldsymbol{\Delta}^{\prime}\mathbf{W}\boldsymbol{\Delta} or the expected information
Jacobian
quadratic for zero-residual problems, linear otherwise
"gn" (default for DLS)
EM
none
one E-step and one M-step
linear, slow but monotone
"em" (two-level models); the \mathsf{H}_1 model with missing data
7.11 Convergence failures and non-admissible solutions
Most estimators in lavaan rely on iterative optimization procedures, which can fail in two fundamentally different ways: the algorithm may fail to converge to any solution, or it may converge to a solution that is statistically inadmissible. In both cases, the issue should be carefully examined before interpreting or reporting results.
7.11.1 Convergence criteria
To determine whether a model has converged, lavaan applies two criteria:
The optimizer must indicate that a (local) solution has been successfully identified.
The absolute values of the elements in the (unscaled) gradient vector must fall below a specified tolerance (defined by the optim_dx_tol option, currently 0.001), except for parameters estimated at boundary values.
A model is considered converged only if both conditions are satisfied. If the first condition fails, lavaan issues the warning:
the optimizer warns that a solution has NOT been found!
If the optimizer reports convergence but the gradient criterion is not met, a different warning is produced:
the optimizer claimed the model converged,but not all elements of the gradient are (near) zero;the optimizer may not have found a local solution;use check_gradient =FALSE to skip this check.
A third warning covers a solution that satisfies both criteria but is not a minimum at all. An over-parameterized model (an over-factored EFA block, for instance) may have no minimum: a factor collapses onto a single indicator, its loading grows without bound and the residual variance of that indicator drifts towards minus infinity, while the objective function slowly approaches an infimum. At some point the optimizer reports convergence at an arbitrary point along that path. lavaan flags such a solution as having run away when a free residual variance of a continuous observed variable is more negative than the observed variance of that variable:
the optimizer claimed the model converged,
but the solution seems to have run away:
the estimated residual variance of y1 is [value], while its
observed variance is only [value];
the objective function may not have a minimum (an over-factored or
otherwise unidentified model?); consider adding bounds (e.g.,
bounds = "pos.var").
The automatic retries (optim_attempts, see Section 6.3) treat a runaway attempt like a non-converged one. A point at which the objective function had to be replaced by its cap (the stand-in for a non-finite value) is never accepted as a converged solution either, even when the optimizer reports convergence there. When no attempt is usable, the non-converged attempt with the smallest finite objective is returned, with this warning.
Earlier versions of lavaan relied solely on the optimizer’s assessment (criterion 1); the gradient-based criterion was added later. Ideally, the scaled gradient would be preferable, but its computation requires the Hessian matrix, which may itself be unreliable. While stricter checks could be implemented, such as lowering the gradient tolerance or incorporating second-order conditions based on the Hessian, the default settings aim to balance sensitivity to genuine convergence failures against the risk of falsely flagging converged models.
Users can modify this behavior in several ways:
Adjust the tolerance via the optim_dx_tol option;
Disable the gradient check with check_gradient = FALSE;
Override both checks using optim_force_converged = TRUE (the model is then always treated as converged).
If convergence is not achieved, the summary() function clearly reports this at the top of the output:
lavaan [version number] did NOT end normally after 192 iterations
** WARNING ** Estimates below are most likely unreliable
In such cases, the reported parameter estimates correspond to the final iteration and are provided solely for diagnostic purposes. They should not be considered reliable and must not be reported.
7.11.2 What to do if a model fails to converge?
Model nonconvergence can arise for a variety of reasons. Clear issues with the model specification or the data, such as perfectly collinear variables or a singular covariance matrix, are typically identified early, with corresponding warning messages provided.
In many cases, however, diagnosing the underlying cause of nonconvergence is not straightforward. The following strategies can help:
Simplify the model. Excessively complex models relative to the available data often fail to converge. Begin with a more parsimonious specification and incrementally reintroduce complexity. Although this approach does not directly resolve the original issue, it can help isolate the problematic part of the model
Use bounded estimation when appropriate. With small sample sizes, parameter estimates may become implausible (e.g., a variance estimate of −4000). In such cases, bounded estimation (bounds = TRUE) can help stabilize the solution (see Section 6.2.2). Bounds are also the remedy for a solution that has run away (Section 7.11.1): bounds = "pos.var" keeps the residual variances nonnegative, and the optimizer can no longer follow the path towards minus infinity.
Check the scale of the variables. Very different variances across observed variables (say, one variable measured in the thousands and another in the hundredths) can slow the optimizer considerably or prevent convergence altogether. lavaan detects this situation automatically: with the current default rescale_data = "auto", poorly scaled variables are internally rescaled (each divided by a power of two close to its standard deviation, a lossless operation), the model is fitted in the well-scaled metric, and the full solution (estimates, standard errors, and test statistics) is mapped back to the original units exactly. rescale_data = TRUE forces the rescaling; rescale_data = "none" disables it. In the settings where the automatic rescaling does not apply (summary-statistics input, multilevel, categorical, and a few others), the classical advice still holds: rescale those variables manually before fitting. A milder alternative leaves the data unchanged and rescales the parameters inside the optimizer: with optim_parscale = "standardized", each free parameter is multiplied by the factor that would map it to its standardized metric (a latent variable takes the scale of its marker indicator), and the constraints are still imposed on the original parameters, so the setting is safe with any type of constraint. The automatic retries (optim_attempts) use it when the first attempt fails.
Modify starting values. Alternative initial values may improve convergence. These can be specified manually or generated via a brute-force approach using random starting values (see Section 6.3).
Switch the optimization algorithm. The current default optimizer can be replaced with alternatives (see Section 7.1). For example:
fit <-cfa(model, data = dat, optim_method ="BFGS")
Other available options include gn (Levenberg-Marquardt damped Fisher scoring; see Section 7.4.6), L.BFGS.B, and (for two-level models only) em. Note that the EM algorithm is the current default optimizer for two-level models with missing = "ml", as it tends to be more robust in that setting.
7.11.3 Non-admissible solutions
Even if the optimizer reports convergence, the resulting solution may still be improper or statistically inadmissible. This occurs when one or more parameter estimates are not plausible from a statistical standpoint, for example negative variances or correlations with absolute values greater than one.
If check_post = TRUE (the default), lavaan performs a series of post-estimation checks:
Negative variances for observed variables. If any residual variance associated with an observed variable is negative, the following warning is issued:
some estimated ov variances are negative
Negative variances for latent variables. If any residual variance associated with a latent variable is negative, the following warning is issued:
some estimated lv variances are negative
The covariance matrix implied for the latent variables must be positive definite. If this condition is violated, the following warning is produced:
covariance matrix of latent variables is not positive definite;use lavInspect(fit, "cov_lv") to investigate.
The covariance matrix of residual measurement errors (\boldsymbol{\Theta}) must be positive definite. If not, lavaan reports:
the covariance matrix of the residuals of the observed variables(theta) is not positive definite; use lavInspect(fit, "theta")to investigate.
The covariance matrix of the residuals in the structural part of the model (\boldsymbol{\Psi}) must be positive definite. This matrix also holds the residual (co)variances of the observed endogenous variables, which are represented internally as dummy latent variables (Section 4.3.4). For numeric endogenous variables, that block is covered by the fourth check, but the residual (co)variances among ordered endogenous variables appear in neither the third nor the fourth check. If \boldsymbol{\Psi} is not positive definite, lavaan reports:
the covariance matrix of the residuals in the structural part ofthe model (psi) is not positive definite; uselavInspect(fit, "est")$psi to investigate.
The third check is only performed if no negative latent variances are detected, the fourth check is only carried out if all observed variances are non-negative, and the fifth check only for the blocks that passed the third and fourth checks (a matrix that fails one of those cannot be positive definite either, and the warning is not repeated). In multiple-group and multilevel models, the checks are carried out per group or per block, and the warnings say which one failed.
To assess positive definiteness, lavaan evaluates the eigenvalues of the relevant matrix. For these post-estimation checks, a matrix is flagged as non–positive definite if any eigenvalue is smaller than -1 * .Machine$double.eps^(3 / 4), scaled by the largest eigenvalue (or by one, for a matrix with small entries), so that the tolerance follows the scale of the matrix. This relatively lenient threshold is chosen to balance sensitivity to genuine problems against minor numerical imprecision near zero.
These post-estimation checks can be skipped. For example:
fit <-cfa(model, data = dat, check_post =FALSE)
As with convergence failures, identifying the root cause of inadmissible solutions is often challenging. Such issues may arise from model misspecification, overparameterization, or an insufficient sample size relative to model complexity.
From a technical standpoint, it is possible to constrain variances to be nonnegative during estimation by setting the option bounds = "pos.var". However, this approach suppresses the diagnostic value of negative variance estimates, which can serve as indicators of deeper problems in the model. For this reason, lavaan allows negative variances by default, leaving it to the user to determine whether they are negligible artifacts or substantive signs of model misspecification.
7.11.4 Keeping the latent covariance matrix positive definite
Bounds act on single parameters, and cannot express the requirement that a covariance matrix as a whole is positive definite: with two or more correlated latent variables, all the variances can be positive while a correlation exceeds one. Consider a model in which the three visual indicators of the Holzinger–Swineford data (and a fourth variable) are spread over two factors:
Warning: lavaan->lav_object_post_check():
covariance matrix of latent variables is not positive definite; use
lavInspect(fit, "cov.lv") to investigate.
lavInspect(fit_split, "cor_lv")
v1 v2
v1 1.000
v2 1.082 1.000
The estimated correlation between the two factors is larger than one, and lavaan issues the third warning of the list above. With pd_lv = TRUE, the model is estimated in such a way that the covariance matrix of the latent variables cannot leave the admissible region. The free (residual) variances and covariances of the latent variables (the free elements of \boldsymbol{\Psi}) are replaced, during the optimization only, by the elements of the Cholesky factor of this matrix; whatever values the optimizer tries, the implied matrix is positive (semi)definite. Covariances that are fixed to zero stay exactly zero, and the results are reported in the usual parameterization.
fit_pd <-cfa(model_split, data = HolzingerSwineford1939, pd_lv =TRUE)
Warning: lavaan->lav_step11_estoptim():
pd_lv = TRUE: the solution is on the boundary of the admissible region:
the variance-covariance matrix of the following latent variables is
singular: 'v1', 'v2'. The standard errors are computed as if the model was
restricted to this boundary (some standard errors may be zero); the
degrees of freedom are not adjusted, and the test statistic(s) may not
follow a chi-square distribution.
If the solution lies in the interior of the admissible region, the results are identical to those of the default setting. Here it does not: the solution ends on the boundary (a correlation of exactly one), which the warning reports. The boundary is then treated as an active inequality constraint. The standard errors are computed as if the model was restricted to this boundary, as for a parameter that lies on a bound (Section 8.4.3), and some of them may be zero; the summary() header reports the corresponding row rank of the constraints matrix. The degrees of freedom are not adjusted, and the test statistic need not follow a chi-square distribution: in the example, the statistic increases (the admissible solution fits slightly worse than the inadmissible one), while the degrees of freedom stay the same.
In version 0.7-4, the option requires that the variances of the latent variables are either free or fixed to a positive value (as with std_lv = TRUE), that the covariances among them are either free or fixed to zero, and that these variances and covariances are not involved in equality or inequality constraints and carry no user-specified bounds; otherwise an error is raised. Automatic bounds (Section 6.2.2) are ignored for these parameters. The option works with the quasi-Newton optimizers and with the EM algorithm for two-level models (where the M-step becomes a constrained M-step), and in two-level models the random slopes are treated as latent variables, so that the covariance matrix of the random effects is kept positive definite as well.
A third value, pd_lv = "auto", applies the device wherever this is possible: a set of correlated latent variables that cannot be handled (because group_equal includes "lv.variances", for example) is silently left unchanged instead of raising an error, and nothing is done if the optimizer does not support the option. The price is that two models that are compared may not have been estimated in the same way. The current default is pd_lv = FALSE, except for models with random slopes, where it is "auto" (Section 16.13). The reservation made for bounds = "pos.var" applies here too: a correlation larger than one is a diagnostic signal (in the example, that the two factors are not distinct), and forcing the solution to be admissible does not repair the model.
7.12 Implementation notes
This section collects details that are tied to the current implementation of lavaan (the R package, version 0.7-4) rather than to the concepts of the main text. Internal file and function names may change or move at any release, while everything reachable through the user interface stays put. Table 7.5 maps the estimation procedures of this chapter to their source files.
Table 7.5: Source files behind the estimation procedures.
Topic
File(s)
FIML with conditional_x = TRUE (casewise kernels)
lav_mvreg_missing.R
auxiliary variables (aux=, FIML and two-stage routes)
analytic gradients (assembled from the model Jacobian)
lav_model_gradient.R
equality and inequality constraint handling
lav_constraints.R
7.12.1 The default optimizer
The “default quasi-Newton optimizer” of the main text (Section 7.1) is nlminb() from R’s stats package, an interface to the PORT optimization library. It has been lavaan’s default since the very first release, and it is what optim_method = "nlminb" (the current default value) selects. lavaan supplies the analytic gradient of the discrepancy function and lets nlminb() approximate the curvature. Box constraints (simple bounds on individual parameters, Section 7.7.4) are handed to nlminb() through its lower and upper arguments, which is why they do not require the constrained route. The alternative values "BFGS" and "L.BFGS.B" are routed to R’s optim(), "gn" to the internal Levenberg-Marquardt/Fisher-scoring routine, "em" to the multilevel EM algorithm, and "noniter" to the non-iterative estimators; the control argument of lavaan() is passed through to nlminb() or optim() unchanged. The constrained route of Section 7.7.5 is the internal function nlminb_constr(), an augmented-Lagrangian method that calls nlminb() for each unconstrained inner problem. A few other places in the package run small, local nlminb() problems of their own, for instance the residual-variance solve for cyclic composite models.
7.12.2 Constraints
The constraint machinery of Section 7.7 is implemented in lav_constraints.R. When the model is built, lav_con_parse() turns the ==, < and > rows of the parameter table into the constraint functions (\mathbf{c}_{\text{eq}} in @ceq.function, \mathbf{c}_{\text{in}} in @cin.function), their Jacobians (@ceq.JAC, @cin.JAC) and right-hand sides, and stores them as slots of the internal model object, together with the classification flags (ceq.simple.only, ceq.linear.only.flag, ceq.nonlinear.flag, cin.simple.only) that drive the routing of Section 7.7.5. With ceq_simple = TRUE (Section 7.7.7), the legacy indicator matrix is stored as @ceq.simple.K instead. That indicator-matrix path was the only treatment of simple equality constraints up to lavaan 0.5-17; the unified == path became the default in 0.5-18. Linearity is detected by lav_con_linear_idx(), which evaluates the Jacobian at two random parameter vectors. After fitting, lav_con_cin_inactive_idx() classifies the inequality constraints as active or inactive, and lav_con_eq_basis() constructs a null-space basis of the equality Jacobian when the reduction below was not used during optimization.
The reduction of Section 7.7.6 is computed by the following block, which stores \mathbf{Z}_{\text{eq}} as @eq.constraints.K and \mathbf{k}_0 as @eq.constraints.k0 on the internal model object:
The derived variance and intercept of a composite (Section 7.6) are recomputed by lav_lisrel_comp_set_intresvar() whenever a parameter vector is turned into model matrices. The model Jacobian \boldsymbol{\Delta} is produced by lav_model_delta() (file lav_model_gradient.R). Up to version 0.6-21, the analytic gradient did not cover the composite chain of Equation 4.11, and composite models required the workaround optim_gradient = "numerical"; since version 0.7-2, lav_model_delta() handles composites analytically and the workaround is no longer needed.
A historical note: the <~ operator predates the composite framework. Up to version 0.6-19, it was interpreted as a formative factor, a latent variable with freely correlated indicator “causes” and a residual variance fixed to zero. This restricts the indicator covariances in a way a composite does not, and does not enforce c = \mathbf{w}^{\prime}\mathbf{y}_c. The current interpretation (introduced in 0.6-20 and refined since) is governed by the composites option, which is TRUE by default.
Asparouhov, T., & Muthén, B. O. (2007). Computationally efficient estimation of multilevel high-dimensional latent variable models. Proceedings of the 2007 Joint Statistical Meetings, Section on Statistics in Epidemiology, 2531–2535.
Bentler, P. M. (1982). Confirmatory factor-analysis via noniterative estimation - a fast, inexpensive method. Journal of Marketing Research, 19(4), 417–424.
Bollen, K. A. (1996). An Alternative Two Stage Least Squares (2SLS) Estimator for Latent Variable Equations. Psychometrika, 61(1), 109–121.
Browne, M. W. (1974). Generalized Least Squares Estimators in the Analysis of Covariances Structures. South African Statistical Journal, 8, 1–24.
Browne, M. W. (1984). Asymptotic distribution-free methods in the analysis of covariance structures. British Journal of Mathematical and Statistical Psychology, 37(1), 62–83.
Browne, M. W., & Arminger, G. (1995). Specification and estimation of mean- and covariance-structure models. In G. Arminger, C. C. Clogg, & M. E. Sobel (Eds.), Handbook of statistical modeling for the social and behavioral sciences (pp. 311–359). Plenum Press.
Burghgraeve, E., De Neve, J., & Rosseel, Y. (2021). Estimating structural equation models using James-Stein type shrinkage estimators. Psychometrika, 86(1), 96–130.
Dempster, A. P., Laird, N. M., & Rubin, D. B. (1977). Maximum likelihood from incomplete data via the EM algorithm. Journal of the Royal Statistical Society: Series B (Methodological), 39(1), 1–38. https://doi.org/10.1111/j.2517-6161.1977.tb01600.x
Dennis, J. E., Jr., & Schnabel, R. B. (1996). Numerical methods for unconstrained optimization and nonlinear equations. SIAM.
Du, H., & Bentler, P. M. (2022). Distributionally-weighted least squares in structural equation modeling. Psychological Methods, 27(4), 519–540. https://doi.org/10.1037/met0000388
Enders, C. K. (2022). Applied missing data analysis. Guilford Publications.
Forero, C. G., Maydeu-Olivares, A., & Gallardo-Pujol, D. (2009). Factor analysis with ordinal indicators: A monte carlo study comparing DWLS and ULS estimation. Structural Equation Modeling: A Multidisciplinary Journal, 16(4), 625–641. https://doi.org/10.1080/10705510903203573
Graham, J. W. (2003). Adding missing-data-relevant variables to FIML-based structural equation models. Structural Equation Modeling: A Multidisciplinary Journal, 10(1), 80–100. https://doi.org/10.1207/S15328007SEM1001_4
Guttman, L. (1952). Multiple group methods for common-factor analysis: Their basis, computation, and interpretation. Psychometrika, 17(2), 209–222.
Jamshidian, M., & Jennrich, R. I. (1997). Acceleration of the EM algorithm by using quasi-Newton methods. Journal of the Royal Statistical Society: Series B (Methodological), 59(3), 569–587. https://doi.org/10.1111/1467-9868.00083
Jöreskog, K. G. (1967). Some contributions to maximum likelihood factor analysis. Psychometrika, 32(4), 443–482.
Katsikatsou, M., Moustaki, I., & Jamil, H. (2022). Pairwise likelihood estimation for confirmatory factor analysis models with categorical variables and data that are missing at random. British Journal of Mathematical and Statistical Psychology, 75(1), 23–45.
Katsikatsou, M., Moustaki, I., Yang-Wallentin, F., & Jöreskog, K. G. (2012). Pairwise likelihood estimation for factor analysis models with ordinal data. Computational Statistics & Data Analysis, 56(12), 4243–4258.
Lee, S.-Y., & Jennrich, R. I. (1979). A study of algorithms for covariance structure analysis with specific comparisons using factor analysis. Psychometrika, 44(1), 99–113. https://doi.org/10.1007/BF02293789
Levenberg, K. (1944). A method for the solution of certain non-linear problems in least squares. Quarterly of Applied Mathematics, 2(2), 164–168. https://doi.org/10.1090/qam/10666
Marquardt, D. W. (1963). An algorithm for least-squares estimation of nonlinear parameters. Journal of the Society for Industrial and Applied Mathematics, 11(2), 431–441. https://doi.org/10.1137/0111030
McLachlan, G. J., & Krishnan, T. (2008). The EM algorithm and extensions (2nd ed.). Wiley.
Muthén, B. O. (1993). Goodness of fit with categorical and other non-normal variables. In K. A. Bollen & J. S. Long (Eds.), Testing structural equation models (pp. 205–243). Sage.
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., & Vidal, D. (2025). A tutorial for understanding SEM using R: Where do all the numbers come from? British Journal of Mathematical and Statistical Psychology. https://doi.org/10.1111/bmsp.70003
Rubin, D. B., & Thayer, D. T. (1982). EM algorithms for ML factor analysis. Psychometrika, 47(1), 69–76. https://doi.org/10.1007/BF02293851
Savalei, V., & Bentler, P. M. (2009). A two-stage approach to missing data: Theory and application to auxiliary variables. Structural Equation Modeling: A Multidisciplinary Journal, 16(3), 477–497. https://doi.org/10.1080/10705510903008238
Schamberger, T., Schuberth, F., Henseler, J., & Rosseel, Y. (2025). Factor- and composite-based structural equation modeling — a new approach to incorporate composites in the traditional SEM framework. arXiv Preprint. https://doi.org/10.48550/arXiv.2508.06112
Varadhan, R., & Roland, C. (2008). Simple and globally convergent methods for accelerating the convergence of any EM algorithm. Scandinavian Journal of Statistics, 35(2), 335–353. https://doi.org/10.1111/j.1467-9469.2007.00585.x
The first reason is that lavaan originally framed ML estimation as a special case of weighted least squares (called reweighted least squares). The second reason is that when computing the derivative of the ML discrepancy function, many terms gain a 2* multiplier, which can be avoided if the value of the ML discrepancy function is divided by two.↩︎