Appendix D — The multivariate normal distribution

$$

$$

This appendix collects results for the multivariate normal distribution that underlie the standard-error and test-statistic calculations in Section 8.1. Proofs are omitted; the reader is referred to Magnus and Neudecker (2019) for a comprehensive treatment.

D.1 The density function

A P-dimensional random vector \mathbf{y} follows a multivariate normal distribution with mean vector \boldsymbol{\mu} (P\times 1) and positive definite covariance matrix \boldsymbol{\Sigma} (P\times P), written \mathbf{y}\sim \mathcal{N}(\boldsymbol{\mu}, \boldsymbol{\Sigma}), if its probability density function is

p(\mathbf{y};\, \boldsymbol{\mu}, \boldsymbol{\Sigma}) = \frac{1}{(2\pi)^{P/2}\, |\boldsymbol{\Sigma}|^{1/2}} \exp\!\left\{-\frac{1}{2} (\mathbf{y}- \boldsymbol{\mu})^{\prime} \boldsymbol{\Sigma}^{-1}(\mathbf{y}- \boldsymbol{\mu}) \right\}. \tag{D.1}

The exponent (\mathbf{y}- \boldsymbol{\mu})^{\prime} \boldsymbol{\Sigma}^{-1}(\mathbf{y}- \boldsymbol{\mu}) is the squared Mahalanobis distance between \mathbf{y} and \boldsymbol{\mu}. The expectation and covariance of \mathbf{y} are \mathrm{E}[\mathbf{y}] = \boldsymbol{\mu} and \mathrm{Var}(\mathbf{y}) = \boldsymbol{\Sigma}.

D.2 Likelihood and log-likelihood

Given a random sample \mathcal{Y} = \{\mathbf{y}_1, \mathbf{y}_2, \ldots, \mathbf{y}_{N}\} of N independent observations from \mathcal{N}(\boldsymbol{\mu}, \boldsymbol{\Sigma}), the likelihood function is the product of the individual densities:

l(\boldsymbol{\mu}, \boldsymbol{\Sigma}\mid \mathcal{Y}) = \prod_{i=1}^{N} \frac{1}{(2\pi)^{P/2}\, |\boldsymbol{\Sigma}|^{1/2}} \exp\!\left\{-\frac{1}{2} (\mathbf{y}_i - \boldsymbol{\mu})^{\prime} \boldsymbol{\Sigma}^{-1}(\mathbf{y}_i - \boldsymbol{\mu}) \right\}.

Taking logarithms and collecting terms gives the log-likelihood:

\text{logl}(\boldsymbol{\mu}, \boldsymbol{\Sigma}\mid \mathcal{Y}) = -\frac{NP}{2}\ln(2\pi) - \frac{N}{2}\ln|\boldsymbol{\Sigma}| - \frac{1}{2} \sum_{i=1}^{N} (\mathbf{y}_i - \boldsymbol{\mu})^{\prime} \boldsymbol{\Sigma}^{-1}(\mathbf{y}_i - \boldsymbol{\mu}). \tag{D.2}

D.3 The quadratic form

It is useful to write the quadratic term in Equation D.2 in various equivalent ways, both in terms of raw data and in terms of sample statistics.

D.3.1 Using raw data

Denote the sum of squared Mahalanobis distances by

\Delta^2 = \sum_{i=1}^{N} (\mathbf{y}_i - \boldsymbol{\mu})^{\prime} \boldsymbol{\Sigma}^{-1}(\mathbf{y}_i - \boldsymbol{\mu}).

Because (\mathbf{y}_i - \boldsymbol{\mu})^{\prime}\boldsymbol{\Sigma}^{-1}(\mathbf{y}_i - \boldsymbol{\mu}) is a 1 \times 1 scalar it equals its own trace, and the cyclic property of the trace (see appendix B) gives

(\mathbf{y}_i - \boldsymbol{\mu})^{\prime} \boldsymbol{\Sigma}^{-1}(\mathbf{y}_i - \boldsymbol{\mu}) = \text{tr}\!\left[ \boldsymbol{\Sigma}^{-1}(\mathbf{y}_i - \boldsymbol{\mu})(\mathbf{y}_i - \boldsymbol{\mu})^{\prime} \right].

Summing over observations and pulling the constant \boldsymbol{\Sigma}^{-1} outside,

\Delta^2 = \text{tr}\!\left[ \boldsymbol{\Sigma}^{-1} \sum_{i=1}^{N} (\mathbf{y}_i - \boldsymbol{\mu})(\mathbf{y}_i - \boldsymbol{\mu})^{\prime} \right].

D.3.2 Using sample statistics

Let \bar{\mathbf{y}}= \frac{1}{N}\sum_{i=1}^{N}\mathbf{y}_i be the sample mean vector and \mathbf{S}= \frac{1}{N}\sum_{i=1}^{N} (\mathbf{y}_i - \bar{\mathbf{y}})(\mathbf{y}_i - \bar{\mathbf{y}})^{\prime} be the (maximum-likelihood) sample covariance matrix. Adding and subtracting \bar{\mathbf{y}} inside each term and expanding, the quadratic form separates into two parts:

\Delta^2 = N\, \text{tr}\!\left[\boldsymbol{\Sigma}^{-1}\mathbf{S}\right] + N\, (\bar{\mathbf{y}}- \boldsymbol{\mu})^{\prime} \boldsymbol{\Sigma}^{-1} (\bar{\mathbf{y}}- \boldsymbol{\mu}). \tag{D.3}

Defining the matrix

\mathbf{W} = \mathbf{S}+ (\bar{\mathbf{y}}- \boldsymbol{\mu})(\bar{\mathbf{y}}- \boldsymbol{\mu})^{\prime} = \frac{1}{N} \sum_{i=1}^{N} (\mathbf{y}_i - \boldsymbol{\mu})(\mathbf{y}_i - \boldsymbol{\mu})^{\prime}, \tag{D.4}

the quadratic form collapses to \Delta^2 = N\,\text{tr}[\boldsymbol{\Sigma}^{-1}\mathbf{W}], and the log-likelihood Equation D.2 becomes

\text{logl}(\boldsymbol{\mu}, \boldsymbol{\Sigma}\mid \mathcal{Y}) = c - \frac{N}{2}\ln|\boldsymbol{\Sigma}| - \frac{N}{2} \text{tr}\!\left[\boldsymbol{\Sigma}^{-1}\mathbf{S}\right] - \frac{N}{2} (\bar{\mathbf{y}}- \boldsymbol{\mu})^{\prime} \boldsymbol{\Sigma}^{-1} (\bar{\mathbf{y}}- \boldsymbol{\mu}), \tag{D.5}

where c = -\frac{NP}{2}\ln(2\pi) is a constant that does not depend on \boldsymbol{\mu} or \boldsymbol{\Sigma}. The parametric information in the data thus enters entirely through the three sufficient statistics \bar{\mathbf{y}}, \mathbf{S}, and N.

D.4 Derivatives of the log-likelihood

D.4.1 With respect to \boldsymbol{\mu}

Using the identity \partial\,(\mathbf{x} - \mathbf{a})^{\prime}\mathbf{A}(\mathbf{x}-\mathbf{a})/\partial \mathbf{a} = -2\mathbf{A}(\mathbf{x}-\mathbf{a}) (with \mathbf{A} = \boldsymbol{\Sigma}^{-1} symmetric), the gradient of the log-likelihood with respect to \boldsymbol{\mu} is

\frac{\partial \text{logl}(\boldsymbol{\mu}, \boldsymbol{\Sigma}\mid \mathcal{Y})} {\partial \boldsymbol{\mu}} = N\, \boldsymbol{\Sigma}^{-1}(\bar{\mathbf{y}}- \boldsymbol{\mu}). \tag{D.6}

Setting this to zero gives the maximum likelihood estimate \hat{\boldsymbol{\mu}} = \bar{\mathbf{y}}.

The casewise score with respect to \boldsymbol{\mu} is the gradient of the log-likelihood for a single observation i:

l_i(\boldsymbol{\mu}\mid \mathbf{y}_i) = \frac{\partial \text{logl}(\boldsymbol{\mu}, \boldsymbol{\Sigma}\mid \mathbf{y}_i)}{\partial \boldsymbol{\mu}} = \boldsymbol{\Sigma}^{-1}(\mathbf{y}_i - \boldsymbol{\mu}). \tag{D.7}

The full gradient equals the sum of casewise scores: \partial \text{logl}/ \partial \boldsymbol{\mu} = \sum_{i=1}^{N} l_i(\boldsymbol{\mu}\mid \mathbf{y}_i) = N\,\boldsymbol{\Sigma}^{-1}(\bar{\mathbf{y}}- \boldsymbol{\mu}).

D.4.2 With respect to \boldsymbol{\Sigma}

Using the matrix derivative rules \partial \ln|\mathbf{X}|/\partial \mathbf{X} = (\mathbf{X}^{-1})^{\prime} and \partial\,\text{tr}[\mathbf{X}^{-1}\mathbf{C}]/\partial \mathbf{X} = -(\mathbf{X}^{-1}\mathbf{C}\mathbf{X}^{-1})^{\prime}, and treating \boldsymbol{\Sigma} as an unconstrained matrix (symmetry is accounted for below), the derivative of Equation D.5 with respect to \boldsymbol{\Sigma} is

\frac{\partial \text{logl}(\boldsymbol{\mu}, \boldsymbol{\Sigma}\mid \mathcal{Y})} {\partial \boldsymbol{\Sigma}} = \frac{N}{2}\boldsymbol{\Sigma}^{-1}(\mathbf{W} - \boldsymbol{\Sigma})\boldsymbol{\Sigma}^{-1}, \tag{D.8}

where \mathbf{W} is defined in Equation D.4. Setting this to zero gives \mathbf{W} = \boldsymbol{\Sigma}; when \boldsymbol{\mu} is also at its ML value \bar{\mathbf{y}}, we have \mathbf{W} = \mathbf{S} and hence \hat{\boldsymbol{\Sigma}} = \mathbf{S}.

Accounting for the symmetry of \boldsymbol{\Sigma} by reparametrizing through \text{vech}(\boldsymbol{\Sigma}), the gradient with respect to the free elements is

\frac{\partial \text{logl}(\boldsymbol{\mu}, \boldsymbol{\Sigma}\mid \mathcal{Y})} {\partial\,(\text{vech}\,\boldsymbol{\Sigma})^{\prime}} = \frac{N}{2} \mathbf{D}^{\prime}(\boldsymbol{\Sigma}^{-1}\otimes \boldsymbol{\Sigma}^{-1}) \mathbf{D}\,\text{vech}(\mathbf{W} - \boldsymbol{\Sigma}), \tag{D.9}

where \mathbf{D} is the P^2 \times P(P+1)/2 duplication matrix (see appendix B). The casewise score with respect to \text{vech}(\boldsymbol{\Sigma}) for observation i is

l_i(\text{vech}\,\boldsymbol{\Sigma}\mid \mathbf{y}_i) = \frac{1}{2} \mathbf{D}^{\prime}(\boldsymbol{\Sigma}^{-1}\otimes \boldsymbol{\Sigma}^{-1}) \mathbf{D}\,\text{vech}\!\left[ (\mathbf{y}_i - \boldsymbol{\mu})(\mathbf{y}_i - \boldsymbol{\mu})^{\prime} - \boldsymbol{\Sigma} \right]. \tag{D.10}

D.4.3 The combined score vector

Stacking the two sets of parameters into \boldsymbol{\beta} = \bigl[\boldsymbol{\mu}^{\prime},\;(\text{vech}\,\boldsymbol{\Sigma})^{\prime}\bigr]^{\prime}, a vector of length P^{\star} = P+ P(P+1)/2, the gradient of the log-likelihood with respect to \boldsymbol{\beta} can be written compactly as

