A Note on the Connection Between Trek Rules and Separable Nonlinear Least Squares in Linear Structural Equation Models

We show that separable nonlinear least squares (SNLLS) estimation is applicable to all linear structural equation models (SEMs) that can be specified in RAM notation. SNLLS is an estimation technique that has successfully been applied to a wide range of models, for example neural networks and dynamic systems, often leading to improvements in convergence and computation time. It is applicable to models of a special form, where a subset of parameters enters the objective linearly. Recently, Kreiberg et al. (Struct Equ Model Multidiscip J 28(5):725–739, 2021. 10.1080/10705511.2020.1835484) have shown that this is also the case for factor analysis models. We generalize this result to all linear SEMs. To that end, we show that undirected effects (variances and covariances) and mean parameters enter the objective linearly, and therefore, in the least squares estimation of structural equation models, only the directed effects have to be obtained iteratively. For model classes without unknown directed effects, SNLLS can be used to analytically compute least squares estimates. To provide deeper insight into the nature of this result, we employ trek rules that link graphical representations of structural equation models to their covariance parametrization. We further give an efficient expression for the gradient, which is crucial to make a fast implementation possible. Results from our simulation indicate that SNLLS leads to improved convergence rates and a reduced number of iterations. Supplementary Information The online version contains supplementary material available at 10.1007/s11336-022-09891-5.