\frac{\partial \text{logl}(\boldsymbol{\mu}, \boldsymbol{\Sigma}\mid \mathcal{Y})} {\partial \boldsymbol{\beta}} = N \underbrace{ \begin{pmatrix} \boldsymbol{\Sigma}^{-1}& \mathbf{0} \\[2pt] \mathbf{0}^{\prime} & \frac{1}{2}\mathbf{D}^{\prime}(\boldsymbol{\Sigma}^{-1}\otimes \boldsymbol{\Sigma}^{-1})\mathbf{D} \end{pmatrix} }_{\mathcal{I}_1} \begin{pmatrix} \bar{\mathbf{y}}- \boldsymbol{\mu}\\[2pt] \text{vech}(\mathbf{W} - \boldsymbol{\Sigma}) \end{pmatrix}. \tag{D.11}

(The block-diagonal matrix in Equation D.11 is the unit expected information matrix \mathcal{I}_1, derived in Section D.6.1 below.) The corresponding casewise score for observation i is

\mathbf{g}_i(\boldsymbol{\beta}) \equiv l_i(\boldsymbol{\beta} \mid \mathbf{y}_i) = \begin{pmatrix} \boldsymbol{\Sigma}^{-1}& \mathbf{0} \\[2pt] \mathbf{0}^{\prime} & \frac{1}{2}\mathbf{D}^{\prime}(\boldsymbol{\Sigma}^{-1}\otimes \boldsymbol{\Sigma}^{-1})\mathbf{D} \end{pmatrix} \begin{pmatrix} \mathbf{y}_i - \boldsymbol{\mu}\\[2pt] \text{vech}\!\left[ (\mathbf{y}_i - \boldsymbol{\mu})(\mathbf{y}_i - \boldsymbol{\mu})^{\prime} - \boldsymbol{\Sigma} \right] \end{pmatrix}. \tag{D.12}

The total gradient satisfies \partial\text{logl}/\partial\boldsymbol{\beta} = \sum_{i=1}^{N} \mathbf{g}_i(\boldsymbol{\beta}).

D.5 The Hessian

The matrix of second-order partial derivatives of the log-likelihood with respect to \boldsymbol{\beta} is the Hessian. For the multivariate normal log-likelihood it takes the block form

H_{N} = -N \begin{bmatrix} \boldsymbol{\Sigma}^{-1}& \bigl[(\bar{\mathbf{y}}- \boldsymbol{\mu})^{\prime}\boldsymbol{\Sigma}^{-1} \otimes \boldsymbol{\Sigma}^{-1}\bigr]\mathbf{D}\\[6pt] \mathbf{D}^{\prime}\bigl[\boldsymbol{\Sigma}^{-1}(\bar{\mathbf{y}}- \boldsymbol{\mu}) \otimes \boldsymbol{\Sigma}^{-1}\bigr] & \tfrac{1}{2}\mathbf{D}^{\prime} (\boldsymbol{\Sigma}^{-1}\otimes \mathbf{A})\mathbf{D} \end{bmatrix}, \tag{D.13}

where

\mathbf{A} = \boldsymbol{\Sigma}^{-1}(2\mathbf{W} - \boldsymbol{\Sigma})\boldsymbol{\Sigma}^{-1}.

(A proof can be found in Magnus and Neudecker (2019), p. 319.) Note that the off-diagonal blocks of H_{N} involve (\bar{\mathbf{y}}- \boldsymbol{\mu}): they vanish when \boldsymbol{\mu} is at its ML value \bar{\mathbf{y}}, and H_{N} becomes block-diagonal.

D.6 Information matrices

The three information quantities used in Section 8.2 are defined as unit quantities (i.e., per observation). Here we give their explicit forms under the multivariate normal for the parameter vector \boldsymbol{\beta} = [\boldsymbol{\mu}^{\prime}, (\text{vech}\,\boldsymbol{\Sigma})^{\prime}]^{\prime}.

D.6.1 The unit expected information matrix

The unit expected information matrix is the negative expected Hessian per observation:

\mathcal{I}_1 = -\frac{1}{N} \mathrm{E}\!\left[H_{N}\right] = \begin{pmatrix} \boldsymbol{\Sigma}^{-1}& \mathbf{0} \\[4pt] \mathbf{0}^{\prime} & \frac{1}{2}\mathbf{D}^{\prime}(\boldsymbol{\Sigma}^{-1}\otimes \boldsymbol{\Sigma}^{-1})\mathbf{D} \end{pmatrix}. \tag{D.14}

The off-diagonal blocks vanish because \mathrm{E}[\bar{\mathbf{y}}- \boldsymbol{\mu}] = \mathbf{0} and \mathrm{E}[\mathbf{W} - \boldsymbol{\Sigma}] = \mathbf{0}. The inverse of \mathcal{I}_1 has the convenient closed form

\mathcal{I}_1^{-1} = \begin{pmatrix} \boldsymbol{\Sigma}& \mathbf{0} \\[4pt] \mathbf{0}^{\prime} & 2\mathbf{D}^{+}(\boldsymbol{\Sigma}\otimes \boldsymbol{\Sigma})\mathbf{D}^{+\prime} \end{pmatrix}, \tag{D.15}

where \mathbf{D}^{+} = (\mathbf{D}^{\prime}\mathbf{D})^{-1}\mathbf{D}^{\prime} is the Moore–Penrose generalized inverse of the duplication matrix (see appendix B).

D.6.2 The unit observed information matrix

The unit observed information matrix is minus the Hessian divided by N, evaluated at the parameter estimates:

I_1 = -\frac{1}{N} H_{N} = \begin{bmatrix} \boldsymbol{\Sigma}^{-1}& \bigl[(\bar{\mathbf{y}}- \boldsymbol{\mu})^{\prime}\boldsymbol{\Sigma}^{-1} \otimes \boldsymbol{\Sigma}^{-1}\bigr]\mathbf{D}\\[6pt] \mathbf{D}^{\prime}\bigl[\boldsymbol{\Sigma}^{-1}(\bar{\mathbf{y}}- \boldsymbol{\mu}) \otimes \boldsymbol{\Sigma}^{-1}\bigr] & \tfrac{1}{2}\mathbf{D}^{\prime} (\boldsymbol{\Sigma}^{-1}\otimes \mathbf{A})\mathbf{D} \end{bmatrix}. \tag{D.16}

When \boldsymbol{\mu} is replaced by its ML estimate \bar{\mathbf{y}}, the off-diagonal blocks vanish and \mathbf{A} = \boldsymbol{\Sigma}^{-1}(2\mathbf{S}- \boldsymbol{\Sigma})\boldsymbol{\Sigma}^{-1}; if additionally \boldsymbol{\Sigma}= \mathbf{S} then \mathbf{A} = \boldsymbol{\Sigma}^{-1} and I_1 = \mathcal{I}_1.

D.6.3 The unit first-order information matrix

The unit first-order information matrix (also called the outer-product-of-scores matrix) is the average outer product of the casewise score vectors Equation D.12:

\mathbb{I}_1 = \frac{1}{N} \sum_{i=1}^{N} \mathbf{g}_i(\boldsymbol{\beta})\, \mathbf{g}_i(\boldsymbol{\beta})^{\prime}. \tag{D.17}

Substituting the casewise scores gives

\mathbb{I}_1 = \mathcal{I}_1\, \boldsymbol{\Gamma}^{\mathrm{MOD}}\, \mathcal{I}_1,

where \boldsymbol{\Gamma}^{\mathrm{MOD}} is the sample covariance matrix of the vectors \bigl[(\mathbf{y}_i - \boldsymbol{\mu})^{\prime},\; \text{vech}[(\mathbf{y}_i - \boldsymbol{\mu})(\mathbf{y}_i - \boldsymbol{\mu})^{\prime} - \boldsymbol{\Sigma}]^{\prime}\bigr]^{\prime}. Under multivariate normality, \mathrm{E}[\boldsymbol{\Gamma}^{\mathrm{MOD}}] = \mathcal{I}_1^{-1}, so in expectation \mathbb{I}_1 = \mathcal{I}_1: the three unit information matrices agree when the model is correctly specified.

D.6.4 Evaluation at the unrestricted model

When \boldsymbol{\mu} and \boldsymbol{\Sigma} are replaced by their unrestricted ML estimates \bar{\mathbf{y}} and \mathbf{S} (the so-called \mathsf{H}_1 model), the expected and the observed unit information matrices reduce to the same quantity:

\mathcal{I}_1\big|_{\bar{\mathbf{y}},\,\mathbf{S}} = I_1\big|_{\bar{\mathbf{y}},\,\mathbf{S}} = \begin{pmatrix} \mathbf{S}^{-1}& \mathbf{0} \\[4pt] \mathbf{0} & \frac{1}{2}\mathbf{D}^{\prime} (\mathbf{S}^{-1}\otimes \mathbf{S}^{-1})\mathbf{D} \end{pmatrix} = \bigl[\boldsymbol{\Gamma}^{\mathrm{NT}}\bigr]^{-1}, \tag{D.18}

where \boldsymbol{\Gamma}^{\mathrm{NT}} is the asymptotic covariance matrix of the sample statistics (\bar{\mathbf{y}}, \text{vech}(\mathbf{S})) under normality. It has the same block structure as Equation D.15, with \boldsymbol{\Sigma} replaced by \mathbf{S}:

\bigl[\boldsymbol{\Gamma}^{\mathrm{NT}}\bigr] = \begin{pmatrix} \mathbf{S}& \mathbf{0} \\[4pt] \mathbf{0}^{\prime} & 2\mathbf{D}^{+}(\mathbf{S}\otimes \mathbf{S})\mathbf{D}^{+\prime} \end{pmatrix}.

The quantity \boldsymbol{\Gamma}^{\mathrm{NT}} (or N times its unit version) plays a central role in the construction of test statistics for model fit; it represents the variability of the sample statistics under normality against which the model is assessed.

D.7 The asymptotic covariance matrix of the sample moments

Throughout the book, \boldsymbol{\Gamma} denotes the asymptotic covariance matrix of the vector of sample moments \mathbf{s}, scaled by the sample size: \boldsymbol{\Gamma}= N\cdot \mathrm{ACOV}(\mathbf{s}), with \mathbf{s}= (\bar{\mathbf{y}}, \text{vech}\,\mathbf{S}) when a mean structure is present and \mathbf{s}= \text{vech}\, \mathbf{S} otherwise. The estimators of \boldsymbol{\Gamma} are introduced in Section 5.6.2 and collected in Table 8.2. This section connects them to the information matrices of Section D.6, gives the finite-sample corrections that lavaan offers, and points to the settings in which \boldsymbol{\Gamma} takes a different form.

D.7.1 The normal-theory form

At the unrestricted model, the ML estimates of (\boldsymbol{\mu}, \boldsymbol{\Sigma}) are the sample moments themselves, and their asymptotic covariance matrix is the inverse of the unit expected information. By Equation D.18,

\boldsymbol{\Gamma}^{\mathrm{NT}} = \mathcal{I}_1^{-1} = \begin{pmatrix} \boldsymbol{\Sigma}& \mathbf{0} \\[4pt] \mathbf{0}^{\prime} & 2\mathbf{D}^{+}(\boldsymbol{\Sigma}\otimes \boldsymbol{\Sigma})\mathbf{D}^{+\prime} \end{pmatrix}, \tag{D.19}

estimated by substituting \mathbf{S} for \boldsymbol{\Sigma}. The lower-right block is the covariance matrix of \sqrt{N}\,\text{vech}\,\mathbf{S} under normality, where the fourth-order moments reduce to products of second-order moments; the off-diagonal blocks vanish because the third-order central moments of a normal distribution are zero, so that the sample mean and the sample covariance matrix are asymptotically independent.

D.7.2 The distribution-free estimator and the sandwich identity

Without a distributional assumption, \boldsymbol{\Gamma} is estimated by the sample covariance matrix of the casewise moment contributions (Equation 8.16),

\hat{\boldsymbol{\Gamma}} = \frac{1}{N}\sum_{i=1}^{N} (\mathbf{v}_i - \bar{\mathbf{v}})(\mathbf{v}_i - \bar{\mathbf{v}})^{\prime}, \qquad \mathbf{v}_i = \begin{pmatrix} \mathbf{y}_i \\ \text{vech}\!\left[(\mathbf{y}_i - \bar{\mathbf{y}})(\mathbf{y}_i - \bar{\mathbf{y}})^{\prime}\right] \end{pmatrix}, \tag{D.20}

where \bar{\mathbf{v}} = \mathbf{s} exactly, because the contributions average to the sample moments. This estimator is related to the information matrices by an identity that holds in every finite sample, not only asymptotically. Evaluate the casewise score Equation D.12 at the unrestricted estimates \boldsymbol{\mu}= \bar{\mathbf{y}} and \boldsymbol{\Sigma}= \mathbf{S}. The vector it multiplies is then exactly \mathbf{v}_i - \mathbf{s}, so that

\mathbf{g}_i(\mathbf{s}) = \mathcal{I}_1\, (\mathbf{v}_i - \mathbf{s}), \qquad\text{hence}\qquad \mathbb{I}_1 = \frac{1}{N}\sum_{i} \mathbf{g}_i \mathbf{g}_i^{\prime} = \mathcal{I}_1\, \hat{\boldsymbol{\Gamma}}\, \mathcal{I}_1,

and therefore

\hat{\boldsymbol{\Gamma}} = \mathcal{I}_1^{-1}\, \mathbb{I}_1\, \mathcal{I}_1^{-1}, \tag{D.21}

with both information matrices evaluated at the sample moments. Two consequences follow. First, lavaan has two computational routes to the same matrix: the direct crossproduct Equation D.20, used for complete single-level data because it is fast, and the sandwich Equation D.21, used whenever the casewise contributions are not independent and identically distributed moment vectors (sampling weights, incomplete data, two-level data), because the sandwich only requires an information matrix and casewise scores. Second, under normality \mathrm{E}[\mathbb{I}_1] = \mathcal{I}_1, so that \hat{\boldsymbol{\Gamma}} converges to \boldsymbol{\Gamma}^{\mathrm{NT}}; in a finite sample the two differ by the sampling variability of the third- and fourth-order moments, which is why \hat{\boldsymbol{\Gamma}} needs large samples. The identity can be verified numerically; the implementation notes (Section D.11) show the check with the internal routines.

D.7.3 Model-based versions

The same construction can be carried out at an arbitrary point (\boldsymbol{\mu}, \boldsymbol{\Sigma}) instead of the sample moments, typically at the model-implied moments of a fitted model. With \boldsymbol{\beta} = (\boldsymbol{\mu}, \text{vech}\,\boldsymbol{\Sigma}) as before, and with \mathbf{v}_i(\boldsymbol{\mu}) = (\mathbf{y}_i, \text{vech}[(\mathbf{y}_i - \boldsymbol{\mu})(\mathbf{y}_i - \boldsymbol{\mu})^{\prime}]) the vector \mathbf{v}_i of Equation D.20 in which \bar{\mathbf{y}} is replaced by \boldsymbol{\mu},

\boldsymbol{\Gamma}^{\mathrm{MOD}}(\boldsymbol{\mu}, \boldsymbol{\Sigma}) = \frac{1}{N}\sum_{i=1}^{N} (\mathbf{v}_i(\boldsymbol{\mu}) - \boldsymbol{\beta})(\mathbf{v}_i(\boldsymbol{\mu}) - \boldsymbol{\beta})^{\prime}, \tag{D.22}

which is the matrix appearing in Section D.6.3. The identity \mathbb{I}_1(\boldsymbol{\mu}, \boldsymbol{\Sigma}) = \mathcal{I}_1(\boldsymbol{\Sigma})\,\boldsymbol{\Gamma}^{\mathrm{MOD}}\, \mathcal{I}_1(\boldsymbol{\Sigma}) holds at every (\boldsymbol{\mu}, \boldsymbol{\Sigma}), so Equation D.22 coincides with the triple-product form Equation 8.19 when the expected information is used as the outer factor, and reduces to Equation D.20 at the sample moments. Its normal-theory counterpart is \boldsymbol{\Gamma}^{\mathrm{MOD,NT}}(\boldsymbol{\Sigma}) = \mathcal{I}_1(\boldsymbol{\Sigma})^{-1}, which is Equation 8.20. Both are evaluated at the model-implied moments and are used by the model-based test statistics of Section 8.5.3.

D.7.4 Finite-sample corrections

Three options modify the plain estimator Equation D.20.

  • gamma_n_minus_one = TRUE divides the crossproduct by N- 1 instead of N. Both conventions appear in the literature; the difference is immaterial asymptotically but affects the comparison with other software.

  • gamma_unbiased = TRUE replaces the covariance block of \hat{\boldsymbol{\Gamma}} by the unbiased estimator of Browne (1984). Writing \hat{\boldsymbol{\Gamma}}_{22} for the covariance block of Equation D.20, \hat{\boldsymbol{\Gamma}}^{\mathrm{NT}}_{22} for that of Equation D.19 (with \mathbf{S} substituted), and \mathbf{s}_2 = \text{vech}\,\mathbf{S}, \hat{\boldsymbol{\Gamma}}^{U}_{22} = \frac{N(N-1)}{(N-2)(N-3)}\, \hat{\boldsymbol{\Gamma}}_{22} - \frac{N}{(N-2)(N-3)} \left(\hat{\boldsymbol{\Gamma}}^{\mathrm{NT}}_{22} - \frac{2}{N-1}\,\mathbf{s}_2\mathbf{s}_2^{\prime}\right). \tag{D.23} When a mean structure is present, the mean block is \mathbf{S} and the cross block of Equation D.20 is multiplied by N/(N-2). The option is only available in the plain setting (no fixed_x, conditional_x, clustering, or model-based evaluation), and is used by the unbiased variants of the regularized test statistics of Section 8.5.3.

  • gamma_wls_mplus = TRUE (only for the (D)WLS family with continuous data) reproduces the convention of Mplus: with \mathbf{s}_u = \text{vech} of the unbiased sample covariance matrix and \mathbf{s}_b = \frac{N-1}{N}\mathbf{s}_u, the covariance block becomes \hat{\boldsymbol{\Gamma}}_{22} - (\mathbf{s}_u\mathbf{s}_u^{\prime} - \mathbf{s}_b\mathbf{s}_b^{\prime}), and the cross block is multiplied by (N-1)/N.

D.7.5 Sampling weights and clustering

With sampling weights w_i, lavaan uses the sandwich route: \hat{\boldsymbol{\Gamma}} = \mathcal{I}_{1,w}^{-1}\, \mathbb{I}_{1,w}\,\mathcal{I}_{1,w}^{-1}, where the expected information is evaluated at the weighted sample moments, and the first-order term is a weighted crossproduct of the unweighted casewise scores, divided by \sum_i w_i. Under the current default sampling_weights_type = "design", each score is multiplied by w_i before the crossproduct is taken (so that the result is invariant to the scale of the weights); under "frequency", by \sqrt{w_i}, which treats the weights as case multiplicities. Under normality the sandwich collapses to the weighted normal-theory form.

When the cases are clustered but no level structure is modeled (cluster= without level: blocks), the casewise contributions are first summed within clusters, and the crossproduct of the cluster sums is multiplied by N_J/(N_J-1), with N_J the number of clusters. This is the cluster-corrected estimator Equation 8.23.

D.7.6 Other settings

The remaining variants are derived where the corresponding setting is introduced:

  • fixed_x = TRUE: the rows and columns of the covariate moments are masked, and the inverse of the masked information is used, as described in Section 5.6.2;

  • conditional_x = TRUE: the moment vector is (\text{vec}\,\hat{\mathbf{B}}, \text{vech}\,\mathbf{S}_{y|x}) and \boldsymbol{\Gamma} takes the residual form Equation D.40 (normal theory) or its distribution-free analogue (Section 5.6.4); the incomplete-data case is treated in Section D.10;

  • correlation structures: the delta method Equation 5.1 transforms any of the above;

  • incomplete data: the sandwich for the unrestricted FIML estimates Equation D.51, with the observed information as bread;

  • two-level data: the same sandwich, with the two-level \mathsf{H}_1 information matrices of Section 16.8.1 and one score per cluster;

  • ordered categorical data: the asymptotic covariance matrix of the stage-wise estimates, Equation 14.7, derived in Section 14.4.3.

D.8 Conditional approach (continuous covariates)

In the conditional approach, the model specifies the distribution of the P-dimensional response vector \mathbf{y} given a Q-dimensional vector \mathbf{x} of observed exogenous covariates, rather than the joint distribution of (\mathbf{y}, \mathbf{x}). Conditional on \mathbf{x}, the responses follow a multivariate linear regression with normal residuals:

\mathbf{y}_i \mid \mathbf{x}_i \sim \mathcal{N}\!\bigl(\boldsymbol{\gamma}+ \boldsymbol{\Pi}\mathbf{x}_i,\, \boldsymbol{\Sigma}_{y|x}\bigr), \qquad i = 1, \ldots, N. \tag{D.24}

The vectors \mathbf{y}_1, \ldots, \mathbf{y}_{N} are independent given the covariates. Throughout this section, all data are assumed complete (no missing values); the FIML extension is treated separately in Section D.9. The pattern of results parallels the complete-data joint sections, with the conditional mean \boldsymbol{\gamma}+ \boldsymbol{\Pi}\mathbf{x}_i playing the role of \boldsymbol{\mu} and the residual covariance \boldsymbol{\Sigma}_{y|x} that of \boldsymbol{\Sigma}.

In what follows, P refers to the dimension of the response vector \mathbf{y} (the number of outcomes), and Q to the dimension of the covariate vector \mathbf{x}. Outside of this section, P retains its usual meaning of the total number of variables in the (joint) analysis.

D.8.1 Model and notation

The model can be written compactly in matrix form. Stack the responses and covariates rowwise: \mathbf{Y} = (\mathbf{y}_1, \ldots, \mathbf{y}_{N})^{\prime} (N\times P) and \mathbf{X} = (\mathbf{x}_1, \ldots, \mathbf{x}_{N})^{\prime} (N\times Q). Adjoining a leading column of ones for the intercept yields the augmented design matrix

\mathbf{X}_1 = (\mathbf{1}, \mathbf{X}), \qquad N\times (Q+ 1).

Collect the conditional intercept \boldsymbol{\gamma} (P\times 1) and the conditional slopes \boldsymbol{\Pi} (P\times Q) into a single (Q+ 1) \times P matrix

\mathbf{B} = \begin{pmatrix} \boldsymbol{\gamma}^{\prime} \\ \boldsymbol{\Pi}^{\prime} \end{pmatrix}, \tag{D.25}

so that the conditional mean of case i is \boldsymbol{\gamma}+ \boldsymbol{\Pi}\mathbf{x}_i = \mathbf{B}^{\prime}\mathbf{x}_{1,i}, where \mathbf{x}_{1,i} = (1, \mathbf{x}_i^{\prime})^{\prime}. The conditional model then reads \mathbf{Y} = \mathbf{X}_1 \mathbf{B} + \mathbf{E}, with the rows of \mathbf{E} independently \mathcal{N}(\mathbf{0}, \boldsymbol{\Sigma}_{y|x}). This is exactly the parameterization used internally: the first row of \mathbf{B} holds the intercepts and the remaining rows the transposed slopes (see the implementation notes, Section D.11).