99
In the behavioral and social sciences, structural equation models (SEMs) have become widely accepted as a multivariate statistical tool for modeling the relation between latent and observed variables. Apart from maximum likelihood estimation, least squares (LS) estimation is a common approach for parameter estimation. In LS, parameters are estimated by minimizing a nonlinear function of the parameters and data. In practice, this problem is typically solved by applying generic nonlinear optimization techniques, such as Newton-type gradient descent approaches that iteratively minimize the objective function until convergence is reached. However, for some model classes, generic optimization algorithms can be adapted to make better use of the model structure and thus solve the problem more efficiently. For a particular type of models, the parameters separate, that is, one set of parameters enters the objective in a nonlinear way, while another set of parameters enters the objective linearly. For a vector of observations y and predictors x of size m, the objective is of the form where α ∈ R n , β ∈ R k are parameter vectors and the (nonlinear) functions ϕ j are continuously differentiable w.r.t. β. Golub and Pereyra (1973) showed that this kind of objective allows for a reformulation of the optimization problem, such that only the parameters β have to be obtained iteratively, while the parameters α can be computed after the optimization in a single step. The procedure has been subsequently called separable nonlinear least squares (SNLLS). It has been successfully applied in many disciplines, and it has been observed that the reduced dimension of the parameter space can lead to reduced computation time, a reduced number of iterations and better convergence properties (Golub & Pereyra, 2003). Inspired by earlier work (Kreiberg et al., 2016(Kreiberg et al., , 2021 that showed that this procedure can also be applied to factor analysis models, we generalize their result to the entire class of linear structural equation models and give analytical gradients for the reduced optimization problem, which is central for an efficient implementation.

Review of Concepts
In the following, we briefly review the notation for structural equation models, the generalized least squares estimator and the trek rules used to derive the model-implied covariance matrix.

Linear Structural Equation Models
Linear structural equation models can be defined in RAM notation (reticular action model; McArdle & McDonald, 1984) as follows (we follow the notation from Drton, 2018): Let x, ε be random vectors with values in R m and where ∈ R m×m is a matrix of constants or unknown (directed) parameters. Let ∈ R m×m be the covariance matrix of ε and I the identity matrix. If I − is invertible, Eq. 2 can be solved by 100 PSYCHOMETRIKA If x is partitioned into a part x obs of m obs observed variables and x lat of m lat latent variables, we can reorder x such that x = x T obs x T lat T , and the covariance matrix of the observed variables is given by where F = I 0 ∈ R m obs ×(m obs +m lat ) is a rectangular filter matrix. We denote the parameters by θ = θ T T T ∈ R q , partitioned into directed parameters from and undirected parameters from . (We call them directed or undirected parameters because they correspond to directed or undirected paths in the graph of the model.) If we want to stress that is a function of the parameters, we write (θ ). If we are also interested in the mean structure, we introduce a vector of (possibly zero) mean parameters γ ∈ R m such that x = γ + x + ε and obtain

Least Squares Estimation
The least squares objective function for θ is: where σ = vech( ) is the half-vectorization of , that is, the vector of non-duplicated elements of the model-implied covariance matrix, s = vech(S) is the half-vectorization of the observed covariance matrix and V is a fixed symmetric positive definite weight matrix. Specific forms of the weight matrix V lead to commonly used special cases of this estimation technique: Generalized least squares estimation uses V = 1 2 D T S −1 ⊗ S −1 D (where D denotes the duplication matrix from Magnus and Neudecker (2019b)), asymptotic distribution-free estimation uses a consistent estimator of the asymptotic covariance matrix of s, and unweighted least squares estimation uses the identity matrix (Bollen, 1989;Browne, 1982Browne, , 1984.

Trek Rules
To show that in SEM undirected effects enter the least squares objective linearly, we employ trek rules (Drton, 2018), which are path tracing rules used to derive the model-implied covariance between any pair of variables in a SEM (Boker et al., 2002). Various authors have proposed rules to link the graph to the covariance parametrization of the model. Here, we give the rules as put forward by Drton (2018), which are based on treks as basic building blocks (for an overview of alternative formulations see Mulaik, 2009). A trek τ from a node i to j is a path connecting them, where directed edges can be traveled forwards and backwards, but it is not allowed to walk from one arrowhead into another (without colliding arrowheads). A top node of a trek is a node which has only outgoing edges.
To derive an expression for the model-implied covariance between any two variables i and j based on the postulated SEM, we follow 4 steps: 1. Find all treks from i to j. 2. For each trek, multiply all parameters along it. 3. If a trek does not contain a covariance parameter, factor in the variance of the top node. 4. Add all obtained trek monomials from the different treks together. Note that a trek is ordered in the sense that two treks containing exactly the same nodes and edges are considered different if they are traveled in a different order. In particular, each trek has a source (i) and a target ( j), and a trek from j to i is considered to be a different trek, even if it contains exactly the same nodes and edges. Also note that variances are not considered to be edges in the mixed graph corresponding to the model (i.e., it is not allowed to travel variance edges). Therefore, all graphical representations of SEMs in this article omit variance edges, and it is required to factor them in according to rule 3 after the treks are collected.

Example
To illustrate how the model-implied covariances can be derived using trek rules, we give an example based on the graph shown in the path diagram in Fig. 1. To find the model-implied covariance between nodes X 2 and X 6 in the model shown in Fig. 1, we first find all treks from X 2 to X 6 We now compute the trek monomials for each trek. The second trek does not contain a covariance parameter, so we need to factor in the variance of the top node. We find the trek's top node G and denote the variance parameter of G by ω G . Finally, we add the resulting trek monomials and we find that the model-implied covariance between X 2 and X 6 can be expressed as follows: cov(X 2 , X 6 ) = λ 2 ω l λ 6 + β 2 ω G β 6 (9) As a second example, we derive the model-implied variance of X 3 . Again, we first find all treks from X 3 to X 3 : All treks do not contain a covariance parameter, so we need to factor in the variance of the respective top nodes ζ 1 , G and X 3 . We denote the variance parameters of ζ 1 and X 3 by ω ζ 1 and ω 3 and add the resulting trek monomials to obtain var(X 3 ) = λ 2 3 ω ζ 1 + β 2 3 ω G + ω 3 (13)

Formal Definitions
We denote the elements of , the undirected effects between nodes i and j, by ω i j and the elements of , the directed effects, by λ i j . Drton (2018) defines a trek monomial of a trek τ without a covariance parameter as where i 0 is the top node of the trek, and a trek monomial of a trek τ containing an undirected edge between i 0 and j 0 as (notice the swapped indices of λ lk compared to the formula in Drton because our corresponds to his T ). With this, the elements of (θ ) are represented as a summation over treks. He proves that where T (i, j) is the set of all treks from i to j. It follows that the model-implied covariance is a sum of monomials of parameters. Because covariances between the error terms are not transitive, exactly one undirected parameter (variance or covariance) is present in each monomial. Therefore, if all the directed parameters were fixed, the model-implied covariance would be a linear function of the undirected parameters. This is what makes the SNLLS procedure applicable to structural equation models. For later use, we also note that Drton gives the following expression: where P( j, i) is the set of directed paths from j to i. This is because we can write (I − ) −1 = ∞ k=0 k , where the geometric series converges iff all eigenvalues of lie in (−1, 1). (Further explanations about this and an excellent account of the connections between matrix algebra and graphs can be found in Kepner & Gilbert (2011).)

Separable Nonlinear Least Squares for SEM
We first outline the proofs for the applicability of SNLLS to CFA as given by Golub and Pereyra (1973) and Kreiberg et al. (2021). Subsequently, we proof that SNLLS is applicable to linear structural equation models. We further extend the existing proofs to subsume models that contain a mean structure. Last, we derive analytic gradients that are central for efficient software implementations.

Outline of Previous Work
To minimize Eq. 1, Golub and Pereyra (1973) define the matrix function such that Eq. 1 can be written as where · denotes the euclidean norm. For a fixed value of β, a solution for α can be obtained as α = + (β)y. They further proved that under the assumption that (β) has constant rank near the solution, only the nonlinear parameters β have to be obtained iteratively by replacing α and minimizing the modified objective where + denotes the Moore-Penrose generalized inverse. Afterward, the least squares solution for the linear parameters α can be obtained as the standard least squares estimator arg min α∈R n (β)α − y = + (β)y. Kreiberg et al. (2021) showed that this procedure is applicable for CFA models (we reproduce their main results in our notation), as it is possible to rewrite the model-implied covariances σ as a product of a matrix-valued function G(θ ) (that depends only on the directed parameters) and the undirected parameters θ , so the LS objective can be written as They further stated that if θ is fixed, we know from standard linear least squares estimation that the minimizer for the undirected effects can be obtained aŝ Inserting Eq. 24 into Eq. 22 and simplifying, they obtained a new objective to be minimized: This objective only depends on the directed parameters θ . After minimizing it to obtain a LS estimateθ , Eq.24 can be used to obtain the LS estimate of θ . We would like to note they assume that G has full rank, which is not a necessary assumption and can be relaxed using alternative formulations of Eqs. 24 and 25. To extend the method to general structural equation models, we have to derive G(θ ). We do that in the following for all models formulated in the RAM notation.

Derivation of G(θ )
Since F = I 0 with 0 ∈ R m obs ×m lat , the product FMF T for any M ∈ R m×m is equal to just deleting the last m lat rows and columns of M. We also note that for any matrices M, D ∈ R n×n we can write With this in mind, we can rewrite the model-implied covariance matrix (θ ) as with i, j ∈ {1, . . . , m obs }. We now immediately see that each entry of is a sum of products of entries of (I − ) −1 and . More importantly, exactly one entry of enters each term of the sum; if we keep all entries of fixed, each element in is a linear function of the entries of and is therefore a linear function of the undirected parameters in (under the assumption that is linearly parameterized). As a result, the parameter vector θ is separable in two parts, θ from and θ from , and θ enters the computation of the model-implied covariance linearly. As stated before, this is the reason why we will be able to apply separable nonlinear least squares estimation to our problem. Before we proceed, we would like to introduce some notation. If F and G are tuples of length n and m, and f and g are functions, we define a column vector of length n as and a matrix of size n × m as To make the subsequent steps easier to follow, we assume that there are no equality constraints between parameters in and no constant terms in different from 0. In Appendices A and B, we show how to lift those assumptions. We now further simplify Eq. 30: Since only nonzero entries of (the parameters θ ) contribute to the sum, we define C as the lower triangular indices of θ in , i.e., C i = (l, k) ∈ N × N with (θ ) i = ω lk and l ≥ k. We now rewrite Eq. 30 by omitting all zero terms: where δ k =l is an indicator function that takes the value 1 if k = l and 0 otherwise. Since we are only interested in the non-duplicated elements σ of , we define another index tuple D that denotes the indices of the original position of σ k in , i.e., D k = (i, j) such that σ k = i j . This allows us to stack the expression we just found for i j rowwise to get where G(θ ) ∈ R dim(σ )×dim(θ ) . (We let dim(·) of a vector denote its number of elements, i.e., the dimension of the underlying (finite-dimensional) vector space.) Even though this expression may appear involved, it is in fact easy to compute. Before the optimization procedure starts, we store C by looking up the positions of the parameters in and also store D. At each step of the optimization procedure, to compute G(θ ), we now compute (I− ) −1 first and then loop through the entries C and D to compute each entry of G(θ ) according to Eq. 37. We note that G will typically be sparse; therefore, it is advisable to analyze its sparsity pattern previous to the optimization, and only loop through nonzero values.
In Appendix D, we present a different way of obtaining G(θ ) and the gradients, which mimics the approach of Kreiberg et al. (2021). However, the expressions obtained here are computationally more efficient, as the ones in the appendix contain very large Kronecker products.

Mean Structures
If the model contains mean parameters, we partition the parameter vector θ into three parts: θ and θ as before, and θ γ from the mean vector γ . From Eq. 5, we directly see that the modelimplied mean vector μ(θ) is a linear function of θ γ . If we let A denote the indices of the parameters θ γ in γ , i.e., for i = A j we have (θ γ ) j = γ i , we obtain the formula We now make a slight change in notation: For the previously obtained G(θ )-matrix, we write G σ instead and define G μ := (I − ) −1 i j i∈(1,...,m obs ), j∈A . Using a formulation of the least squares objective that also includes a mean structure, we see that It follows that in addition to the undirected parameters, the mean parameters also do not have to be optimized iteratively but can instead be computed analytically after the iterative optimization is completed.

Gradient of the SNLLS Objective
There are computationally efficient expression to compute the SNLLS objective and its gradient analytically (Kaufman, 1975;O'Leary & Rust, 2013). Because numerical approximations of the gradient are often slow and may become numerically unstable, we derive an analytical expression for the part of the gradient that is specific to SEMs. We use the notation and methods from Magnus and Neudecker (2019a) and denote the differential by d and the Jacobian by D. The Jacobian of a matrix function M with respect to a vector x is defined as D M = ∂ vec M ∂ x T . In the approaches by Kaufman (1975) and O'Leary and Rust (2013), the gradient of the SNLSS objective is expressed in terms of the partial derivatives of the entries of G w.r.t the nonlinear parameters, i.e., D G. In order to be able to implement such efficient approaches in practice, we derive D G here. We also give the full gradient of Eq. 25 for completeness in Appendix C, although in practice, a more efficient expression from the cited literature can be used (which also does not assume G to have full rank). For reasons of clarity, we here only consider the case without mean structure, e.g., G = G σ . This is because the derivative of G μ is similar to obtain and we do not want to make the derivation unnecessarily technical.
Let E denote the indices of θ in , i.e., E k = (i, j) such that i j = (θ ) k . We note that With this, we derive the partial derivatives of each entry of G in terms of the matrix (I − ) −1 as and we obtain D G ∈ R dim(σ ) dim(θ )×dim(θ ) as To facilitate software implementation, we give a way to compute D G in pseudocode in Algorithm 1. In practice, D G will typically contain many zero values. Therefore, it is advisable to analyze the sparsity pattern of D G before the optimization procedure begins and to only compute the nonzero values of D G at each iteration. Also note that the entries of D G are continuous w.r.t θ , since they are sums of products of entries of the inverse (I − ) −1 , which is continuous.
vl end for end for end for

Discussion
We have shown that separable nonlinear least squares is applicable to generalized least squares estimation of structural equation models formulated in the RAM notation. We have also shown a connection to path tracing rules in the form of trek rules. Note that when the same weight matrix is used, the point estimates obtained by SNLLS and LS are identical. Therefore, standard errors and test statistics are obtained using the same methods available for regular least squares estimation. In the following, we would like to discuss the two major benefits of using SNLLS for SEM: better convergence properties and a reduction in the computation time for parameter estimation.

Convergence
An important issue in SEM is convergence problems, especially in small samples (De Jonckere & Rosseel, 2022). If the optimizer fails to converge, no parameter estimates can be obtained. Using the SNLLS objective should lead to fewer convergence problems than LS, since only the directed parameters need to be estimated iteratively. Therefore, only the subset of directed parameters requires starting values. In many models, most of the directed parameters are factor loadings, and we can obtain very good starting values for them with the FABIN 3 estimator (Hägglund, 1982). Also, Ruhe and Wedin (1980) and Golub and Pereyra (2003) give additional proofs and reasons for why the reduced optimization problem of SNLLS should in principle be better behaved than the full LS problem. Additionally, for the class of models without unknown directed parameters, convergence problems should be eliminated altogether, as the estimator of the mean and (co)variance parameters can be computed analytically. Most prominently, this features many types of latent growth curve models.
To investigate the convergence properties of SNLLS in SEM, we ran a small simulation. We used the model in Fig. 2 to draw 1000 random data sets for varying sample sizes (N = 10 to N = 100) under the assumption of multivariate normality with zero expectation and the model-implied covariance induced by the parameters. The sample size and the factor loadings are deliberately chosen to be small to achieve a setting where non-convergence often occurs. We fitted the true model to each sample with generalized least squares (GLS; Bollen, 1989) and SNLLS estimation. All analyses were done in the programming language R (R Core Team, 2021). For GLS estimation, we used lavaan (Rosseel, 2012). The plots were created with ggplot2 (Wickham, 2016), and the data were prepared with dplyr (Wickham et al., 2021). In Fig. 3 we report the number of converged models for each sample size. In Fig. 4, we report the median number of iterations needed until convergence for each sample size. Using SNLLS effectively halved the median number of iterations until convergence for most sample sizes and more than halved the number of non-converged models for most sample sizes. This indicates that SNLLS might be a useful alternative for applied researchers to consider if they encounter convergence problems.

Computation Time
The benefits of SNLLS estimation, specifically the reduced dimensionality of the parameter space, better starting values and fewer iterations to convergence, could lead to reduced computation times. However, the computation of the SNLLS objective function and gradient is also more costly, so the cost per iteration can be higher. In sum, the question whether SNLLS estimation is faster in actual time spent in the optimization hinges upon several aspects, such as the actual implementation of the gradient, meta-parameters of the optimizer and model complexity. Kreiberg et al. (2021) stated that estimation by SNLLS will typically be multiple times faster than LS when the reduced parameter space is much smaller than the original one. They conducted a simulation study, where they fitted a number of CFA models and concluded that the estimation time is bigger for LS than for SNLLS as the number of estimated parameters increases. Even   Simulation results-median number of iterations by sample size. GLS, generalized least squares; SNLLS, separable nonlinear least squares though their simulation is useful to illustrate the potential benefits of SNLLS, it seems unfit to us to make a case for a general reduction in computation time when using SNLLS in modern software. The gradient computation in the simulation was based on a finite difference approximation in both the LS and the SNLLS condition. In existing software (Rosseel, 2012;von Oertzen et al., 2015), analytic gradients are implemented for LS estimation, so the authors compare against a straw man that would not be used in practice if computational efficiency is important. In addition, centered finite differences takes 2q calls to the objective function per computation of the gradient, where q is the number of parameters. Since SNLLS results in a smaller parameter space, their method of differentiation favors the SNLLS procedure.
It remains to implement a competitive version of SNLLS optimization for SEM using the analytic gradients derived in this paper to be able to do a realistic simulation to investigate whether SNLLS outperforms the LS estimator in practice. However, there is a large body of research concerning the efficient implementation of SNLLS (see, for example, Kaufman, 1975;O'Leary and Rust, 2013); writing competitive software for SNLLS in SEMs would be a research topic on its own. Therefore, we only give simulation results concerning the improvement of convergence rates and the number of iterations in this paper. As noted previously, for the class of models without unknown directed parameters, the estimator of the mean and (co)variance parameters can be computed in a single step. As a result, those models should especially benefit from lower computation times.

An Outlook on Maximum Likelihood Estimation
If the assumption of multivariate normality is tenable, another method of obtaining parameter estimates is maximum likelihood estimation. Here, we briefly discuss to what extent our results may have an impact on maximum likelihood optimization of SEMs. In least squares estimation with a fixed weight matrix, we saw that the undirected parameters θ and the mean parameters θ γ enter the objective linearly. For maximum likelihood estimation, we believe it is not possible to factor out the undirected parameters (for most models used in practice). This is because the likelihood of the normal distribution depends on the inverse of the model-implied covariance matrix. For the simplistic example model depicted in Fig. 5, we derive the model-implied covariance matrix as and the inverse can be computed as where adj refers to the adjugate matrix, so in our example, and −1 = (ω 1 ω l + ω 2 ω l + ω 1 ω 2 ) −1 ω l + ω 2 −ω l −ω l ω l + ω 1 (52) We see that θ enters the determinant and therefore the inverse of in a nonlinear way. In general, the Leibniz Formula for the determinant gives where S m obs denotes the symmetric group. Since this formula multiplies entries of , and we saw in Eq. 30 that the entries of depend on the undirected parameters, it is very likely that those form a product and enter the objective in a nonlinear way. However, for the mean parameters, the picture may be different and we leave this for future work. If the model is saturated (e.g., has zero degrees of freedom), the least squares estimates are the same as the maximum likelihood estimates, since S = (θ ML ) = (θ LS ). Also, Lee and Jennrich (1979) showed that maximum likelihood estimation can be obtained as a form of iteratively reweighted least squares if V is a function of the parameters: where D denotes the duplication matrix from Magnus and Neudecker (2019b). Another way of obtaining ML estimates with SNLLS would therefore be to minimize the SNLLS objective and use the obtained to update the weight matrix V as given in Eq. 54. SNLLS could then be rerun with the updated weight matrix, and the weight matrix be updated again, until converges to (θ ML ). However, we would like to note that this procedure is probably computationally quite inefficient.

Conclusion
We generalized separable nonlinear least squares estimation to all linear structural equation models that can be specified in the RAM notation, particularly those including a mean structure. We explained this result with the help of trek rules and the non-transitivity of the covariances of the error terms, providing deeper insight into the algebraic relations between the parameters of SEMs. We further derived analytic gradients and explained why they are of central importance to obtain a competitive implementation. Our simulation indicates that SNLLS leads to improvements in convergence rate and number of iterations. It remains for future research to investigate the computational costs empirically. We also showed why it is unlikely that undirected parameters enter the maximum likelihood objective linearly. Thus, another line of research could be concerned with the applicability of SNLLS to the mean parameters in maximum likelihood estimation and Appendix B: Constants in To handle constants in different from zero, we introduce c as the vector of constant nonzero entries in and E as the lower triangular indices of c in . Further, define with D defined as in Eq. 36, i.e., the indices of the original position of σ k in . This allows us to modify Eq. 38 to and reformulate the least squares objective as with s = (s − G c c). For a fixed value of θ , we can now again solve for θ .
Appendix C: Gradient of the SNLLS Objective Let a T := s T VG G T VG −1 . We derive the differential as Appendix D: Alternative Proof This is the analogous formulation to the one given in Kreiberg et al. (2021) for CFA models. We see that the resulting expressions contain very large Kronecker products; for reasons of computational efficiency, we therefore favor the expressions given in the main text. Let D + denote the Moore-Penrose inverse of the duplication matrix D m obs from Magnus and Neudecker (2019b) such that and L be a matrix such that vec( ) = L θ (D2) We can obtain L ∈ R m 2 ×dim(θ ) as