It is convenient to define, alongside the population \mathbf{B} and \boldsymbol{\Sigma}_{y|x}, the corresponding sample (OLS / ML) quantities

\hat{\mathbf{B}} = (\mathbf{X}_1^{\prime}\mathbf{X}_1)^{-1}\mathbf{X}_1^{\prime}\mathbf{Y}, \qquad \mathbf{S}_{y|x} = \frac{1}{N} (\mathbf{Y} - \mathbf{X}_1\hat{\mathbf{B}})^{\prime} (\mathbf{Y} - \mathbf{X}_1\hat{\mathbf{B}}), \tag{D.26}

i.e., the columnwise OLS regression coefficients and the (ML) residual sample covariance matrix. The (Q+1) \times (Q+1) Gram matrix of the covariates,

\frac{1}{N}\mathbf{X}_1^{\prime}\mathbf{X}_1 = \begin{pmatrix} 1 & \bar{\mathbf{x}}^{\prime} \\ \bar{\mathbf{x}}& \mathbf{S}_x+ \bar{\mathbf{x}}\bar{\mathbf{x}}^{\prime} \end{pmatrix}, \tag{D.27}

is fully recovered from the sample mean \bar{\mathbf{x}} and the (ML) sample covariance \mathbf{S}_x of the covariates, plus N. Together, the quintuple (\hat{\mathbf{B}}, \mathbf{S}_{y|x}, \bar{\mathbf{x}}, \mathbf{S}_x, N) constitutes the sufficient statistics for the conditional model.

The combined parameter vector is

\boldsymbol{\beta} = \bigl[ \mathrm{vec}(\mathbf{B})^{\prime},\, (\mathrm{vech}\,\boldsymbol{\Sigma}_{y|x})^{\prime} \bigr]^{\prime}, \tag{D.28}

of length P(Q+ 1) + P(P+ 1)/2. The ordering of \mathrm{vec}(\mathbf{B}) groups the parameters by outcome: intercept and slopes for y_1 first, then for y_2, and so on. (Below, the symbol \boldsymbol{\beta} denotes this stacked parameter vector and should not be confused with the regression coefficient matrix \mathbf{B}.)

D.8.2 Likelihood and log-likelihood

Conditional on \mathbf{X}, the joint density of the responses factorizes, giving the conditional log-likelihood

\text{logl}(\mathbf{B}, \boldsymbol{\Sigma}_{y|x} \mid \mathcal{Y}, \mathbf{X}) = -\frac{NP}{2}\ln(2\pi) - \frac{N}{2}\ln|\boldsymbol{\Sigma}_{y|x}| - \frac{1}{2} \mathrm{tr}\!\left[ (\mathbf{Y} - \mathbf{X}_1\mathbf{B}) \boldsymbol{\Sigma}_{y|x}^{-1} (\mathbf{Y} - \mathbf{X}_1\mathbf{B})^{\prime} \right]. \tag{D.29}

The trace term is the conditional analogue of the sum of Mahalanobis distances in Equation D.2 and is the form evaluated directly from the raw data. By adding and subtracting \mathbf{X}_1\hat{\mathbf{B}} inside each residual and expanding (the conditional analogue of the manipulation in Section D.3), the trace separates into two pieces:

\frac{1}{N} (\mathbf{Y} - \mathbf{X}_1\mathbf{B})^{\prime} (\mathbf{Y} - \mathbf{X}_1\mathbf{B}) = \mathbf{S}_{y|x} + (\hat{\mathbf{B}} - \mathbf{B})^{\prime} \frac{\mathbf{X}_1^{\prime}\mathbf{X}_1}{N} (\hat{\mathbf{B}} - \mathbf{B}) \;\equiv\; \widetilde{\mathbf{W}}, \tag{D.30}

which is the conditional analogue of the matrix \mathbf{W} in Equation D.4: when \mathbf{X}_1 = \mathbf{1} and \mathbf{B} collapses to \boldsymbol{\mu}^{\prime}, Equation D.30 reduces exactly to Equation D.4. The log-likelihood then takes the sample-statistics form

\text{logl} = c - \frac{N}{2}\ln|\boldsymbol{\Sigma}_{y|x}| - \frac{N}{2} \mathrm{tr}\!\left[\boldsymbol{\Sigma}_{y|x}^{-1}\mathbf{S}_{y|x}\right] - \frac{N}{2} \mathrm{tr}\!\left[ \boldsymbol{\Sigma}_{y|x}^{-1} (\hat{\mathbf{B}} - \mathbf{B})^{\prime} \frac{\mathbf{X}_1^{\prime}\mathbf{X}_1}{N} (\hat{\mathbf{B}} - \mathbf{B}) \right], \tag{D.31}

with constant c = -(NP/2)\ln(2\pi). In this form, the parametric information in the data enters only through the sufficient statistics \hat{\mathbf{B}}, \mathbf{S}_{y|x}, \bar{\mathbf{x}}, \mathbf{S}_x, and N.

D.8.3 Derivatives

Differentiating Equation D.29 with respect to \mathbf{B} (holding \boldsymbol{\Sigma}_{y|x} fixed) gives a matrix gradient analogous to Equation D.6:

\frac{\partial \text{logl}(\mathbf{B}, \boldsymbol{\Sigma}_{y|x} \mid \mathcal{Y}, \mathbf{X})} {\partial \mathbf{B}} = \mathbf{X}_1^{\prime}(\mathbf{Y} - \mathbf{X}_1\mathbf{B}) \boldsymbol{\Sigma}_{y|x}^{-1}. \tag{D.32}

Setting Equation D.32 to zero gives the closed-form ML estimate \hat{\mathbf{B}} = (\mathbf{X}_1^{\prime}\mathbf{X}_1)^{-1} \mathbf{X}_1^{\prime}\mathbf{Y}. Differentiating Equation D.29 with respect to \boldsymbol{\Sigma}_{y|x} (treated as unconstrained, with symmetry handled below) gives the conditional analogue of Equation D.8:

\frac{\partial \text{logl}}{\partial \boldsymbol{\Sigma}_{y|x}} = \frac{N}{2}\, \boldsymbol{\Sigma}_{y|x}^{-1} \bigl(\widetilde{\mathbf{W}} - \boldsymbol{\Sigma}_{y|x}\bigr) \boldsymbol{\Sigma}_{y|x}^{-1}. \tag{D.33}

Setting Equation D.33 to zero gives \widetilde{\mathbf{W}} = \boldsymbol{\Sigma}_{y|x}; combined with \mathbf{B} = \hat{\mathbf{B}} this yields \hat{\boldsymbol{\Sigma}}_{y|x} = \mathbf{S}_{y|x}. Unlike the joint case under FIML, the conditional ML estimates have a closed form: the OLS regression on \mathbf{X}_1 followed by the ML residual covariance.

The gradient with respect to \mathrm{vech}(\boldsymbol{\Sigma}_{y|x}) (the free elements of the symmetric matrix) is obtained by applying \mathbf{D}^{\prime} to the vec of Equation D.33, in analogy with Equation D.9.

The casewise score for case i, the building block of the first-order information matrix, generalizes Equation D.12:

\mathbf{g}_i(\boldsymbol{\beta}) = \begin{pmatrix} \boldsymbol{\Sigma}_{y|x}^{-1}\! \bigl(\mathbf{y}_i - \mathbf{B}^{\prime}\mathbf{x}_{1,i}\bigr) \otimes \mathbf{x}_{1,i} \\[6pt] \frac{1}{2}\mathbf{D}^{\prime}\! \bigl(\boldsymbol{\Sigma}_{y|x}^{-1} \otimes \boldsymbol{\Sigma}_{y|x}^{-1}\bigr)\mathbf{D}\, \mathrm{vech}\!\bigl[ (\mathbf{y}_i - \mathbf{B}^{\prime}\mathbf{x}_{1,i}) (\mathbf{y}_i - \mathbf{B}^{\prime}\mathbf{x}_{1,i})^{\prime} - \boldsymbol{\Sigma}_{y|x} \bigr] \end{pmatrix}. \tag{D.34}

The first block is the score for \mathrm{vec}(\mathbf{B}), the second block the score for \mathrm{vech}(\boldsymbol{\Sigma}_{y|x}). The total gradient satisfies \partial\text{logl}/\partial\boldsymbol{\beta} = \sum_{i=1}^{N} \mathbf{g}_i(\boldsymbol{\beta}).

D.8.4 The Hessian

Differentiating the score equations Equation D.32 and Equation D.33 a second time and collecting blocks yields the Hessian of the conditional log-likelihood:

H_{N} = -N \begin{bmatrix} \boldsymbol{\Sigma}_{y|x}^{-1} \otimes \dfrac{\mathbf{X}_1^{\prime}\mathbf{X}_1}{N} & \mathbf{H}_{12} \\[10pt] \mathbf{H}_{12}^{\prime} & \tfrac{1}{2}\mathbf{D}^{\prime} \bigl(\boldsymbol{\Sigma}_{y|x}^{-1} \otimes \mathbf{A}\bigr)\mathbf{D} \end{bmatrix}, \tag{D.35}

where, in analogy with Section D.5,

\mathbf{A} = \boldsymbol{\Sigma}_{y|x}^{-1} \bigl(2\widetilde{\mathbf{W}} - \boldsymbol{\Sigma}_{y|x}\bigr) \boldsymbol{\Sigma}_{y|x}^{-1},

and the off-diagonal block

\mathbf{H}_{12}^{\prime} = \mathbf{D}^{\prime} \biggl[ \boldsymbol{\Sigma}_{y|x}^{-1} \otimes \boldsymbol{\Sigma}_{y|x}^{-1} (\hat{\mathbf{B}} - \mathbf{B})^{\prime}\, \frac{\mathbf{X}_1^{\prime}\mathbf{X}_1}{N} \biggr]

is proportional to the OLS residual \hat{\mathbf{B}} - \mathbf{B} and vanishes whenever \mathbf{B} = \hat{\mathbf{B}}, in particular at the unrestricted (\mathsf{H}_1) ML estimates. With \mathbf{X}_1 = \mathbf{1} and \mathbf{B} \to \boldsymbol{\mu}^{\prime}, Equation D.35 reduces to Equation D.13. The Hessian Equation D.35 differs from the unit observed information matrix below by the factor -N.

D.8.5 Information matrices

The three unit information quantities for the conditional model follow the same definitions as in Section D.6, applied now to the parameter vector Equation D.28.

D.8.5.1 The unit expected information matrix

Taking the expectation of Equation D.35 removes the off-diagonal blocks because \mathrm{E}[\hat{\mathbf{B}} - \mathbf{B}] = \mathbf{0}, and substitutes \mathrm{E}[\widetilde{\mathbf{W}}] = \boldsymbol{\Sigma}_{y|x} in \mathbf{A} (so that \mathbf{A} \to \boldsymbol{\Sigma}_{y|x}^{-1}). The unit expected information matrix is therefore block-diagonal:

\mathcal{I}_1 = \begin{pmatrix} \boldsymbol{\Sigma}_{y|x}^{-1} \otimes \dfrac{\mathbf{X}_1^{\prime}\mathbf{X}_1}{N} & \mathbf{0} \\[10pt] \mathbf{0}^{\prime} & \frac{1}{2}\mathbf{D}^{\prime} \bigl(\boldsymbol{\Sigma}_{y|x}^{-1} \otimes \boldsymbol{\Sigma}_{y|x}^{-1}\bigr)\mathbf{D} \end{pmatrix}. \tag{D.36}

Its inverse has the convenient closed form

\mathcal{I}_1^{-1} = \begin{pmatrix} \boldsymbol{\Sigma}_{y|x} \otimes N(\mathbf{X}_1^{\prime}\mathbf{X}_1)^{-1} & \mathbf{0} \\[8pt] \mathbf{0}^{\prime} & 2\mathbf{D}^{+} \bigl(\boldsymbol{\Sigma}_{y|x} \otimes \boldsymbol{\Sigma}_{y|x}\bigr)\mathbf{D}^{+\prime} \end{pmatrix}. \tag{D.37}

D.8.5.2 The unit observed information matrix

The unit observed information matrix is -H_{N}/N evaluated at the parameter estimates, i.e.,

I_1 = -\frac{1}{N} H_{N}, \tag{D.38}

with H_{N} given in Equation D.35. It can be computed either from the raw data or from the sample statistics. At the unrestricted (\mathsf{H}_1) ML estimates the off-diagonal blocks vanish (because \mathbf{B} = \hat{\mathbf{B}}) and \mathbf{A} collapses to \boldsymbol{\Sigma}_{y|x}^{-1}; the observed information then equals the expected information.

D.8.5.3 The unit first-order information matrix

The unit first-order (outer-product-of-scores) information matrix is the average outer product of the casewise scores Equation D.34:

\mathbb{I}_1 = \frac{1}{N} \sum_{i=1}^{N} \mathbf{g}_i(\boldsymbol{\beta})\, \mathbf{g}_i(\boldsymbol{\beta})^{\prime}. \tag{D.39}

Equivalently, \mathbb{I}_1 = \mathbf{G}^{\prime}\mathbf{G}/ N with \mathbf{G} the N\times [P(Q+1) + P(P+1)/2] matrix of casewise scores.

D.8.5.4 Evaluation at the unrestricted model

When \mathbf{B} and \boldsymbol{\Sigma}_{y|x} are replaced by their unrestricted ML estimates \hat{\mathbf{B}} and \mathbf{S}_{y|x}, the expected and the observed unit information matrices coincide and reduce to Equation D.36 with \boldsymbol{\Sigma}_{y|x} replaced by \mathbf{S}_{y|x}. The inverse Equation D.37, evaluated at the sample moments, is the asymptotic covariance matrix of the unrestricted estimates (\mathrm{vec}\,\hat{\mathbf{B}}, \mathrm{vech}\,\mathbf{S}_{y|x}) under conditional normality:

\mathcal{I}_1^{-1}\big|_{\hat{\mathbf{B}},\,\mathbf{S}_{y|x}} = \begin{pmatrix} \mathbf{S}_{y|x}\otimes N(\mathbf{X}_1^{\prime}\mathbf{X}_1)^{-1} & \mathbf{0} \\[6pt] \mathbf{0}^{\prime} & 2\mathbf{D}^{+} \bigl(\mathbf{S}_{y|x}\otimes \mathbf{S}_{y|x}\bigr)\mathbf{D}^{+\prime} \end{pmatrix}. \tag{D.40}

This is the conditional (“residual”) counterpart of the joint normal-theory \boldsymbol{\Gamma}^{\mathrm{NT}} in Equation D.18, and plays the same role in the construction of test statistics for model fit when the analysis is conditional on the covariates.

D.9 Incomplete data (FIML)

The previous sections assumed that all P variables are observed for every case. When some entries of the data matrix are missing, full information maximum likelihood (FIML) bases inference on the marginal density of the observed entries for each case. Because any subvector of a multivariate normal vector is itself multivariate normal, with mean and covariance taken from the corresponding rows and columns of \boldsymbol{\mu} and \boldsymbol{\Sigma}, nearly all results of the previous sections carry over, with the sums-over-cases of the complete-data formulas replaced by sums-over-patterns of pattern analogues.

D.9.1 Missing-data patterns and notation

For each case i = 1, \ldots, N, let \mathcal{O}_i \subseteq \{1, \ldots, P\} denote the set of indices of the variables that are observed. Two cases share a missing-data pattern when their observed-variable index sets coincide. Cases with all variables missing carry no information about \boldsymbol{\mu} or \boldsymbol{\Sigma} and are dropped; N refers henceforth to the post-deletion sample size. Distinct patterns are indexed by r = 1, \ldots, R. For pattern r we write:

  • \mathcal{O}_r \subseteq \{1, \ldots, P\}: the indices of variables observed in this pattern, with P_r = |\mathcal{O}_r|;
  • n_r: the number of cases sharing this pattern, with \sum_{r=1}^{R} n_r = N;
  • \mathbf{T}_r (P_r \times P): the selection matrix obtained by retaining the rows of \mathbf{I}_{P} indexed by \mathcal{O}_r. For any P-vector \mathbf{a} and P\times P matrix \mathbf{A}, the operations \mathbf{T}_r \mathbf{a} and \mathbf{T}_r \mathbf{A} \mathbf{T}_r^{\prime} extract the entries observed in pattern r;
  • \mathbf{y}_i^{(r)} = \mathbf{T}_r \mathbf{y}_i, \boldsymbol{\mu}^{(r)} = \mathbf{T}_r \boldsymbol{\mu}, and \boldsymbol{\Sigma}^{(r)} = \mathbf{T}_r \boldsymbol{\Sigma}\mathbf{T}_r^{\prime}: the observed subvector for case i \in r and the corresponding subvector and submatrix of the population moments;
  • \bar{\mathbf{y}}^{(r)} = \frac{1}{n_r}\sum_{i \in r}\mathbf{y}_i^{(r)} and \mathbf{S}^{(r)} = \frac{1}{n_r}\sum_{i \in r} (\mathbf{y}_i^{(r)} - \bar{\mathbf{y}}^{(r)})(\mathbf{y}_i^{(r)} - \bar{\mathbf{y}}^{(r)})^{\prime}: the (ML) sample mean and covariance computed from the observed entries of the cases in pattern r.

The pattern-specific sample statistics \bar{\mathbf{y}}^{(r)}, \mathbf{S}^{(r)} and n_r are precomputed once and stored with the sample statistics. The pattern analogue of the matrix \mathbf{W} from Equation D.4 is

\mathbf{W}^{(r)} = \mathbf{S}^{(r)} + (\bar{\mathbf{y}}^{(r)} - \boldsymbol{\mu}^{(r)}) (\bar{\mathbf{y}}^{(r)} - \boldsymbol{\mu}^{(r)})^{\prime} = \frac{1}{n_r} \sum_{i \in r} (\mathbf{y}_i^{(r)} - \boldsymbol{\mu}^{(r)}) (\mathbf{y}_i^{(r)} - \boldsymbol{\mu}^{(r)})^{\prime}. \tag{D.41}

A practical remark: the pattern inverse \boldsymbol{\Sigma}^{(r)-1} = (\mathbf{T}_r \boldsymbol{\Sigma}\mathbf{T}_r^{\prime})^{-1} is not, in general, a submatrix of \boldsymbol{\Sigma}^{-1}. lavaan obtains it efficiently from \boldsymbol{\Sigma}^{-1}: the rows and columns corresponding to the missing variables in pattern r are removed by a symmetric inverse update.

D.9.2 The FIML log-likelihood

Under independence and multivariate normality, the log-likelihood of the incomplete data is the sum of the casewise log-likelihoods of the observed subvectors. Because cases sharing a pattern share \boldsymbol{\mu}^{(r)} and \boldsymbol{\Sigma}^{(r)}, the log-likelihood collapses to a sum of R terms, each of which has the form of the complete-data log-likelihood Equation D.5 applied to the observed entries of pattern r:

\text{logl}(\boldsymbol{\mu}, \boldsymbol{\Sigma}\mid \mathcal{Y}) = -\frac{1}{2} \sum_{r=1}^{R} n_r \Bigl\{ P_r \ln(2\pi) + \ln|\boldsymbol{\Sigma}^{(r)}| + \mathrm{tr}\!\left[\boldsymbol{\Sigma}^{(r)-1}\mathbf{W}^{(r)}\right] \Bigr\}. \tag{D.42}

In this pattern-based form, the pattern statistics \bar{\mathbf{y}}^{(r)}, \mathbf{S}^{(r)}, n_r are sufficient. Equivalently, working case by case, the casewise log-likelihood for case i in pattern r is

\ell_i(\boldsymbol{\mu}, \boldsymbol{\Sigma}\mid \mathbf{y}_i) = -\frac{1}{2}\Bigl\{ P_r \ln(2\pi) + \ln|\boldsymbol{\Sigma}^{(r)}| + (\mathbf{y}_i^{(r)} - \boldsymbol{\mu}^{(r)})^{\prime} \boldsymbol{\Sigma}^{(r)-1} (\mathbf{y}_i^{(r)} - \boldsymbol{\mu}^{(r)}) \Bigr\}, \tag{D.43}

and \text{logl}= \sum_{i=1}^{N} \ell_i. When every case is fully observed there is a single pattern r=1 with \mathbf{T}_1 = \mathbf{I}_{P} and n_1 = N, and Equation D.42 reduces to Equation D.5.

D.9.3 Score functions

Differentiating Equation D.42 pattern by pattern (each term has the form of Equation D.6 and Equation D.8 applied to the observed entries) gives the gradients with respect to \boldsymbol{\mu} and \boldsymbol{\Sigma}. The selection matrix \mathbf{T}_r embeds the pattern-level contributions back into P-dimensional space:

\frac{\partial \text{logl}(\boldsymbol{\mu}, \boldsymbol{\Sigma}\mid \mathcal{Y})} {\partial \boldsymbol{\mu}} = \sum_{r=1}^{R} n_r\, \mathbf{T}_r^{\prime} \boldsymbol{\Sigma}^{(r)-1} \bigl(\bar{\mathbf{y}}^{(r)} - \boldsymbol{\mu}^{(r)}\bigr), \tag{D.44}

\frac{\partial \text{logl}(\boldsymbol{\mu}, \boldsymbol{\Sigma}\mid \mathcal{Y})} {\partial \boldsymbol{\Sigma}} = \sum_{r=1}^{R} \frac{n_r}{2}\, \mathbf{T}_r^{\prime} \boldsymbol{\Sigma}^{(r)-1} \bigl(\mathbf{W}^{(r)} - \boldsymbol{\Sigma}^{(r)}\bigr) \boldsymbol{\Sigma}^{(r)-1}\, \mathbf{T}_r. \tag{D.45}

The gradient with respect to \text{vech}(\boldsymbol{\Sigma}) is obtained by applying \mathbf{D}^{\prime} to the vec of Equation D.45.

The casewise score for case i in pattern r, the building block of the first-order information matrix, generalizes Equation D.12 directly. Stacking the score for \boldsymbol{\mu} on top of the score for \text{vech}(\boldsymbol{\Sigma}) and embedding through \mathbf{T}_r,

\mathbf{g}_i(\boldsymbol{\beta}) = \begin{pmatrix} \mathbf{T}_r^{\prime}\, \boldsymbol{\Sigma}^{(r)-1}\bigl(\mathbf{y}_i^{(r)} - \boldsymbol{\mu}^{(r)}\bigr) \\[6pt] \frac{1}{2}\mathbf{D}^{\prime} (\mathbf{T}_r^{\prime}\!\otimes\!\mathbf{T}_r^{\prime}) \mathrm{vec}\!\left[ \boldsymbol{\Sigma}^{(r)-1}\! \bigl\{(\mathbf{y}_i^{(r)} - \boldsymbol{\mu}^{(r)})(\mathbf{y}_i^{(r)} - \boldsymbol{\mu}^{(r)})^{\prime} - \boldsymbol{\Sigma}^{(r)}\bigr\}\! \boldsymbol{\Sigma}^{(r)-1} \right] \end{pmatrix}. \tag{D.46}

In implementation terms, the entries of \mathbf{g}_i(\boldsymbol{\beta}) corresponding to variables that are missing for case i are zero. The total gradient is the sum \partial\text{logl}/\partial\boldsymbol{\beta} = \sum_{i=1}^{N} \mathbf{g}_i(\boldsymbol{\beta}).

Setting Equation D.44 and Equation D.45 to zero yields a system that generally has no closed-form solution, because each pattern contributes its own submatrices of \boldsymbol{\mu} and \boldsymbol{\Sigma}. The system is solved iteratively, either by EM (Section D.9.7) or by direct numerical maximization.

D.9.4 The Hessian

Differentiating Equation D.44 and Equation D.45 a second time and summing across patterns yields the Hessian of the FIML log-likelihood. As in the complete-data case (Equation D.13) it has block structure:

H_{N}^{\text{FIML}} = -\sum_{r=1}^{R} n_r \begin{bmatrix} \mathbf{H}_{11}^{(r)} & \mathbf{H}_{12}^{(r)} \\[4pt] \mathbf{H}_{12}^{(r)\prime} & \mathbf{H}_{22}^{(r)} \end{bmatrix}, \tag{D.47}

where, in analogy with Section D.5, the pattern blocks are

\begin{aligned} \mathbf{H}_{11}^{(r)} &= \mathbf{T}_r^{\prime}\,\boldsymbol{\Sigma}^{(r)-1}\,\mathbf{T}_r, \\[4pt] \mathbf{H}_{12}^{(r)} &= \mathbf{T}_r^{\prime} \bigl[(\bar{\mathbf{y}}^{(r)} - \boldsymbol{\mu}^{(r)})^{\prime}\,\boldsymbol{\Sigma}^{(r)-1} \otimes \boldsymbol{\Sigma}^{(r)-1}\bigr]\, (\mathbf{T}_r \otimes \mathbf{T}_r)\,\mathbf{D}, \\[4pt] \mathbf{H}_{22}^{(r)} &= \tfrac{1}{2}\,\mathbf{D}^{\prime}\, (\mathbf{T}_r^{\prime} \otimes \mathbf{T}_r^{\prime})\, \bigl[\boldsymbol{\Sigma}^{(r)-1} \otimes \mathbf{A}^{(r)}\bigr]\, (\mathbf{T}_r \otimes \mathbf{T}_r)\,\mathbf{D}, \end{aligned}

with

\mathbf{A}^{(r)} = \boldsymbol{\Sigma}^{(r)-1} \bigl(2\mathbf{W}^{(r)} - \boldsymbol{\Sigma}^{(r)}\bigr)\, \boldsymbol{\Sigma}^{(r)-1}.

Each pattern contributes a Hessian of exactly the complete-data form Equation D.13 (evaluated at the pattern statistics) on the rows and columns indexed by \mathcal{O}_r, and zeros elsewhere. Note that, in contrast with the complete-data case, the off-diagonal blocks do not automatically vanish at the FIML estimate: the FIML estimate of \boldsymbol{\mu} is in general not equal, within \mathcal{O}_r, to the pattern mean \bar{\mathbf{y}}^{(r)}.

D.9.5 Information matrices

The three unit information quantities of Section D.6 generalize to the FIML setting in a natural way: replace each pattern term in the score-outer-product or Hessian by its pattern analogue, sum across patterns, and divide by N. Throughout this subsection, \boldsymbol{\beta} = [\boldsymbol{\mu}^{\prime}, (\text{vech}\,\boldsymbol{\Sigma})^{\prime}]^{\prime} as before.

D.9.5.1 The unit expected information matrix

Under the missing-completely-at-random (MCAR) assumption, \mathrm{E}[\bar{\mathbf{y}}^{(r)} - \boldsymbol{\mu}^{(r)}] = \mathbf{0} and \mathrm{E}[\mathbf{W}^{(r)} - \boldsymbol{\Sigma}^{(r)}] = \mathbf{0}, so the off-diagonal blocks of Equation D.47 vanish in expectation. The unit expected information matrix is therefore block-diagonal:

\mathcal{I}_1^{\text{FIML}} = \frac{1}{N} \sum_{r=1}^{R} n_r \begin{pmatrix} \mathbf{T}_r^{\prime}\boldsymbol{\Sigma}^{(r)-1}\mathbf{T}_r & \mathbf{0} \\[4pt] \mathbf{0}^{\prime} & \frac{1}{2}\mathbf{D}^{\prime} (\mathbf{T}_r^{\prime} \otimes \mathbf{T}_r^{\prime}) \bigl(\boldsymbol{\Sigma}^{(r)-1} \otimes \boldsymbol{\Sigma}^{(r)-1}\bigr) (\mathbf{T}_r \otimes \mathbf{T}_r)\,\mathbf{D} \end{pmatrix}. \tag{D.48}

With complete data (R = 1, \mathbf{T}_1 = \mathbf{I}_{P}, n_1 = N), Equation D.48 reduces to Equation D.14. Under MAR (more general than MCAR but still ignorable), the expected and observed information matrices generally differ, and the observed information matrix below is preferred for inference.

D.9.5.2 The unit observed information matrix

The unit observed information matrix is minus the FIML Hessian Equation D.47 divided by N, evaluated at the parameter estimates:

I_1^{\text{FIML}} = -\frac{1}{N} H_{N}^{\text{FIML}}. \tag{D.49}

It is the default information matrix used by lavaan for FIML inference under missing = "ml".

D.9.5.3 The unit first-order information matrix

The unit first-order (outer-product-of-scores) information matrix is the average outer product of the casewise scores Equation D.46:

\mathbb{I}_1^{\text{FIML}} = \frac{1}{N} \sum_{i=1}^{N} \mathbf{g}_i(\boldsymbol{\beta})\, \mathbf{g}_i(\boldsymbol{\beta})^{\prime}. \tag{D.50}

Equivalently, \mathbb{I}_1^{\text{FIML}} = \mathbf{G}^{\prime}\mathbf{G}/N, where \mathbf{G} is the N\times P^{\star} matrix whose i-th row is \mathbf{g}_i(\boldsymbol{\beta})^{\prime}. With clustered data, the rows of \mathbf{G} are first summed within each cluster and rescaled by \sqrt{N_J/(N_J-1)} (a small-cluster correction).

Unlike the complete-data setting (cf. Section D.6.4), even at the unrestricted (\mathsf{H}_1) estimates the expected and the observed unit information matrices \mathcal{I}_1^{\text{FIML}} and I_1^{\text{FIML}} generally do not coincide, because the off-diagonal blocks of the observed Hessian Equation D.47 remain non-zero when \bar{\mathbf{y}}^{(r)} \ne \mathbf{T}_r\hat{\boldsymbol{\mu}} across patterns.

D.9.6 Sandwich covariance for the unrestricted estimates

Because the three FIML information matrices do not agree in general, the asymptotic covariance matrix of the unrestricted estimates (\hat{\boldsymbol{\mu}}^{h_1}, \text{vech}\,\hat{\boldsymbol{\Sigma}}^{h_1}) is best estimated by a sandwich form that combines the (observed) information and the first-order information:

\boldsymbol{\Omega}_{\text{SW}} = \bigl(I_1^{\text{FIML}}\bigr)^{-1}\, \mathbb{I}_1^{\text{FIML}}\, \bigl(I_1^{\text{FIML}}\bigr)^{-1}. \tag{D.51}

The matrix \boldsymbol{\Omega}_{\text{SW}} is the FIML counterpart of the normal-theory \boldsymbol{\Gamma}^{\mathrm{NT}} of Equation D.18: it provides a consistent estimate of the asymptotic covariance of \sqrt{N}(\hat{\boldsymbol{\mu}}^{h_1} - \boldsymbol{\mu}, \, \text{vech}(\hat{\boldsymbol{\Sigma}}^{h_1} - \boldsymbol{\Sigma})) under MAR (without requiring MCAR). In the FIML literature this matrix is variously called “\boldsymbol{\Omega}_{SW}” or “\boldsymbol{\Gamma} for incomplete data”. It plays the role of \boldsymbol{\Gamma}^{\mathrm{NT}} in the construction of test statistics for model fit when the data are incomplete.

D.9.7 EM algorithm for the unrestricted moments

The score equations Equation D.44 and Equation D.45 do not admit closed-form solutions for unrestricted \boldsymbol{\mu} and \boldsymbol{\Sigma}. lavaan obtains the unrestricted FIML estimates (\hat{\boldsymbol{\mu}}^{h_1}, \hat{\boldsymbol{\Sigma}}^{h_1}) via the EM algorithm, working with the complete-data sufficient statistics \mathbf{q} = \sum_{i=1}^{N}\mathbf{y}_i (P\times 1) and \mathbf{Q} = \sum_{i=1}^{N}\mathbf{y}_i\mathbf{y}_i^{\prime} (P\times P). Iteration t starts from the current values \boldsymbol{\mu}^{(t)} and \boldsymbol{\Sigma}^{(t)}.

In the E-step, for pattern r, partition the indices into observed (\mathcal{O}_r) and missing (\mathcal{M}_r) sets, and use the standard multivariate-normal conditional moments to fill in the missing entries. For each case i in pattern r,

\mathrm{E}\bigl[\mathbf{y}_i^{\mathcal{M}_r} \mid \mathbf{y}_i^{(r)}\bigr] = \boldsymbol{\mu}^{\mathcal{M}_r,(t)} + \boldsymbol{\Sigma}^{\mathcal{M}_r,\mathcal{O}_r,(t)}\, \boldsymbol{\Sigma}^{(r)-1,(t)}\, \bigl(\mathbf{y}_i^{(r)} - \boldsymbol{\mu}^{(r),(t)}\bigr),

with conditional variance correction

\boldsymbol{\Sigma}^{\mathcal{M}_r,\mathcal{M}_r,(t)} - \boldsymbol{\Sigma}^{\mathcal{M}_r,\mathcal{O}_r,(t)}\, \boldsymbol{\Sigma}^{(r)-1,(t)}\, \boldsymbol{\Sigma}^{\mathcal{O}_r,\mathcal{M}_r,(t)}

added to the corresponding \mathcal{M}_r \times \mathcal{M}_r block of \mathbf{Q} for every case in pattern r. Summing over all cases yields the expected sufficient statistics \hat{\mathbf{q}} = \mathrm{E}[\mathbf{q} \mid \mathcal{Y}, \boldsymbol{\mu}^{(t)}, \boldsymbol{\Sigma}^{(t)}] and \hat{\mathbf{Q}} = \mathrm{E}[\mathbf{Q} \mid \mathcal{Y}, \boldsymbol{\mu}^{(t)}, \boldsymbol{\Sigma}^{(t)}].

In the M-step, update the parameters by their complete-data ML formulas applied to the expected sufficient statistics:

\boldsymbol{\mu}^{(t+1)} = \frac{\hat{\mathbf{q}}}{N}, \qquad \boldsymbol{\Sigma}^{(t+1)} = \frac{\hat{\mathbf{Q}}}{N} - \boldsymbol{\mu}^{(t+1)}\boldsymbol{\mu}^{(t+1)\prime}.

The two steps are iterated until the maximum absolute change in (\boldsymbol{\mu}, \text{vech}\,\boldsymbol{\Sigma}) falls below a tolerance. The run is controlled by the em_h1_args option: for single-level data its current defaults are at most 500 iterations, a tolerance of 10^{-5} on the change in the estimates, and SQUAREM acceleration (Varadhan & Roland, 2008); the two-level EM of appendix E uses the same option with different defaults, and a convergence criterion on the log-likelihood instead (Section 16.6.3). When some pairs of variables have zero coverage (no case observes them jointly), the EM update is invalid for the affected covariances; lavaan then falls back to direct numerical maximization of Equation D.42, with \boldsymbol{\Sigma} parameterized through its Cholesky factor.

D.10 Conditional approach with incomplete data

This section combines the conditional model of Section D.8 with the incomplete-data treatment of Section D.9. The combination (conditional_x = TRUE with missing = "ml", "two.stage", or "robust.two.stage") is available for single-level models with continuous data (Section 7.3.4). Only the key steps and the final formulas are given; the pattern of the derivation follows the two sections it builds on.

D.10.1 Setting and notation

The covariates must be complete: conditioning on \mathbf{x}_i is only meaningful for cases where \mathbf{x}_i is observed, so cases with a missing covariate value are removed listwise, and missing = "ml.x" (which integrates over missing covariate values and therefore needs a distribution for \mathbf{x}) is not available. Missing values in the responses are handled pattern by pattern, exactly as in Section D.9.1, with the patterns now defined on the P response variables only: pattern r has observed index set \mathcal{O}_r of size P_r, selection matrix \mathbf{T}_r, and n_r cases. Cases with all responses missing carry no information about (\mathbf{B}, \boldsymbol{\Sigma}_{y|x}) and are dropped. For pattern r we write \mathbf{B}_r = \mathbf{B}\mathbf{T}_r^{\prime} ((Q+1) \times P_r, the columns of \mathbf{B} for the observed responses), \boldsymbol{\Sigma}^{(r)}_{y|x} = \mathbf{T}_r\boldsymbol{\Sigma}_{y|x}\mathbf{T}_r^{\prime}, and \mathbf{r}_i = \mathbf{y}_i^{(r)} - \mathbf{B}_r^{\prime}\mathbf{x}_{1,i} for the observed residual of case i.

D.10.2 The log-likelihood

Marginalizing the conditional normal Equation D.24 over the unobserved responses selects the corresponding rows of \mathbf{B} and the corresponding submatrix of \boldsymbol{\Sigma}_{y|x}, so the observed-data log-likelihood is

\text{logl}(\mathbf{B}, \boldsymbol{\Sigma}_{y|x} \mid \mathcal{Y}, \mathbf{X}) = -\frac{1}{2}\sum_{r=1}^{R}\sum_{i \in r} \Bigl\{ P_r \ln(2\pi) + \ln\bigl|\boldsymbol{\Sigma}^{(r)}_{y|x}\bigr| + \mathbf{r}_i^{\prime}\,\boldsymbol{\Sigma}^{(r)-1}_{y|x}\,\mathbf{r}_i \Bigr\}. \tag{D.52}

The difference with Equation D.42 is that the mean now varies from case to case within a pattern, because it depends on \mathbf{x}_i. The pattern still shares one inverse and one log-determinant (obtained from \boldsymbol{\Sigma}_{y|x}^{-1} by the same inverse update as in the joint case). Because the conditional mean is linear in \mathbf{x}_{1,i}, the quadratic form depends on the data only through three crossproduct matrices per pattern,

\mathbf{W}^{xx}_r = \sum_{i \in r}\mathbf{x}_{1,i}\mathbf{x}_{1,i}^{\prime}, \qquad \mathbf{W}^{xy}_r = \sum_{i \in r}\mathbf{x}_{1,i}\mathbf{y}_i^{(r)\prime}, \qquad \mathbf{W}^{yy}_r = \sum_{i \in r}\mathbf{y}_i^{(r)}\mathbf{y}_i^{(r)\prime},

since the total residual crossproduct of the pattern (a sum over the cases of the pattern, and not an average like \mathbf{W}^{(r)} of Section D.9.1) expands as

\widetilde{\mathbf{W}}_r = \sum_{i \in r}\mathbf{r}_i\mathbf{r}_i^{\prime} = \mathbf{W}^{yy}_r - \mathbf{B}_r^{\prime}\mathbf{W}^{xy}_r - \mathbf{W}^{xy\prime}_r\mathbf{B}_r + \mathbf{B}_r^{\prime}\mathbf{W}^{xx}_r\mathbf{B}_r, \tag{D.53}

and the log-likelihood becomes

\text{logl} = -\frac{1}{2}\sum_{r=1}^{R} \Bigl\{ n_rP_r \ln(2\pi) + n_r\ln\bigl|\boldsymbol{\Sigma}^{(r)}_{y|x}\bigr| + \mathrm{tr}\!\left[\boldsymbol{\Sigma}^{(r)-1}_{y|x}\widetilde{\mathbf{W}}_r\right] \Bigr\}. \tag{D.54}

The three crossproduct matrices are computed once, stored with the sample statistics next to the pattern means and covariances of the joint case, and reused by the objective function, the gradient, the Hessian, and the expected information; only the casewise scores need the raw data. With sampling weights, every sum over the cases of a pattern becomes a weighted sum, and n_r becomes the sum of the weights.

D.10.3 The unrestricted model

The unrestricted conditional model lets (\mathbf{B}, \boldsymbol{\Sigma}_{y|x}) be completely free. With complete data its ML estimates are the OLS regression and the ML residual covariance matrix (Section D.8.3); with missing responses there is no closed form. No new EM algorithm is needed, however. Consider, as a computational device only, the joint normal model for \mathbf{z}= (\mathbf{y}^{\prime}, \mathbf{x}^{\prime})^{\prime} with unrestricted (\boldsymbol{\mu}, \boldsymbol{\Sigma}), partitioned into y and x blocks. The joint density factorizes as f(\mathbf{y}, \mathbf{x}) = f(\mathbf{y}\mid \mathbf{x})\,f(\mathbf{x}), and the map

\boldsymbol{\Pi}= \boldsymbol{\Sigma}_{yx}\boldsymbol{\Sigma}_{xx}^{-1}, \qquad \boldsymbol{\gamma}= \boldsymbol{\mu}_y - \boldsymbol{\Pi}\boldsymbol{\mu}_x, \qquad \boldsymbol{\Sigma}_{y|x} = \boldsymbol{\Sigma}_{yy} - \boldsymbol{\Sigma}_{yx}\boldsymbol{\Sigma}_{xx}^{-1}\boldsymbol{\Sigma}_{xy} \tag{D.55}

is a one-to-one reparameterization of (\boldsymbol{\mu}, \boldsymbol{\Sigma}) into the conditional part (\mathbf{B}, \boldsymbol{\Sigma}_{y|x}) and the marginal part (\boldsymbol{\mu}_x, \boldsymbol{\Sigma}_{xx}), with variation-independent blocks. Because the covariates are complete, the same factorization holds case by case for the observed data: marginalizing the joint normal over the missing responses and then conditioning on \mathbf{x}_i commute, so that \log f(\mathbf{y}_i^{(r)}, \mathbf{x}_i) = \log f(\mathbf{y}_i^{(r)} \mid \mathbf{x}_i; \mathbf{B}, \boldsymbol{\Sigma}_{y|x}) + \log f(\mathbf{x}_i; \boldsymbol{\mu}_x, \boldsymbol{\Sigma}_{xx}). Summed over cases, the joint observed-data log-likelihood separates into a conditional term and a marginal term with disjoint parameters, and maximizing it maximizes both. Consequently, the unrestricted conditional estimates are obtained by running the joint EM algorithm of Section D.9.7 on (\mathbf{y}, \mathbf{x}) and partitioning the result with Equation D.55. This is what lavaan does (the partition is written as a small augmented regression, as in the complete-data case); the results are stored as the res.int, res.slopes, and res.cov elements of the \mathsf{H}_1 estimates, which lavInspect(fit, "h1") returns. Auxiliary variables (aux=) are appended to the joint EM run and dropped afterwards, as in the joint case. The unrestricted log-likelihood is evaluated by inserting the partitioned estimates into Equation D.54, so that the restricted and the unrestricted model use one and the same kernel.

The same argument yields an identity that is useful for validation. With the covariate moments held at their EM (or sample) values \hat{\boldsymbol{\tau}}_x, the conditional log-likelihood differs from the joint fixed_x = TRUE log-likelihood by a constant that does not depend on the model parameters: \text{logl}_{\text{cond}}(\boldsymbol{\vartheta}) = \text{logl}_{\text{joint}}(\boldsymbol{\vartheta}, \hat{\boldsymbol{\tau}}_x) - \text{logl}_x(\hat{\boldsymbol{\tau}}_x). Therefore conditional_x = TRUE, missing = "ml" and fixed_x = TRUE, missing = "ml" fit the same likelihood and must agree, up to optimizer precision, on the parameter estimates, the reported (conditional) log-likelihood, the chi-square statistic, and the Hessian-based standard errors. The following chunk checks this, and verifies the partitioning against the joint EM moments returned by lavH1():

model <- '
  visual  =~ x1 + x2 + x3
  textual =~ x4 + x5 + x6
  visual  ~ ageyr + sex
  textual ~ ageyr
'
set.seed(1)
d <- HolzingerSwineford1939
d$x1[sample(301, 40)] <- NA
d$x5[sample(301, 40)] <- NA
fit_cond  <- sem(model, data = d, missing = "ml", conditional_x = TRUE)
fit_joint <- sem(model, data = d, missing = "ml", fixed_x = TRUE)
c(logLik(fit_cond), logLik(fit_joint))
[1] -2406.785 -2406.785
max(abs(coef(fit_cond) - coef(fit_joint)))
[1] 3.449038e-06
max(abs(sqrt(diag(vcov(fit_cond))) - sqrt(diag(vcov(fit_joint)))))
[1] 3.429935e-06
# partitioning the joint EM moments reproduces the unrestricted
# conditional moments of the fit
h1  <- lavInspect(fit_cond, "h1")
em  <- lavH1(model, data = d, missing = "ml", fixed_x = FALSE)
yv  <- paste0("x", 1:6); xv <- c("ageyr", "sex")
Pi  <- em$cov[yv, xv] %*% solve(em$cov[xv, xv])
nu  <- em$mean[yv] - Pi %*% em$mean[xv]
Sres <- em$cov[yv, yv] - Pi %*% em$cov[xv, yv]
c(max(abs(Pi - h1$res.slopes)), max(abs(nu - h1$res.int)),
  max(abs(Sres - h1$res.cov)))
[1] 1.076916e-14 1.483258e-13 7.549517e-15

D.10.4 Derivatives and information matrices

Define, per pattern, the kernel \mathbf{C}_r = \mathbf{W}^{xy}_r - \mathbf{W}^{xx}_r\mathbf{B}_r = \sum_{i \in r}\mathbf{x}_{1,i}\mathbf{r}_i^{\prime}, the pattern analogue of \mathbf{X}_1^{\prime}(\mathbf{Y} - \mathbf{X}_1\mathbf{B}) in Equation D.32. Differentiating Equation D.54, pattern r contributes

\frac{\partial \text{logl}}{\partial \mathbf{B}}\bigg|_{\text{columns } \mathcal{O}_r} \mathrel{+}= \mathbf{C}_r\,\boldsymbol{\Sigma}^{(r)-1}_{y|x}, \qquad \frac{\partial \text{logl}}{\partial \boldsymbol{\Sigma}_{y|x}}\bigg|_{\mathcal{O}_r \times \mathcal{O}_r} \mathrel{+}= -\frac{n_r}{2}\left( \boldsymbol{\Sigma}^{(r)-1}_{y|x} - \boldsymbol{\Sigma}^{(r)-1}_{y|x}\frac{\widetilde{\mathbf{W}}_r}{n_r}\boldsymbol{\Sigma}^{(r)-1}_{y|x} \right), \tag{D.56}

and nothing to the entries outside these blocks, which its likelihood does not involve. The gradient with respect to \text{vech}(\boldsymbol{\Sigma}_{y|x}) follows by applying \mathbf{D}^{\prime}, and the model gradient by the chain rule through the Jacobian \boldsymbol{\Delta} of the conditional moments, whose row order (per response variable, the intercept followed by the slopes, then \text{vech}\,\boldsymbol{\Sigma}_{y|x}) is the same as in the complete-data case. The casewise score of case i in pattern r has the form of Equation D.34 restricted to the observed entries: \mathbf{x}_{1,i} \otimes the residual kernel \mathbf{r}_i^{\prime} \boldsymbol{\Sigma}^{(r)-1}_{y|x} for the columns of \mathbf{B} in \mathcal{O}_r, and the normal score kernel of \mathbf{r}_i for the \mathcal{O}_r \times \mathcal{O}_r block of \boldsymbol{\Sigma}_{y|x}, both zero-padded elsewhere. The scores sum to the gradient, and their average outer product is the first-order information; both identities are used as internal consistency checks.

Differentiating once more gives the observed information. Writing \bar{\mathbf{S}}_r for \boldsymbol{\Sigma}^{(r)-1}_{y|x} zero-padded to P\times P, and \bar{\mathbf{C}}_r for \mathbf{C}_r zero-padded to (Q+1) \times P,

\begin{aligned} -\mathbf{H}_{11} &= \sum_r \Bigl[\boldsymbol{\Sigma}^{(r)-1}_{y|x} \otimes \mathbf{W}^{xx}_r\Bigr] \ \text{(on the coefficient blocks of } \mathcal{O}_r\text{)},\\ -\mathbf{H}_{21} &= \sum_r \mathbf{D}^{\prime} \bigl(\bar{\mathbf{S}}_r \otimes \bar{\mathbf{S}}_r\bar{\mathbf{C}}_r^{\prime}\bigr),\\ -\mathbf{H}_{22} &= \sum_r \frac{n_r}{2}\,\mathbf{D}^{\prime} \bigl(\bar{\mathbf{S}}_r \otimes \bar{\mathbf{A}}_r\bigr)\mathbf{D}, \qquad \mathbf{A}_r = \boldsymbol{\Sigma}^{(r)-1}_{y|x} \Bigl(2\frac{\widetilde{\mathbf{W}}_r}{n_r} - \boldsymbol{\Sigma}^{(r)}_{y|x}\Bigr) \boldsymbol{\Sigma}^{(r)-1}_{y|x}. \end{aligned} \tag{D.57}

The coefficient block is block-sparse (a pattern only couples the coefficients of its observed responses), the cross block does not vanish away from the unrestricted solution, and the covariance block has the same form as in the joint incomplete-data case, with the pattern residual average \widetilde{\mathbf{W}}_r/n_r in the role of the pattern crossproduct around the mean. The \mathbf{H} blocks are the blocks of the Hessian H_{N} of this log-likelihood, and the unit observed information is -H_{N}/N. Taking expectations given the observed patterns and covariate values (\mathrm{E}[\mathbf{r}_i \mid \mathbf{x}_i] = \mathbf{0} and \mathrm{E}[\widetilde{\mathbf{W}}_r] = n_r \boldsymbol{\Sigma}^{(r)}_{y|x}) gives the block-diagonal unit expected information

\mathcal{I}_{1,11} = \frac{1}{N}\sum_r \Bigl[\boldsymbol{\Sigma}^{(r)-1}_{y|x} \otimes \mathbf{W}^{xx}_r\Bigr], \qquad \mathcal{I}_{1,22} = \frac{1}{N}\sum_r \frac{n_r}{2}\,\mathbf{D}^{\prime} \bigl(\bar{\mathbf{S}}_r \otimes \bar{\mathbf{S}}_r\bigr)\mathbf{D}, \qquad \mathcal{I}_{1,21} = \mathbf{0}. \tag{D.58}

Two remarks apply. First, as in the joint case, an expectation “given the observed patterns” is a proper expected information only under MCAR; under MAR the observed information is the appropriate choice, which is why information = "observed" is the current default with missing = "ml". Second, the conditional expected information is not the same object as the expected information of the joint fixed_x = TRUE fit with incomplete data: the former uses the realized covariate crossproducts \mathbf{W}^{xx}_r of the cases in each pattern, the latter pattern submatrices of the joint \boldsymbol{\Sigma}. With complete data the two coincide; with missing data they differ, and every statistic that relies on the expected information by default (notably lavTestScore()) gives moderately different results in the two parameterizations, while the observed-information versions agree.

D.10.5 Two-stage estimation

For missing = "two.stage" and "robust.two.stage", stage 1 estimates the unrestricted conditional moments by the joint EM plus partitioning of Section D.10.3, and stage 2 fits the model to these moments with the complete-data conditional machinery of Section D.8, as if they were sample statistics. The standard errors must account for stage 1 (Section 8.4.11). With \mathbf{J} the complete-data \mathsf{H}_1 information (the bread) and \boldsymbol{\Omega} the asymptotic covariance matrix of the stage-1 estimates, the parameter covariance matrix is the sandwich

(\boldsymbol{\Delta}^{\prime}\mathbf{J}\boldsymbol{\Delta})^{-1} \boldsymbol{\Delta}^{\prime}\mathbf{J}\,\boldsymbol{\Omega}\,\mathbf{J}\boldsymbol{\Delta} (\boldsymbol{\Delta}^{\prime}\mathbf{J}\boldsymbol{\Delta})^{-1},

with \boldsymbol{\Omega} = I_1^{-1}, the inverse of the observed information of the stage-1 problem (se = "two.stage", Savalei and Bentler (2009)), or \boldsymbol{\Omega} = I_1^{-1} \mathbb{I}_1 I_1^{-1} (se = "robust.two.stage", Savalei and Falk (2014)), both in the conditional metric. Inverting the conditional block gives the correct marginal covariance matrix of the conditional estimates, even though stage 1 estimated the joint moments, because with complete covariates the joint information is block-diagonal between (\mathbf{B}, \boldsymbol{\Sigma}_{y|x}) and (\boldsymbol{\mu}_x, \boldsymbol{\Sigma}_{xx}). The same two matrices serve as the incomplete-data \boldsymbol{\Gamma} of the conditional moments (Section D.7.6). The combination is not available with the least-squares estimators, nor with auxiliary variables in the two-stage standard errors.

D.10.6 What agrees with the joint fixed_x = TRUE fit

Since the two parameterizations fit the same likelihood, any difference between them is a matter of which information matrix a statistic uses (Table D.1). The practical advice is to compare Hessian-based or sandwich-based quantities when checking the two parameterizations against each other or against other software, and to request information = "observed" for the score test under missingness.

Table D.1: Agreement between conditional_x = TRUE and fixed_x = TRUE under missing = "ml".
Quantity Agreement Reason
estimates, log-likelihood, chi-square, df exact same likelihood
standard errors, observed_information = "hessian" exact Hessian in the parameter metric
standard errors, observed_information = "h1" below 1% differ by a vanishing gradient term
MLR standard errors, Yuan-Bentler scaled tests numerically identical identical scores in the parameter metric
two-stage and robust two-stage standard errors below 1% same, via the stage-1 blocks
standard errors, information = "expected" about 6% different conditioning
lavTestScore() with its default expected information about 20% in the statistic inherits the expected-information difference
baseline model and incremental fit indices different by design the conditional baseline frees the slopes

D.11 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 D.2 maps the quantities of this appendix to the functions that compute them. The functions with suffix _samp work from the sample statistics; those with suffix _data from the raw data.

Table D.2: Functions behind the computations of this appendix.
Quantity Function File
normal-theory \boldsymbol{\Gamma}, Equation D.19 lav_samp_gamma_nt() lav_samplestats_gamma.R
ADF and model-based \boldsymbol{\Gamma} (Equation D.20, Equation 8.19, Equation 8.20) lav_samp_gamma() lav_samplestats_gamma.R
two-level \boldsymbol{\Gamma} (one score per cluster) lav_samp_gamma_2l_g() lav_samplestats_wls_2l.R
conditional log-likelihood, raw data (Equation D.29) lav_mvreg_loglik_data() lav_mvreg.R
conditional log-likelihood, sample statistics (Equation D.31) lav_mvreg_loglik_samp() lav_mvreg.R
gradient w.r.t. \mathbf{B} (Equation D.32) lav_mvreg_dlogl_dbeta() lav_mvreg.R
gradient w.r.t. \boldsymbol{\Sigma}_{y|x} and its vech (Equation D.33) lav_mvreg_dlogl_drescov(), lav_mvreg_dlogl_dvechrescov() lav_mvreg.R
casewise scores (Equation D.34) lav_mvreg_sc_beta(), lav_mvreg_sc_sigma(), lav_mvreg_sc_beta_sigma() lav_mvreg.R
conditional Hessian (Equation D.35) lav_mvreg_logl_hessian_samp() lav_mvreg.R
conditional expected information (Equation D.36) lav_mvreg_info_expected() lav_mvreg.R
conditional observed information (Equation D.38) lav_mvreg_info_observed_data(), lav_mvreg_information_observed_samplestats() lav_mvreg.R
conditional first-order information lav_mvreg_info_firstorder() lav_mvreg.R
pattern-wise inverse \boldsymbol{\Sigma}^{(r)-1} by inverse update lav_mat_sym_inverse_update() lav_matrix.R
FIML log-likelihood (Equation D.42), pattern-based and casewise lav_mvn_mi_loglik_samp(), lav_mvn_mi_llik_pattern(), lav_mvn_mi_llik_casewise() lav_mvnorm_missing.R
FIML gradient (Equation D.44, Equation D.45) lav_mvn_mi_dlogl_dmu_samp(), lav_mvn_mi_dlogl_dsigma_samp() lav_mvnorm_missing.R
FIML casewise scores (Equation D.46) lav_mvn_mi_sc_mu_sigma() lav_mvnorm_missing.R
FIML Hessian lav_mvnorm_missing_logl_hessian_samplestats() lav_mvnorm_missing.R
FIML expected information (Equation D.48) lav_mvn_mi_info_expected() lav_mvnorm_missing.R
FIML observed information (Equation D.49) lav_mvn_mi_info_observed_data() lav_mvnorm_missing.R
FIML first-order information lav_mvn_mi_info_firstorder() lav_mvnorm_missing.R
\boldsymbol{\Omega}_{SW} for the unrestricted model lav_mvn_mi_h1_omega_sw() lav_mvnorm_missing_h1.R
EM for the unrestricted model: E-step and driver lav_mvn_mi_estep(), lav_mvn_mi_h1_est_moments() lav_mvnorm_missing.R, lav_mvnorm_missing_h1.R
zero-coverage fallback (Cholesky parameterization) lav_mvn_mi_h1_est_moments_chol() lav_mvnorm_missing_h1.R
pattern crossproducts for the conditional FIML case lav_samp_mi_patterns_res() lav_mvreg_missing.R

In the conditional approach, the coefficient matrix \mathbf{B} of Section D.8 is assembled from the stored intercepts and slopes as Beta = rbind(matrix(res.int, nrow = 1), t(res.slopes)). The pattern-specific sample statistics of Section D.9 (and, for the conditional case, the three crossproduct matrices of Section D.10) are stored in the @missing slot of the lavsamplestats object; the EM estimates of the unrestricted model are stored in its @missing.h1 slot, which lavInspect(fit, "h1") returns.

The sandwich identity Equation D.21 can be checked with the internal routines that compute the ADF \boldsymbol{\Gamma} (lav_samp_gamma()) and the unit expected and first-order information matrices at the sample moments (lav_mvn_info_expected() and lav_mvn_info_firstorder(), both in lav_mvnorm.R):

Y <- as.matrix(HolzingerSwineford1939[, paste0("x", 1:9)])
N <- nrow(Y); ybar <- colMeans(Y); S <- cov(Y) * (N - 1) / N
gamma_adf <- lavaan:::lav_samp_gamma(Y, meanstructure = TRUE)
I1 <- lavaan:::lav_mvn_info_expected(sigma_1 = S)
J1 <- lavaan:::lav_mvn_info_firstorder(y = Y, mu = ybar, sigma_1 = S)
max(abs(gamma_adf - solve(I1) %*% J1 %*% solve(I1)))
[1] 1.998401e-14