18  The SAM approach to SEM

18.1 System-wide versus stepwise estimation

The default estimation strategy in lavaan, and in SEM software in general, is system-wide (or joint) estimation: all the free parameters of the model are estimated simultaneously by minimizing a single discrepancy function (chapter 7), regardless of whether they belong to the measurement part or to the structural part. The Structural After Measurement (SAM) approach (Rosseel & Loh, 2024) takes a different route: the measurement part is estimated first, and only then, with the measurement parameters kept fixed, the structural part. In lavaan, this approach is implemented in the sam() function.

The idea is not new. In factor score regression, factor scores are first computed for each latent variable, and the scores are then used in a regression or path analysis; the measurement part is decoupled from the structural part by design. Used naively, this gives biased structural estimates, but Skrondal and Laake (2001) showed how the bias can be avoided by a suitable choice of the factor scores, and Wall and Amemiya (2000) and, independently, Croon (2002) showed how it can be removed by a correction of the moments of the factor scores (see also Devlieger et al., 2016; Devlieger & Rosseel, 2017). SAM generalizes this line of work: the separation of the measurement part from the structural part becomes the organizing principle of the estimation of a general structural equation model, and factor scores are no longer needed.

A major motivation for the separation is to avoid interpretational confounding (Burt, 1976). In a joint analysis, the estimates of the measurement parameters depend on the structural part: when the structural part is changed, the factor loadings change with it. Since a latent variable takes its meaning from its indicators and their loadings, the latent variables themselves change with the structural model. Strictly speaking, two structural models that are compared in a joint analysis do not relate the same latent variables. In a SAM analysis, the latent variables are defined by their indicators alone, before any structural relation among them is specified, and they keep the same meaning whatever structural model is fitted. The idea of settling the measurement model first is familiar from the two-step modeling strategy of Anderson and Gerbing (1988), but their two steps concern model evaluation, and the final model is still estimated jointly. SAM separates the estimation itself.

The stepwise approach has two additional benefits. First, the model is fitted in parts. Each measurement block is a small factor model with only a few parameters, and given the measurement estimates, the structural part is a small model too. This is an advantage when the sample size is modest, a setting where a joint analysis of a large model often fails to converge or ends in an inadmissible solution (see Section 7.11 and Section 7.11.3). As a by-product, every part comes with its own fit information (Section 18.8). Second, the approach is flexible: each step is an ordinary lavaan analysis, and the measurement blocks and the structural part can be fitted with different estimators and different options.

These benefits come at a cost. Under a correctly specified model, the SAM estimates are consistent, but somewhat less efficient than the joint estimates, and the standard errors and test statistics need their own two-step versions. Nor should SAM be seen as a generally more robust alternative for joint estimation. What SAM guarantees is that the measurement estimates are not affected by the structural part; a misspecification in a measurement block still affects the structural estimates, and Robitzsch (2022) shows that SAM is not always more robust than joint estimation against local misspecifications. Simulation evidence, and practical guidance on when the stepwise approach is advantageous, can be found in Rosseel and Loh (2024) and Dhaene and Rosseel (2023).

SAM is not the only alternative to joint estimation in lavaan. The multi-stage estimators of chapter 17 (the instrumental-variable estimator, the James-Stein estimators and the multiple-group method) do not estimate all the parameters jointly either, but they divide the model along different lines: all the directed effects, factor loadings and regression coefficients alike, are obtained in a first stage (equation by equation for the instrumental-variable and James-Stein estimators), and the variances and covariances in a second stage. The measurement part is never set apart from the structural part, so fitting a full model with, say, estimator = "IV" is not a SAM analysis. The two approaches can be combined, however: the multi-stage estimators can be used to fit the measurement blocks in step 1 of a SAM analysis (Section 18.2.1).

This chapter starts with an illustration of interpretational confounding (Section 18.1.1), and then describes the SAM framework and its two main variants: local SAM (Section 18.3), which fits the structural model to estimated moments of the latent variables, and global SAM (Section 18.4), which re-fits the full model with the measurement parameters held fixed. We discuss the sam() function and its output (Section 18.6), the standard errors that propagate the step-1 uncertainty into step 2 (Section 18.7), and the fit measures and test statistics that are reported for SAM objects (Section 18.8). The small-sample corrections of local SAM are collected in a separate section (Section 18.9). We end with latent interactions (Section 18.10) and a list of the supported settings and current limitations (Section 18.11). All the examples use public functions only; details that are tied to the current implementation are collected in the implementation notes at the end of this chapter (Section 18.12).

18.1.1 A population-level illustration

To see how the structural part can affect the measurement part in a joint analysis, without any sampling noise, we work at the population level. Consider a population with three latent variables, each measured by three indicators with (standardized) loadings 0.8, 0.7, and 0.6. In the population, the structural part contains both indirect and direct effects:

pop <- '
  f1 =~ 0.8*y1 + 0.7*y2 + 0.6*y3
  f2 =~ 0.8*y4 + 0.7*y5 + 0.6*y6
  f3 =~ 0.8*y7 + 0.7*y8 + 0.6*y9
  f2 ~ 0.4*f1
  f3 ~ 0.4*f2 + 0.5*f1
  f1 ~~ 1.00*f1
  f2 ~~ 0.84*f2
  f3 ~~ 0.43*f3
  y1 ~~ 0.36*y1; y2 ~~ 0.51*y2; y3 ~~ 0.64*y3
  y4 ~~ 0.36*y4; y5 ~~ 0.51*y5; y6 ~~ 0.64*y6
  y7 ~~ 0.36*y7; y8 ~~ 0.51*y8; y9 ~~ 0.64*y9
'
Sigma <- fitted(sem(pop, do_fit = FALSE))$cov

The residual variances were chosen so that all latent variables and all indicators have unit variance; Sigma is the population covariance matrix. Suppose now that a researcher fits a model in which the direct effect f3 ~ f1 is omitted: the structural part is misspecified, while the measurement part is correct. We pass the population matrix to both sem() and sam(), using a very large (nominal) sample size so that sampling variability plays no role. Because all the variables have unit variance in the population, we compare the standardized solutions, which do not depend on the way the metric of the latent variables is set:

mod <- '
  f1 =~ y1 + y2 + y3
  f2 =~ y4 + y5 + y6
  f3 =~ y7 + y8 + y9
  f2 ~ f1
  f3 ~ f2
'
fit_sem <- sem(mod, sample_cov = Sigma, sample_nobs = 1e6,
               correlation = FALSE)
fit_sam <- sam(mod, sample_cov = Sigma, sample_nobs = 1e6,
               se = "none", correlation = FALSE)
std_est <- function(fit, op) {
  std <- standardizedSolution(fit, se = FALSE)
  std$est.std[std$op == op]
}
round(cbind(pop = rep(c(0.8, 0.7, 0.6), 3),
            sem = std_est(fit_sem, "=~"),
            sam = std_est(fit_sam, "=~")), 3)
      pop   sem sam
 [1,] 0.8 0.800 0.8
 [2,] 0.7 0.700 0.7
 [3,] 0.6 0.600 0.6
 [4,] 0.8 0.771 0.8
 [5,] 0.7 0.690 0.7
 [6,] 0.6 0.594 0.6
 [7,] 0.8 0.800 0.8
 [8,] 0.7 0.700 0.7
 [9,] 0.6 0.600 0.6

The joint solution has distorted the factor loadings of f2, the latent variable in the middle of the causal chain: the omitted structural path is partially absorbed by the measurement part, and the fitted f2 is no longer the population latent variable. The SAM solution recovers the population loadings exactly, because the measurement blocks were estimated in isolation. The structural estimates show the same pattern:

round(cbind(sem = std_est(fit_sem, "~"),
            sam = std_est(fit_sam, "~")), 3)
       sem sam
[1,] 0.498 0.4
[2,] 0.668 0.6

The two rows contain the coefficients of f2 ~ f1 and f3 ~ f2. For SAM, the coefficient of f2 ~ f1 equals its population value (0.4), and the coefficient of f3 ~ f2 equals 0.6, exactly the population regression coefficient of f3 on f2 alone (i.e., the correct value of the misspecified projection, since \text{Cov}(f_3, f_2)/\text{Var}(f_2) = 0.4 + 0.5 \times 0.4 = 0.6). The misspecification remains confined to the structural part. In the joint solution, both coefficients are too large (the first one by a quarter), and the distortion has spread to the measurement part of the model.

18.2 The SAM framework

Following Rosseel and Loh (2024), we partition the full parameter vector into two subsets:

\boldsymbol{\vartheta}= (\boldsymbol{\vartheta}_1, \boldsymbol{\vartheta}_2), \tag{18.1}

where \boldsymbol{\vartheta}_1 collects the parameters of the measurement part (factor loadings, residual variances and covariances of the indicators, indicator intercepts, and, in the categorical case, thresholds and scaling factors), and \boldsymbol{\vartheta}_2 collects the parameters of the structural part (regression coefficients among the latent variables, their residual variances and covariances, and latent intercepts or means). Estimation proceeds in two steps:

  1. Step 1 (measurement): estimate \boldsymbol{\vartheta}_1 by fitting the measurement model, possibly split into several independent measurement blocks, each of which is a small CFA fitted by any of the standard lavaan estimators.

  2. Step 2 (structural): estimate \boldsymbol{\vartheta}_2, treating \hat{\boldsymbol{\vartheta}}_1 as known (fixed) values.

The two main variants differ only in how step 2 is carried out:

  • Local SAM first converts \hat{\boldsymbol{\vartheta}}_1 and the sample statistics into estimates of the latent moments (the mean vector \mathrm{E}(\boldsymbol{\eta}) and covariance matrix \text{Var}(\boldsymbol{\eta}) of the latent variables), and then fits the structural model directly to these latent summary statistics, as if they were ordinary sample statistics. The observed data are no longer needed in step 2.

  • Global SAM re-fits the full model to the original sample statistics, with all elements of \boldsymbol{\vartheta}_1 fixed at their step-1 values, so that only \boldsymbol{\vartheta}_2 is free.

Two further methods complete the family: sam_method = "fsr" performs naive factor score regression (no bias correction; see Section 18.5), and the experimental sam_method = "cfsr" performs consistent factor score regression, which applies the correction at the casewise level (also discussed in Section 18.5). Local SAM is the default, and the best studied variant.

Whichever variant is used, the final result is assembled into a single joint lavaan object that contains both the step-1 and the step-2 estimates, so that all the familiar extractor functions (summary(), coef(), parameterEstimates(), fitted(), lavInspect(), …) work as usual. The parameter table of this object (see parTable()) carries an extra step column (1 or 2) that records in which step each parameter was estimated, and the SAM-specific information (the measurement blocks, their fit statistics, the fit of the structural part, and the options that were used) is reported by summary().

18.2.1 Measurement blocks

Step 1 need not fit the entire measurement model at once. The measurement part is divided into measurement blocks, and each block is estimated separately. By default, every latent variable has its own block, unless the model forces some factors to be joined: the automatic block detection inspects the matrix \boldsymbol{\Lambda}^{\prime}\,\boldsymbol{\Theta}\,\boldsymbol{\Lambda}, whose nonzero off-diagonal elements indicate factors that are linked through cross-loadings or through residual covariances between their indicators; linked factors are merged into a single block (technically, the connected components of this matrix define the blocks).

The user can override the default via the mm_list argument, which is a list with one element per block; each element contains the names of one or more latent variables. Joining factors in a single block means that their loadings and residual (co)variances are estimated jointly and that the block chi-square statistic tests the fit of that sub-model; keeping them apart means that a misspecification in one block cannot affect the estimates of the other blocks.

A few rules are enforced in step 1:

  • Every block must be identified on its own. The SAM approach estimates each block in isolation, so a block with more free parameters than sample statistics (negative degrees of freedom) triggers an error, even if the full joint model would be identified. The error message suggests simplifying the block, merging blocks via mm_list, or using sem().

  • A single-factor block with only two indicators is not identified unless additional constraints are imposed; in that case sam() fixes both loadings to unity (with a warning).

  • Each block is fitted with bounded estimation: the option bounds = "wide.zerovar" is set by default (see Section 6.2.2), which greatly reduces the chance of inadmissible block solutions in small samples (De Jonckere & Rosseel, 2022). Additional or different options for the measurement blocks only can be passed via the mm_args argument. This includes the estimator: with mm_args = list(estimator = "MGM"), for example, the blocks are fitted with one of the multi-stage estimators of chapter 17.

  • The standard errors of the block parameters are computed per block, with a type that matches the estimator: se = "standard" for plain ML, se = "robust.sem" for MLM and for categorical (DWLS-type) estimation, se = "robust.huber.white" for MLR and PML, and se = "robust.cluster" for clustered data (see Section 8.4.4). These block-level covariance matrices are collected into a block-diagonal matrix \hat{\boldsymbol{\Omega}}_{11} = \text{Var}(\hat{\boldsymbol{\vartheta}}_1), which will be needed for the two-step standard errors in Section 18.7.2.

Higher-order factors are supported: the lower-order factors are absorbed into the block of their higher-order factor, and lavaan removes them by replacing \boldsymbol{\Lambda} with the reduced-form loadings \boldsymbol{\Lambda}(\mathbf{I} - \mathbf{B})^{-1} (restricted to the higher-order columns) and by adding the contribution of the lower-order disturbances to \boldsymbol{\Theta}.

Composites (defined by the <~ operator; see Section 4.4) are supported as well, but they need a block rule of their own. A composite has no reflective measurement model: its weights are only identified by the covariances between its indicators and the other variables in the block, so a measurement block that contains a single composite and nothing else is not identified. For this reason, all the composites of a model are joined in a single measurement block. If the model contains only one composite, sam() stops with an error; the mm_list argument can then be used to place the composite in the same block as (at least) one latent variable. In the local approach, a composite is treated as what it is, an exact function of its indicators: its row in the mapping matrix of Section 18.3.1 contains its weights, no measurement error is removed from its variance (in the summary() output its reliability is reported as one), and in the structural part it behaves as an observed variable.

18.3 Local SAM

Local SAM is the default method (sam_method = "local"), and the theoretically most interesting one. The key insight, going back to Wall and Amemiya (2000) and Croon (2002) (see Section 13.6 in the chapter on factor scores for the history), is that the moments of the latent variables can be expressed in closed form as a function of the measurement parameters and the moments of the observed indicators. Once estimates of \mathrm{E}(\boldsymbol{\eta}) and \text{Var}(\boldsymbol{\eta}) are available, the structural model, which is a path model among the latent variables, can be fitted to these latent statistics with the ordinary SEM estimation routines, as if they were the sample mean vector and covariance matrix of directly observed variables.

18.3.1 The mapping matrix

Consider a measurement block with model \mathbf{y}= \boldsymbol{\nu}+ \boldsymbol{\Lambda}\boldsymbol{\eta}+ \boldsymbol{\epsilon}, \qquad \text{Var}(\boldsymbol{\epsilon}) = \boldsymbol{\Theta}, \tag{18.2} where \mathbf{y} contains the indicators of the block and \boldsymbol{\eta} the latent variables of the block. A mapping matrix \mathbf{M} is any matrix that satisfies

\mathbf{M} \boldsymbol{\Lambda}= \mathbf{I}. \tag{18.3}

Applying \mathbf{M} to the centered indicators produces factor scores \hat{\boldsymbol{\eta}} = \mathbf{M}(\mathbf{y}- \boldsymbol{\nu}), and Equation 18.3 guarantees the decomposition

\hat{\boldsymbol{\eta}} = \mathbf{M}\left(\boldsymbol{\Lambda}\boldsymbol{\eta}+ \boldsymbol{\epsilon}\right) = \boldsymbol{\eta}+ \mathbf{M}\boldsymbol{\epsilon}: \tag{18.4}

the factor scores equal the true latent variables plus a linear combination of the measurement errors. lavaan implements three choices for \mathbf{M}, selected by the m_method element of the local_options argument:

\mathbf{M}_{\text{ML}} = \left(\boldsymbol{\Lambda}^{\prime}\boldsymbol{\Theta}^{-1}\boldsymbol{\Lambda}\right)^{-1} \boldsymbol{\Lambda}^{\prime}\boldsymbol{\Theta}^{-1}, \tag{18.5}

\mathbf{M}_{\text{GLS}} = \left(\boldsymbol{\Lambda}^{\prime}\mathbf{S}^{-1}\boldsymbol{\Lambda}\right)^{-1} \boldsymbol{\Lambda}^{\prime}\mathbf{S}^{-1}, \qquad \mathbf{M}_{\text{ULS}} = \left(\boldsymbol{\Lambda}^{\prime}\boldsymbol{\Lambda}\right)^{-1} \boldsymbol{\Lambda}^{\prime}. \tag{18.6}

All three satisfy Equation 18.3. The default (m_method = "ML") corresponds to Bartlett factor scores, discussed at length in chapter 13; "GLS" replaces the residual covariance matrix by the (unbiased) sample covariance matrix of the indicators; and "ULS" is simply the Moore–Penrose inverse of \boldsymbol{\Lambda}. The popular regression factor scores are not in this list: they do not satisfy Equation 18.3, so the simple bias correction below would not apply to them (see Croon, 2002; Skrondal & Laake, 2001 for the corrections that regression scores would require).

The ML mapping matrix requires inverting \boldsymbol{\Theta}, which fails when some residual variances are (near) zero. In that case lavaan falls back on the T-transformation of Wall and Amemiya (2000), which constructs the same Bartlett-type mapping matrix without ever inverting \boldsymbol{\Theta}, using the marker indicators of each factor; if that fails too, the ULS mapping matrix is used (with a warning). For categorical endogenous indicators, the ML weights are not appropriate and m_method is automatically switched to "ULS".

18.3.2 Estimating the latent moments

Because \boldsymbol{\eta} and \boldsymbol{\epsilon} are uncorrelated, taking variances on both sides of Equation 18.4 and rearranging gives \text{Var}(\hat{\boldsymbol{\eta}}) = \text{Var}(\boldsymbol{\eta}) + \mathbf{M}\boldsymbol{\Theta}\mathbf{M}^{\prime}, and therefore

\widehat{\text{Var}(\boldsymbol{\eta})} = \mathbf{M}\mathbf{S}\mathbf{M}^{\prime} - \mathbf{M}\hat{\boldsymbol{\Theta}}\mathbf{M}^{\prime} = \mathbf{M}\left(\mathbf{S}- \hat{\boldsymbol{\Theta}}\right) \mathbf{M}^{\prime}, \tag{18.7}

where \mathbf{S} is the sample covariance matrix of the indicators and \hat{\boldsymbol{\Theta}} (and the \hat{\boldsymbol{\Lambda}} inside \mathbf{M}) are the step-1 estimates. When the model has a mean structure, the latent means are estimated along the same lines:

\widehat{\mathrm{E}(\boldsymbol{\eta})} = \mathbf{M}\left(\bar{\mathbf{y}}- \hat{\boldsymbol{\nu}}\right). \tag{18.8}

The two building blocks of Equation 18.7 have a simple interpretation: \mathbf{M}\mathbf{S}\mathbf{M}^{\prime} is the covariance matrix of the factor scores, and \mathbf{M}\hat{\boldsymbol{\Theta}}\mathbf{M}^{\prime} is the covariance matrix of the measurement error that contaminates them. The computation is carried out per block. Latent variables from different blocks are combined afterwards: since every block provides the rows of \mathbf{M} for its own factors (with zeros elsewhere), a single latent variance matrix covering all latent variables, including the covariances between factors from different blocks, is obtained from the same formula applied to the full indicator covariance matrix.

Everything in this subsection can be verified with the public extractor functions. As a running example for the remainder of this chapter, we draw a single sample (N= 300) from the population of Section 18.1.1, so that the true values of all the parameters are known. This time, we fit the correctly specified model:

Data <- lavSimulateData(pop, sample_nobs = 300, seed = 1234)

model <- '
  # measurement part
    f1 =~ y1 + y2 + y3
    f2 =~ y4 + y5 + y6
    f3 =~ y7 + y8 + y9
  # structural part
    f2 ~ f1
    f3 ~ f2 + f1
'
fit_sam <- sam(model, data = Data)

The fitted object contains the step-1 estimates of the measurement parameters, so the loadings and the residual variances can be extracted in the usual way, and the mapping matrix follows from Equation 18.5:

est <- lavInspect(fit_sam, "est")
LAMBDA <- est$lambda
THETA  <- est$theta
M <- solve(t(LAMBDA) %*% solve(THETA) %*% LAMBDA) %*%
     t(LAMBDA) %*% solve(THETA)
round(M, 3)
     y1    y2    y3    y4    y5    y6    y7    y8    y9
f1 0.55 0.307 0.247 0.000 0.000 0.000 0.000 0.000 0.000
f2 0.00 0.000 0.000 0.819 0.173 0.112 0.000 0.000 0.000
f3 0.00 0.000 0.000 0.000 0.000 0.000 0.523 0.327 0.255
max(abs(M %*% LAMBDA - diag(3)))  # M Lambda = I
[1] 1.110223e-16

The mapping matrix has one row per latent variable and one column per observed indicator; note its block structure (every factor has its own measurement block here, so the row of f1 only involves y1–y3, and so on). Because the ML mapping matrix is the factor score matrix of the Bartlett method, lavPredict() returns the same matrix:

fs <- lavPredict(fit_sam, method = "Bartlett", fsm = TRUE)
max(abs(attr(fs, "fsm")[[1]] - M))
[1] 2.220446e-16

Next, we compute the two building blocks of Equation 18.7 and their difference:

S <- lavInspect(fit_sam, "sampstat")$cov
var_fs  <- M %*% S %*% t(M)        # covariance matrix of the factor scores
var_err <- M %*% THETA %*% t(M)    # the measurement error part
var_eta <- var_fs - var_err
round(var_eta, 3)
      f1    f2    f3
f1 0.692 0.341 0.442
f2 0.341 0.846 0.469
f3 0.442 0.469 0.680

This is indeed the matrix that step 2 has used. The structural model of step 2 is itself a fitted lavaan object, which can be extracted with lavInspect(); its “sample statistics” are the estimated latent moments:

fit_struc <- lavInspect(fit_sam, "sam_struc_fit_object")
max(abs(lavInspect(fit_struc, "sampstat")$cov - var_eta))
[1] 5.551115e-17

The ratio of the diagonal elements of \widehat{\text{Var}(\boldsymbol{\eta})} and \mathbf{M}\mathbf{S}\mathbf{M}^{\prime} is the model-based reliability of the factor scores: the proportion of factor-score variance that is due to the true latent variable rather than to measurement error. These values are printed in the summary() header of a SAM object (see Section 18.6.1):

round(diag(var_eta) / diag(var_fs), 3)
   f1    f2    f3 
0.785 0.862 0.769 

When the model contains a mean structure, the latent means are computed from Equation 18.8; in a default single-group analysis (with saturated, freely estimated indicator intercepts) the estimated latent means are zero, but they become informative in multiple-group settings with cross-group intercept constraints.

One caveat remains. Nothing guarantees that the difference in Equation 18.7 is positive definite: in small samples, or when the reliability is low, the subtracted measurement error part can be too large. By default, lavaan guards against this with a small-sample correction that leaves the result untouched in the vast majority of analyses (the running example included). This safeguard, and two further small-sample devices, are discussed in Section 18.9.

18.3.3 Fitting the structural model

Step 2 of local SAM takes the structural part of the model, and fits it with an ordinary lavaan call in which the estimated latent moments play the role of the data. For the running example, we can do this by hand: the structural part is a path model among f1, f2 and f3, and the latent variance matrix is available from the structural fit object:

model_struc <- '
    f2 ~ f1
    f3 ~ f2 + f1
'
var_eta <- lavInspect(fit_struc, "sampstat")$cov
fit_byhand <- sem(model_struc, sample_cov = var_eta, sample_nobs = 300,
                  sample_cov_rescale = FALSE)
round(rbind(byhand = coef(fit_byhand),
            sam    = coef(fit_sam)[names(coef(fit_byhand))]), 3)
       f2~f1 f3~f2 f3~f1 f2~~f2 f3~~f3
byhand 0.493  0.37 0.457  0.678  0.304
sam    0.493  0.37 0.457  0.678  0.304

This is the “fitting a model to summary statistics” mode of Section 5.2, with two special ingredients. The “sample” covariance matrix is the estimated latent variance matrix (with the estimated latent means as the “sample” means if the model has a mean structure). And, whenever it can be computed, sam() also supplies (via the nacov argument) the estimated asymptotic covariance matrix of the latent statistics themselves, \hat{\boldsymbol{\Gamma}}_{\boldsymbol{\eta}}, which drives the corrected test statistic (Section 18.8.1) and several of the standard error methods (Section 18.7). Our by-hand fit leaves this ingredient out, so its standard errors and test statistic are the naive ones.

This example deserves attention beyond its role in SAM, because it is a template. Everything sam() does is, in the end, expressed through lavaan’s public interface: parameter tables are subsetted and refitted, moments and their asymptotic covariance matrices are passed to an ordinary lavaan call, and the results are assembled back into a parameter table. Nothing in the statistical logic requires access to lavaan’s internals. In that sense, sam() is an example of how new methods can be built on top of lavaan rather than inside it. This is the pattern that is recommended in Section 20.2.

The default estimator in this step is ML; alternative options for the structural fit only can be passed via the struc_args argument. They are processed exactly like the options of lavaan() itself (aliases and both spellings of the names included) and take precedence over the common options given as top-level arguments of sam(). Observed exogenous covariates that appear in the structural part are carried along in the latent variance matrix as (pseudo-)latent variables, exactly as described in Section 4.3.4.

Note that the structural model must be identified from the latent moments alone: step 2 uses only the latent variance matrix (and the latent means), so it cannot obtain identification from the measurement part the way a joint model sometimes can (e.g., a non-recursive system without instruments). If the structural part has more free parameters than there are latent moments, sam() stops with an explicit error message.

With std_lv = TRUE, the latent variables are standardized in step 1, and the latent variance matrix that enters step 2 is a correlation matrix. In the structural part, the variances of the exogenous latent variables then stay fixed to one, so that the latent covariances are correlations, also when the structural part restricts them (a covariance that is fixed to a value, or equality constraints among the covariances). The unit variances are not counted as sample statistics (they are one by construction), and the degrees of freedom of the structural part are the same as in the marker-variable metric. For an endogenous latent variable, only the total variance equals one: its residual variance is an ordinary free parameter of step 2, and it is reported with a standard error.

18.4 Global SAM

With sam_method = "global", step 1 is identical, but step 2 returns to the original sample statistics: the full model is re-fitted with all measurement parameters fixed at their step-1 values \hat{\boldsymbol{\vartheta}}_1, so that only the structural parameters are free. The estimation now uses the joint discrepancy function F(\mathbf{s}, \boldsymbol{\sigma}(\boldsymbol{\vartheta})(\hat{\boldsymbol{\vartheta}}_1, \boldsymbol{\vartheta}_2)), minimized over \boldsymbol{\vartheta}_2 only.

Local and global SAM generally give very similar (but not identical) structural estimates; when the structural part is saturated, the two coincide (up to convergence tolerance), because the joint model can then reproduce any admissible latent variance matrix. Differences appear when the structural part is restricted: local SAM minimizes a discrepancy in the space of latent moments, while global SAM weighs the residuals at the level of the observed moments. Global SAM has two practical drawbacks: it is not available in closed form (a full nonlinear optimization over \boldsymbol{\vartheta}_2 is still needed, although it is much smaller and better behaved than the system-wide one), and there is no natural notion of “fit of the structural part given the measurement part”: fitMeasures() reports the usual statistics of the joint model, with a warning that their behavior under two-step estimation has not been studied. On the other hand, global SAM imposes no rank conditions on \boldsymbol{\Lambda}.

For model testing, global SAM has its own corrected statistic: the rescaled test of Yuan and Chan (2002), requested as test = "yuan.chan", which is the default for sam_method = "global" (see Section 18.8.3).

18.5 Relation to factor score regression

Setting sam_method = "fsr" skips the bias correction: the structural model is fitted to the variance matrix of the factor scores themselves,

\widehat{\text{Var}(\hat{\boldsymbol{\eta}})} = \mathbf{M}\mathbf{S}\mathbf{M}^{\prime}, \tag{18.9}

which, by Equation 18.4, overestimates the latent variances by \mathbf{M}\boldsymbol{\Theta}\mathbf{M}^{\prime}. This is naive factor score regression with Bartlett scores (when m_method = "ML"): the well-known result that regressions among factor scores are biased, attenuated or inflated depending on the score type and on which side of the equation the scores appear (Croon, 2002; Devlieger et al., 2016; Skrondal & Laake, 2001), applies in full, and Section 13.6 (in the chapter on factor scores) discusses this bias in detail. The option exists mainly for pedagogical and benchmarking purposes; there is no good reason to use it in applied work. Note the sequence of equivalences: naive FSR (Equation 18.9) is local SAM without the subtraction of the measurement error part, and local SAM is therefore exactly factor score regression with the Wall–Amemiya/Croon correction, applied blockwise and embedded in the general SEM framework. The alpha_correction option (Section 18.9.2) interpolates between the two extremes.

The experimental sam_method = "cfsr" produces corrected results via a different computational route, the consistent factor score regression of Bogaert et al. (2026): it transforms the mapping matrix by the correlation-preserving transformation for Bartlett-type scores (the same transformation that implements the transform = TRUE option of lavPredict()), such that the covariance matrix of the resulting corrected factor scores estimates \text{Var}(\boldsymbol{\eta}) directly. This is useful when actual casewise scores with the right covariance structure are needed, but for ordinary SAM analyses it offers no advantage over sam_method = "local".

18.6 The sam() function

A typical call to sam() names the model and the data and, at most, a few arguments. As an example, we use a well-known real dataset: the industrialization and political democracy example (Bollen, 1989), with three latent variables and a small sample (N= 75):

model_pd <- '
  # measurement part
    ind60 =~ x1 + x2 + x3
    dem60 =~ y1 + a*y2 + b*y3 + c*y4
    dem65 =~ y5 + a*y6 + b*y7 + c*y8
  # structural part
    dem60 ~ ind60
    dem65 ~ ind60 + dem60
  # residual covariances
    y1 ~~ y5
    y2 ~~ y4 + y6
    y3 ~~ y7
    y4 ~~ y8
    y6 ~~ y8
'

The call below spells out the arguments that matter most; except for mm_list, they are set to their current default values:

fit_pd <- sam(model_pd, data = PoliticalDemocracy,
              sam_method = "local",
              mm_list    = list(ind = "ind60", dem = c("dem60", "dem65")),
              mm_args    = list(bounds = "wide.zerovar"),
              struc_args = list(estimator = "ML"),
              se         = "default")

We use two measurement blocks, one for ind60, and one joint block for dem60 and dem65 (which are linked by correlated residuals, so the automatic detection would join them as well). The sam_method argument selects the variant: "local", "global", "fsr", or the experimental "cfsr". The mm_list argument defines the measurement blocks as a list of latent variable names (Section 18.2.1); when it is omitted, the blocks are detected automatically, with one block per set of linked factors. The next two arguments are lists of lavaan options that apply to one step only: mm_args to the measurement blocks of step 1, and struc_args to the structural fit of step 2. Any other lavaan option (see lavOptions()) can be given directly in the call, and then applies to both steps. The se argument selects the standard errors of the structural parameters; its default chooses a method that suits the analysis at hand, here the local standard errors (Section 18.7).

The remaining arguments are introduced where they are needed, and ?sam lists them all. The most important one is local_options, a list that collects the settings of local SAM: the mapping matrix (m_method, Section 18.3.1), the lambda correction (lambda_correction, lambda1_floor and lambda2_floor, Section 18.9.1), the alpha correction (alpha_correction, Section 18.9.2), the correction for the attenuation of the latent correlations (bias_correction, Section 18.9.3), and a few settings for two-level models and latent interactions (Section 18.11 and Section 18.10); an example of its use is given in Section 18.9.1. The bootstrap argument holds the settings that are used when se = "bootstrap". All argument names, and the element names of the list-valued arguments as well, use underscores.

18.6.1 The summary output

We return to our running example:

summary(fit_sam)
This is lavaan 0.7-4 -- using the SAM approach to SEM

  SAM method                                     Local
  Mapping matrix M method                           ML
  Number of measurement blocks                       3
  Estimator measurement part                        ML
  Estimator structural part                         ML

  Number of observations                           300

Summary Information Measurement + Structural:

  Block Latent Nind Chisq Df
      1     f1    3     0  0
      2     f2    3     0  0
      3     f3    3     0  0

  Model-based reliability latent variables:

     f1    f2    f3
  0.785 0.862 0.769

  Summary Information Structural part:

  chisq df pvalue cfi rmsea srmr
      0  0     NA   1     0    0

Parameter Estimates:

  Standard errors                                Local
  Information                                 Expected
  Information bread                           Observed
  Information saturated (h1) model          Structured

Regressions:
                   Estimate  Std.Err  z-value  P(>|z|)
  f2 ~                                                
    f1                0.493    0.084    5.844    0.000
  f3 ~                                                
    f2                0.370    0.070    5.308    0.000
    f1                0.457    0.076    6.057    0.000

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)
    f1                0.692    0.102    6.812    0.000
   .f2                0.678    0.126    5.370    0.000
   .f3                0.304    0.070    4.362    0.000

The output differs from a regular sem() summary in several places. The banner reports the SAM approach, and a SAM-specific header block reports the SAM method, the mapping matrix method, the number of measurement blocks, and the estimators used in each step. Next comes a block-by-block table with the local fit of each measurement block: the number of indicators, and the block’s own chi-square statistic and degrees of freedom. Here, the table is not very informative: every block is a just-identified one-factor model with three indicators (zero degrees of freedom). A more informative table is shown below.

The Model-based reliability latent variables line reports the reliabilities of the factor scores that we computed by hand in Section 18.3.2. Low values (say, below 0.6) signal blocks whose factor scores are noisy; the bias correction is then substantial, and the small-sample corrections of Section 18.9.1 and Section 18.9.2 become relevant.

Between the reliabilities and the next block, a note appears when the predicted small-sample attenuation of a latent correlation (Section 18.9.3) is at least 0.05 in absolute value; here, with reasonably reliable indicators and 300 observations, there is none.

The Summary Information Structural part block reports fit measures for the structural model given the measurement part; in this example the structural part is saturated (three regression coefficients plus three (residual) variances exhaust the six latent moments), so the fit is trivially perfect. Section 18.8 discusses these quantities for a restricted structural model.

Finally, the parameter estimates table is printed as usual. The Standard errors Local line signals that the standard errors of the structural parameters account for step-1 uncertainty, and the Information bread line belongs to this type of standard errors (Section 18.7.1). The measurement parameters display their step-1 (block-level) standard errors.

Two elements of the header are only informative in less favorable circumstances. For the political democracy example, the header (the argument estimates = FALSE suppresses the table with the parameter estimates) looks as follows:

summary(fit_pd, estimates = FALSE)
This is lavaan 0.7-4 -- using the SAM approach to SEM

  SAM method                                     Local
  Mapping matrix M method                           ML
  Number of measurement blocks                       2
  Estimator measurement part                        ML
  Estimator structural part                         ML

  Number of observations                            75

Summary Information Measurement + Structural:

  Block      Latent Nind Chisq Df
      1       ind60    3  0.00  0
      2 dem60,dem65    8 15.32 16

  Model-based reliability latent variables:

  ind60 dem60 dem65
  0.973 0.895 0.895

  Note: the lambda truncation engaged (lambda.star = 0.802)

  Summary Information Structural part:

  chisq df pvalue cfi rmsea srmr
      0  0     NA   1     0    0

The block table is now informative: the ind60 block is again just-identified, but the joint dem60/dem65 block has a chi-square of 15.3 on 16 degrees of freedom: the measurement part fits well, and we know this before any structural assumption enters the analysis. In addition, a Note is printed: in this small sample, the safeguard that keeps the latent variance matrix positive definite (the lambda correction of Section 18.9.1) was needed. The note reports the multiplier \lambda^{\star} that was used. A single line means that the truncation has little practical consequence for the regression coefficients (this is the benign case of an almost perfectly predicted latent outcome, dem65); if the consequences are substantial, the note warns that the structural estimates may be biased, and shows the two diagnostics that are explained in Section 18.9.1. When no truncation engaged, which is the usual case, the note is absent.

18.6.2 Comparing the methods

For a correctly specified model, the SAM estimates hardly differ from the system-wide ones. This is to be expected, since all methods are consistent under correct specification:

fit_global <- sam(model, data = Data, sam_method = "global")
fit_fsr    <- sam(model, data = Data, sam_method = "fsr")
fit_sem    <- sem(model, data = Data)

extract <- function(fit) {
  pe <- parameterEstimates(fit)
  pe <- pe[pe$op == "~", ]
  out <- sprintf("%5.3f (%5.3f)", pe$est, pe$se)
  names(out) <- paste0(pe$lhs, "~", pe$rhs)
  out
}
data.frame(pop    = c(0.4, 0.4, 0.5),
           local  = extract(fit_sam),
           global = extract(fit_global),
           fsr    = extract(fit_fsr),
           sem    = extract(fit_sem))
      pop         local        global           fsr           sem
f2~f1 0.4 0.493 (0.084) 0.493 (0.081) 0.387 (0.062) 0.501 (0.077)
f3~f2 0.4 0.370 (0.070) 0.370 (0.076) 0.350 (0.047) 0.397 (0.072)
f3~f1 0.5 0.457 (0.076) 0.457 (0.082) 0.367 (0.051) 0.430 (0.076)

Local and global SAM agree to all printed digits (the structural part is saturated; see Section 18.4), and both are close to the sem() solution; the differences with the population values (which can be compared directly, because all the marker indicators have the same population loading) are well within sampling error. The naive FSR estimates, however, are visibly attenuated: all three coefficients are smaller than those of the three consistent methods fitted to the very same sample, most clearly for f3 ~ f1 (0.367, against 0.43–0.46 for the other methods, and a population value of 0.5), although the measurement quality is decent (reliabilities around 0.77–0.86). A single sample can be misleading, though: for f2 ~ f1, where the consistent methods happen to be too large in this sample, the attenuated FSR estimate is closest to the population value. It is the systematic downward bias that makes naive FSR inconsistent, and with less reliable indicators this bias becomes large.

18.7 Standard errors

The se argument of sam() has its own set of options, listed in Table 18.1. The central issue is always the same: the step-2 estimates \hat{\boldsymbol{\vartheta}}_2 depend on the step-1 estimates \hat{\boldsymbol{\vartheta}}_1, and standard errors that ignore the sampling variability of \hat{\boldsymbol{\vartheta}}_1 are too small.

Table 18.1: Options for the se argument of sam().
se= Description
"default" The current default: "local" whenever the local standard errors are available, "local.nt" when only summary statistics are provided, and "twostep" otherwise (global SAM in particular)
"local" Sandwich standard errors computed entirely in the structural space, using \hat{\boldsymbol{\Gamma}}_{\boldsymbol{\eta}} (Equation 18.10); local methods only; the only two-step-corrected option for PML and for latent interactions
"local.nt" As "local", but with the normal-theory \hat{\boldsymbol{\Gamma}}^{\mathrm{NT}}
"twostep" Classic two-step correction based on the joint (expected) information matrix; assumes the distributional assumptions of the estimator hold; replaced by "local" when the plug-in bias correction of the latent correlations was applied (Section 18.9.3)
"twostep.robust" Robust (sandwich) two-step correction along the lines of Yuan and Chan (2002), using the ADF \hat{\boldsymbol{\Gamma}}; automatic replacement for "twostep" with categorical data, clustered data, conditional_x = TRUE, or measurement blocks that are fitted with a multi-stage estimator (IV, JS, JSA, MGM)
"twostep.huber.white" Experimental casewise-score variant (stacked Murphy–Topel-type sandwich); continuous ML data, single level, no equality constraints; falls back to "twostep.robust"/"twostep" otherwise
"naive" Standard errors of the step-2 structural fit, treating the estimated latent moments as observed data; step-1 uncertainty ignored
"standard" (1/N)\,\mathbf{I}_{22}^{-1} from the joint information matrix; step-1 uncertainty ignored
"bootstrap" Nonparametric bootstrap of the entire two-step procedure (whole clusters are resampled when the data are clustered); see the bootstrap argument
"none" No standard errors

The current default, se = "default", is resolved according to the setting. The local standard errors (se = "local", Section 18.7.1) are used whenever they are available, which includes the local approach with complete or incomplete, continuous or categorical, single-group or multiple-group, and clustered data. They do not rely on normality, and they remain valid when the measurement model is misspecified; in simulations, they were closer to the empirical standard deviations of the estimates than the classic two-step standard errors when the data are not normal or when the measurement model is misspecified (an omitted cross-loading, for example), and they had better coverage in small samples. When only summary statistics are provided (and no nacov argument), the normal-theory variant se = "local.nt" is used. The classic two-step standard errors (se = "twostep", Section 18.7.2) are the default for global SAM, and for the settings where the covariance matrix of the latent statistics is not available in lavaan 0.7-4 (two-level models with multiple groups, missing data or categorical data). In earlier versions of lavaan, the default was se = "twostep" in all settings; a call with an explicit se = "twostep" still gives those standard errors. The Standard errors line in the summary() output always shows the method that was used.

18.7.1 Local standard errors

The local standard errors (se = "local") stay entirely within the structural space. They rest on the estimated asymptotic covariance matrix of the latent statistics (\widehat{\mathrm{E}(\boldsymbol{\eta})}, \mathrm{vech}(\widehat{\text{Var}(\boldsymbol{\eta})})), which lavaan computes at the end of step 1. Since these statistics are a (differentiable) function of the observed sample statistics \mathbf{s} (through Equation 18.7, Equation 18.8, and the step-1 estimator \hat{\boldsymbol{\vartheta}}_1(\mathbf{s})), the delta method gives

\hat{\boldsymbol{\Gamma}}_{\boldsymbol{\eta}} = \mathbf{J}\, \hat{\boldsymbol{\Gamma}} \, \mathbf{J}^{\prime}, \qquad \mathbf{J} = \frac{\partial\, (\widehat{\mathrm{E}(\boldsymbol{\eta})}, \mathrm{vech}(\widehat{\text{Var}(\boldsymbol{\eta})}))} {\partial\, \mathbf{s}^{\prime}}, \tag{18.10}

where \hat{\boldsymbol{\Gamma}} is the (by default unbiased, ADF) sample estimate of the asymptotic covariance matrix of \mathbf{s} (see Section 8.3). The jacobian \mathbf{J} is available analytically. Like the latent moments themselves, the matrix \hat{\boldsymbol{\Gamma}}_{\boldsymbol{\eta}} is passed on to the structural fit, where it can be inspected (for the running example, with the structural fit object of Section 18.3.2):

round(lavInspect(fit_struc, "gamma"), 3)
       f1~~f1 f1~~f2 f1~~f3 f2~~f2 f2~~f3 f3~~f3
f1~~f1  3.091                                   
f1~~f2  0.679  0.939                            
f1~~f3  1.064  0.481  0.983                     
f2~~f2  0.491  0.395  0.281  4.548              
f2~~f3  0.186  0.503  0.492  0.929  1.034       
f3~~f3  0.353  0.396  1.070  0.147  1.235  3.518

The structural fit of step 2 thus receives \hat{\boldsymbol{\Gamma}}_{\boldsymbol{\eta}} as the asymptotic covariance matrix of its “sample” statistics, so its own se = "robust.sem" sandwich

\widehat{\text{Var}}(\hat{\boldsymbol{\vartheta}}_2) = \frac{1}{N} \left(\hat{\boldsymbol{\Delta}}_{s}^{\prime}\mathbf{W}_{s}\hat{\boldsymbol{\Delta}}_{s}\right)^{-1} \hat{\boldsymbol{\Delta}}_{s}^{\prime}\mathbf{W}_{s}\, \hat{\boldsymbol{\Gamma}}_{\boldsymbol{\eta}}\, \mathbf{W}_{s}\hat{\boldsymbol{\Delta}}_{s} \left(\hat{\boldsymbol{\Delta}}_{s}^{\prime}\mathbf{W}_{s}\hat{\boldsymbol{\Delta}}_{s}\right)^{-1} \tag{18.11}

(with \hat{\boldsymbol{\Delta}}_s and \mathbf{W}_s the jacobian and weight matrix of the structural model with respect to the latent moments) is a valid estimate of the step-2 covariance matrix, including the step-1 uncertainty, because \hat{\boldsymbol{\Gamma}}_{\boldsymbol{\eta}} already contains it. As written, the bread of Equation 18.11 is the expected information of the structural model. In lavaan, however, the bread is based on the observed information (the Hessian of the structural fit function) by default, for the same reason as in the categorical setting (Section 14.5.6): the expected bread is only correct if the structural model fits perfectly. Whenever the structural model restricts the moments of an equation’s own predictors (for example, two endogenous predictors without a residual covariance), the expected bread understates the sampling variability under misspecification, while the observed bread remains correct. If every equation reproduces the moments of its own predictors (for example, when all the predictors are exogenous), the two breads coincide and nothing changes. The expected bread remains available via struc_args = list(information_bread = "expected"), and summary() reports the bread that was used (Section 8.4.4).

This route linearizes the actual local two-step estimator rather than the joint one, and it is the required (and only) two-step-corrected option in settings where the joint information matrix does not describe the local estimator: latent interaction models, PML estimation, and two-level local SAM (single-group, continuous, complete data). Under conditional_x = TRUE, the "twostep.robust" option is computed through this same structural-space sandwich and coincides with se = "local". The variant se = "local.nt" replaces the ADF \hat{\boldsymbol{\Gamma}} inside Equation 18.10 by its normal-theory counterpart.

The local standard errors imply fixed_x = FALSE: if the structural part contains observed exogenous covariates, their variances and covariances are shown as free parameters, with standard errors. The point estimates are not affected.

With std_lv = TRUE, the jacobian \mathbf{J} of Equation 18.10 includes the standardization of the latent variables, and the unit variances are treated as constants. The local standard errors of the structural coefficients are then identical to the standard errors that standardizedSolution() reports for the same model in the marker-variable metric (fitted with se = "local").

18.7.2 The classic two-step correction

The option se = "twostep", the default for global SAM, implements the classic correction for two-stage estimation. Let \mathbf{I}(\boldsymbol{\vartheta}) denote the (unit, expected) information matrix of the joint model, evaluated at the SAM estimates, and partition it according to Equation 18.1:

\mathbf{I} = \begin{pmatrix} \mathbf{I}_{11} & \mathbf{I}_{12} \\ \mathbf{I}_{21} & \mathbf{I}_{22} \end{pmatrix}, \tag{18.12}

where the indices 1 and 2 refer to the step-1 (measurement) and step-2 (structural) parameters, respectively. If \boldsymbol{\vartheta}_1 were truly known, the covariance matrix of \hat{\boldsymbol{\vartheta}}_2 would be estimated by

\mathbf{V}_2 = \frac{1}{N}\,\mathbf{I}_{22}^{-1} \tag{18.13}

(this is what se = "standard" reports). Because \hat{\boldsymbol{\vartheta}}_1 is estimated, a linearization of the step-2 estimating equations around the true \boldsymbol{\vartheta}_1 adds a second component that propagates the step-1 covariance matrix \hat{\boldsymbol{\Omega}}_{11} = \widehat{\text{Var}}(\hat{\boldsymbol{\vartheta}}_1) (the block-diagonal matrix assembled in step 1; see Section 18.2.1) through the cross-information \mathbf{I}_{21}:

\mathbf{V}_1 = \mathbf{I}_{22}^{-1} \, \mathbf{I}_{21}\, \hat{\boldsymbol{\Omega}}_{11}\, \mathbf{I}_{12} \, \mathbf{I}_{22}^{-1}, \tag{18.14}

and the reported covariance matrix of the structural estimates is

\widehat{\text{Var}}(\hat{\boldsymbol{\vartheta}}_2) = \mathbf{V}_2 + \mathbf{V}_1. \tag{18.15}

Since \mathbf{V}_1 is positive semidefinite, the two-step standard errors are never smaller than the "standard" ones; the difference grows with the measurement uncertainty. When the structural part contains equality constraints, \mathbf{I}_{22}^{-1} is replaced by the constraint-augmented inverse (the same device as in Section 7.7).

One setting needs a more general formula. The decomposition in Equation 18.15 assumes that the step-2 estimating equations and the step-1 estimates are uncorrelated. With std_lv = TRUE and regressions among the latent variables, this no longer holds: the total variance of an endogenous latent variable is a function of the structural parameters, and the step-1 estimates are expressed in that scale. For se = "twostep", lavaan then uses the stacked formula of Section 18.7.3, which keeps the cross-term between the two steps, but with the normal-theory version of \hat{\boldsymbol{\Gamma}} (evaluated at the model-implied moments) instead of the ADF estimate. This is still a normal-theory two-step correction, but it is no longer the sum of two positive semidefinite terms, and a two-step standard error can be slightly smaller than the "standard" one. The general formula is used for continuous, single-level data (complete, or with missing = "ml") and ML estimation; in the other settings, the classic formula is retained.

The two components of Equation 18.15 can be separated by fitting the model twice, once with se = "standard" and once with se = "twostep"; the correction term is what the second adds to the first:

fit_sam_std <- sam(model, data = Data, se = "standard")
fit_sam_two <- sam(model, data = Data, se = "twostep")
pt  <- parTable(fit_sam_two)
idx <- which(pt$step == 2 & pt$free > 0)   # the structural parameters
se_standard <- parTable(fit_sam_std)$se[idx]
se_twostep  <- pt$se[idx]
data.frame(par        = paste0(pt$lhs, pt$op, pt$rhs)[idx],
           standard   = round(se_standard, 3),
           correction = round(sqrt(se_twostep^2 - se_standard^2), 3),
           twostep    = round(se_twostep, 3))
     par standard correction twostep
1  f2~f1    0.073      0.034   0.081
2  f3~f2    0.059      0.047   0.076
3  f3~f1    0.069      0.043   0.082
4 f1~~f1    0.072      0.075   0.104
5 f2~~f2    0.070      0.093   0.116
6 f3~~f3    0.046      0.044   0.064

The step-1 correction is far from negligible here: for the regression coefficient f3 ~ f2, ignoring the correction term (0.047) would understate the standard error by more than a fifth (0.059 instead of 0.076), and for the (residual) variances the correction term is about as large as the standard term. A side-by-side comparison of the naive, the two-step and the (default) local standard errors for the structural regression coefficients makes the same point:

fit_naive <- sam(model, data = Data,
                 se = "naive")
se_of <- function(fit) {
  pe <- parameterEstimates(fit)
  pe$se[pe$op == "~"]
}
data.frame(par     = c("f2~f1", "f3~f2", "f3~f1"),
           naive   = round(se_of(fit_naive), 3),
           twostep = round(se_of(fit_sam_two), 3),
           local   = round(se_of(fit_sam), 3),
           sem     = round(se_of(fit_sem), 3))
    par naive twostep local   sem
1 f2~f1 0.057   0.081 0.084 0.077
2 f3~f2 0.039   0.076 0.070 0.072
3 f3~f1 0.043   0.082 0.076 0.076

The naive standard errors are much too small: they treat the latent variables as if they were observed without error. The two-step and the local standard errors, by contrast, are close to each other and to the system-wide sem() ones, as the theory predicts for normal data and a correctly specified model (Rosseel & Loh, 2024).

18.7.3 The robust two-step correction

The classic correction assumes that the (expected) information matrix correctly describes the sampling variability of both steps (essentially, multivariate normality for ML). The robust variant se = "twostep.robust" drops that assumption, following the estimating equations approach of Yuan and Chan (2002). Three additional ingredients are computed:

  • \mathbf{P} = \partial \hat{\boldsymbol{\vartheta}}_1 / \partial \mathbf{s}^{\prime}, the influence of the sample statistics on the step-1 estimates, assembled block by block;

  • the ADF estimate \hat{\boldsymbol{\Gamma}} of the asymptotic covariance matrix of the sample statistics (Section 8.3);

  • the robust “meat” pieces \mathbf{V}_{22} = \hat{\boldsymbol{\Delta}}_2^{\prime}\mathbf{W} \hat{\boldsymbol{\Gamma}}\mathbf{W}\hat{\boldsymbol{\Delta}}_2, \mathbf{V}_{21} = \hat{\boldsymbol{\Delta}}_2^{\prime}\mathbf{W} \hat{\boldsymbol{\Gamma}}\mathbf{P}^{\prime} and \mathbf{V}_{11} = \mathbf{P}\hat{\boldsymbol{\Gamma}}\mathbf{P}^{\prime}, where \hat{\boldsymbol{\Delta}}_2 contains the structural columns of the joint model jacobian and \mathbf{W} is the weight matrix of the estimator.

These replace the information-matrix-based quantities in Equation 18.13 and Equation 18.14 by their sandwich counterparts, exactly as se = "robust.sem" generalizes se = "standard" in the one-step setting (Section 8.4.4). In several settings, sam() automatically replaces "twostep" by "twostep.robust" because the classic formula is known to be invalid there: with categorical data (where the model-based information understates the variability of the DWLS estimator), with single-level clustered data (cluster=), with conditional_x = TRUE combined with a local method, and when the measurement blocks are fitted with one of the multi-stage estimators of chapter 17 (the classic formula assumes that the blocks are estimated by ML). The experimental se = "twostep.huber.white" computes the same stacked sandwich with a casewise-score meat (the two-step analogue of se = "robust.huber.white") and is currently limited to continuous single-level ML settings (complete data or missing = "ml") without equality constraints.

The standard errors of local SAM were evaluated in the simulation studies of Can and Rosseel (2025). With normal data, the classic two-step standard errors perform well. With nonnormal data they are biased, in particular in smaller samples. The robust two-step standard errors reduce this bias in larger samples, but some underestimation remains in small samples and under misspecification; in those settings, the nonparametric bootstrap (Section 18.7.4) was the most reliable option.

18.7.4 Bootstrap standard errors

Finally, se = "bootstrap" resamples the data and re-runs the entire two-step procedure on each bootstrap sample, which automatically captures the step-1 uncertainty at the cost of computation time:

fit_boot <- sam(model, data = Data,
                se = "bootstrap", bootstrap = list(R = 1000L))

When the data are clustered, whole clusters are resampled. The bootstrap argument also accepts a single number, which is interpreted as R.

18.8 Model fit for SAM objects

Because a local SAM analysis never fits the joint model, the usual global chi-square statistic does not exist. Instead, the natural object of interest is the fit of the structural part, conditional on the (fixed) measurement model of step 1. To make this concrete, we deliberately misspecify the structural part of the running example by omitting the direct path f3 ~ f1, the same misspecification that we studied at the population level in Section 18.1.1:

model_res <- '
    f1 =~ y1 + y2 + y3
    f2 =~ y4 + y5 + y6
    f3 =~ y7 + y8 + y9
    f2 ~ f1
    f3 ~ f2          # the path f1 -> f3 is omitted
'
fit_res <- sam(model_res, data = Data)

18.8.1 The corrected structural test

The structural fit of step 2 produces a chi-square statistic with one degree of freedom (six latent moments minus five free structural parameters). But its “standard” version is not asymptotically chi-square distributed: it treats the estimated latent variance matrix as if it were the sample covariance matrix of N direct observations on the latent variables, ignoring both the measurement error adjustment and the step-1 estimation uncertainty that this matrix contains.

The remedy uses a quantity that was introduced above: the matrix \hat{\boldsymbol{\Gamma}}_{\boldsymbol{\eta}} of Equation 18.10, the estimated asymptotic covariance matrix of the latent statistics, which is also behind the local standard errors (Section 18.7.1). The standard structural statistic is rescaled by the Satorra–Bentler correction of Section 8.5.4, but now the “\boldsymbol{\Gamma}” in the scaling factor is \hat{\boldsymbol{\Gamma}}_{\boldsymbol{\eta}}, so the correction absorbs the step-1 uncertainty. This corrected structural test is computed by default for sam_method = "local" whenever \hat{\boldsymbol{\Gamma}}_{\boldsymbol{\eta}} is available, regardless of which standard errors were requested:

lavTest(fit_res, output = "text")
Model Test User Model:
                                              Standard      Scaled
  Test Statistic                                96.824      27.413
  Degrees of freedom                                 1           1
  P-value (Chi-square)                           0.000       0.000
  Scaling correction factor                                  3.532
    Satorra-Bentler correction                                    

The contrast is large: the naive statistic (96.8) greatly exaggerates the evidence against the structural restriction; the corrected statistic (27.4) is the one to report. Here it still rejects the restriction clearly, as it should, since the omitted path is a substantial one (0.5) in the population. Both are stored with the fitted object (as the "standard" and "satorra.bentler" tests), following the usual conventions of Section 8.5.

The Satorra–Bentler scaled statistic is the default, but the test argument of sam() accepts any other member of the Satorra–Bentler family of Section 8.5.4 for the structural test: "mean.var.adjusted", "scaled.shifted", and their "corrected" versions, "mean.var.adjusted.corrected" and "scaled.shifted.corrected". The corrected versions replace the biased plug-in estimate of the second-order trace by the unbiased estimator of Hayakawa (2019) (Section 8.5.8). That estimator needs casewise contributions to the moments, which a structural fit on the latent moments does not have as such; but \hat{\boldsymbol{\Gamma}}_{\boldsymbol{\eta}} is itself a casewise crossproduct, and its rows take the place of the casewise moment vectors. The corrected tests are available for single-group, single-level models with continuous indicators, with or without latent interactions, except with se = "local.nt" (they are dropped with a warning in the other settings). Several tests can be requested at once, for instance test = c("satorra.bentler", "mean.var.adjusted.corrected"). The test (or scaled_test) argument may be given at the top level of sam() or inside struc_args; the latter takes precedence, with a warning when both name different tests. The measurement blocks of step 1 inherit the top-level test argument as well (unless mm_args overrides it): when a scaled test is requested, the block table of summary() shows the first scaled statistic of each block (columns Chisq.scaled and Df.scaled) and names the test below the table; otherwise it shows the standard chi-square statistic, as in the examples above.

18.8.2 Fit measures

For a local SAM object, fitMeasures() reports on the structural fit: the reported quantities describe the structural part only, conditional on the measurement model, and a note says so explicitly. The scaled/robust versions are based on the corrected test; the baseline model is the independence model among the latent variables, fitted to the same latent moments and corrected with the same \hat{\boldsymbol{\Gamma}}_{\boldsymbol{\eta}}:

fitMeasures(fit_res, c("chisq", "df", "pvalue",
                       "chisq_scaled", "pvalue_scaled",
                       "cfi_robust", "rmsea_robust", "srmr"))
lavaan NOTE:  
   the fit measures are computed for the structural part only, conditional on 
   the (fixed) measurement model of step 1.
Fit measures of the structural part (given the measurement model):

        chisq            df        pvalue  chisq.scaled pvalue.scaled 
       96.824         1.000         0.000        27.413         0.000 
   cfi.robust  rmsea.robust          srmr 
        0.691         0.558         0.151 

The same corrected values appear in the Summary Information Structural part block of summary(). They are the fit measures of the underlying structural fit object, the regular lavaan object that we extracted with lavInspect(fit, "sam_struc_fit_object") in Section 18.3.2. The functions lavResiduals() and modindices() on a local SAM object likewise operate on this structural fit: the residuals are differences between the estimated and the structural-model-implied latent variance matrix, and the modification indices suggest ways to improve the structural part only.

Model comparison with lavTestLRT() also works, provided all fitted objects are local SAM models sharing the same step-1 measurement model; the difference test then compares the structural parts, using the scaled (corrected) statistics:

lavTestLRT(fit_res, fit_sam)
lavaan NOTE:  
   the chi-square difference test compares the structural parts only, 
   conditional on identical (fixed) step-1 measurement models.
Scaled Chi-Squared Difference Test (method = "satorra.bentler.2001")

lavaan->lavTestLRT():  
   lavaan NOTE: The "Chisq" column contains standard test statistics, not the 
   robust test that should be reported per model. A robust difference test is 
   a function of two standard (not robust) statistics.

        Df AIC BIC  Chisq Chisq diff   RMSEA Df diff Pr(>Chisq)    
fit_sam  0          0.000                                          
fit_res  1         96.823     27.413 0.55765       1  1.643e-07 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

18.8.3 The Yuan–Chan test for global SAM

For sam_method = "global", the joint model is re-fitted in step 2, so a global discrepancy statistic T = N\, F(\mathbf{s}, \boldsymbol{\sigma}(\boldsymbol{\vartheta})(\hat{\boldsymbol{\vartheta}}_1, \hat{\boldsymbol{\vartheta}}_2)) exists. But again its naive reference distribution is wrong: the measurement parameters were not estimated by minimizing this discrepancy, so the usual asymptotics do not apply. Yuan and Chan (2002) derived, in their model segregation framework, a rescaled statistic that corrects the global test for the separate (step-1) estimation of the measurement parameters and, at the same time, for non-normality. lavaan implements it as test = "yuan.chan", the default test for global SAM (the computation reduces to a Satorra–Bentler rescaling in which the model jacobian is restricted to its structural columns and \hat{\boldsymbol{\Gamma}} is residualized for the influence of the step-1 estimates). The fitted object then contains both the "standard" and the "yuan.chan" tests, and the scaled and robust fit measures are based on the latter:

fit_gres <- sam(model_res, data = Data,
                sam_method = "global")
fitMeasures(fit_gres, c("chisq", "df", "pvalue",
                        "chisq_scaled", "df_scaled", "pvalue_scaled"))
        chisq            df        pvalue  chisq.scaled     df.scaled 
       69.172        25.000         0.000        61.760        25.000 
pvalue.scaled 
        0.000 

Note that this is a test of the joint model (here with 25 degrees of freedom: 24 from the measurement part plus 1 structural restriction), whereas the corrected structural test of local SAM isolates the single structural degree of freedom.

18.9 Small-sample corrections

The local SAM estimator of Section 18.3 is consistent, but in small samples, or with weakly reliable indicators, three problems can arise: the estimated latent variance matrix may fail to be positive definite, the bias correction may add more variance than it removes bias, and the estimated latent correlations are somewhat attenuated. This section collects the three corresponding devices. Only the first one (the lambda correction) is active by default, and in most analyses it changes nothing; readers who work with reasonably large samples and reliable indicators can skip this section.

18.9.1 The lambda correction

Nothing guarantees that the difference in Equation 18.7 is positive definite: in small samples, or when the reliability is low, the subtracted measurement error part can be too large. lavaan therefore applies, by default, a correction from the measurement error literature (Fuller, 1987, p. 364). Let \lambda be the smallest root of

\left| \, \mathbf{M}\mathbf{S}\mathbf{M}^{\prime} - \lambda \, \mathbf{M}\hat{\boldsymbol{\Theta}}\mathbf{M}^{\prime} \right| = 0. \tag{18.16}

If \lambda \ge 1 + 1/(N-1), the difference is positive definite with a sufficient margin and Equation 18.7 is used as is. Otherwise, the correction shrinks the subtracted term:

\widehat{\text{Var}(\boldsymbol{\eta})} = \mathbf{M}\mathbf{S}\mathbf{M}^{\prime} - \lambda^{\star}\,\mathbf{M}\hat{\boldsymbol{\Theta}}\mathbf{M}^{\prime}, \qquad \lambda^{\star} = \lambda - \frac{1}{N- 1}, \tag{18.17}

which guarantees a positive definite result while removing as much of the measurement error variance as the data allow. The correction can be disabled with local_options = list(lambda_correction = FALSE). Whenever a truncation was needed, the summary() output reports the value of \lambda^{\star} that was used.

The quantity 1/(N-1) in Equation 18.17 acts as a truncation margin (or floor): we truncate whenever \lambda falls below one plus the margin, and the margin is what is kept between \lambda^{\star} and \lambda. This classic margin has a weakness: it vanishes as the sample size grows, while the sample root \lambda is downward biased, mildly so in well-separated settings, but severely when the bottom of the spectrum is clustered (strongly correlated factors, weakly reliable indicators). In such weakly identified settings, the classic rule could even produce structural estimates whose accuracy deteriorates with increasing sample size over a long pre-asymptotic range. The margin is therefore governed by the local option lambda1_floor, which accepts three kinds of values:

  • "debias" (the current default): a gated rule. If the sample margin \lambda - 1 is clearly positive, relative to its own sampling noise, nothing is done, and the result is identical to the classic rule (no truncation, in fact). Only when the sample margin is small is it replaced by a debiased estimate of the population margin, obtained from a small bootstrap of the factor scores; this margin is never smaller than the classic one. The bootstrap does not touch the random number stream of the user, and the results are reproducible. The details of the rule are given in the implementation notes at the end of this chapter.

  • "classic": the classic rule of Equation 18.17.

  • a single nonnegative number: a fixed margin.

For the vast majority of well-behaved analyses, the debiasing step is never triggered and nothing changes; our running example is a case in point. We recompute the two building blocks of Section 18.3.2, and obtain the smallest root:

est <- lavInspect(fit_sam, "est")
LAMBDA <- est$lambda
THETA  <- est$theta
M <- solve(t(LAMBDA) %*% solve(THETA) %*% LAMBDA) %*%
     t(LAMBDA) %*% solve(THETA)
S <- lavInspect(fit_sam, "sampstat")$cov
var_fs  <- M %*% S %*% t(M)
var_err <- M %*% THETA %*% t(M)
# the smallest root of the determinantal equation
min(Re(eigen(solve(var_err) %*% var_fs)$values))
[1] 2.090302

The root is far above one, and no truncation is needed.

The gated rule requires raw, complete, single-level, continuous data (and no conditional_x). In all other settings, including a model that is fitted to summary statistics only, as in Section 18.1.1, it falls back to the classic rule automatically.

To illustrate the safeguard, we return to the political democracy example of Section 18.6. This is a small sample (N= 75), and one of its latent variables (dem65) is almost perfectly predicted by another one (dem60, the same construct measured five years earlier): the two correlate above 0.9, so that the difference in Equation 18.7 comes close to a singular matrix. The summary() output of this analysis (Section 18.6.1) contained a note about a truncation. We compute the building blocks as before, and obtain the smallest root \lambda:

est <- lavInspect(fit_pd, "est")
LAMBDA <- est$lambda
THETA  <- est$theta
M <- solve(t(LAMBDA) %*% solve(THETA) %*% LAMBDA) %*%
     t(LAMBDA) %*% solve(THETA)
S <- lavInspect(fit_pd, "sampstat")$cov
var_fs  <- M %*% S %*% t(M)
var_err <- M %*% THETA %*% t(M)
lambda <- min(Re(eigen(solve(var_err) %*% var_fs)$values))
lambda                                # the sample root
[1] 1.188671

The latent variance matrix that was used in step 2 reveals the multiplier \lambda^{\star}: by Equation 18.17, the difference between the factor score part and the latent variance matrix is \lambda^{\star} times the measurement error part.

fit_struc_pd <- lavInspect(fit_pd, "sam_struc_fit_object")
var_eta <- lavInspect(fit_struc_pd, "sampstat")$cov
lambda_star <- sum((var_fs - var_eta) * var_err) / sum(var_err^2)
lambda_star                           # the multiplier that was used
[1] 0.8020894
lambda - lambda_star                  # the (debiased) truncation margin
[1] 0.3865817
max(abs(var_eta - (var_fs - lambda_star * var_err)))
[1] 1.110223e-16

The sample root \lambda is larger than one, so the classic rule would not have truncated at all. But with only 75 observations and a latent covariance matrix that is almost singular, the sample margin \lambda - 1 is small relative to its own sampling noise: the debiasing step is triggered, and the debiased margin leads to \lambda^{\star} < 1. The last line confirms that the latent variance matrix has the form of Equation 18.17 exactly.

The next comparison shows how much the choice of the rule matters here. The settings of local SAM are changed through the local_options argument, a named list in which only the elements that deviate from their defaults need to be given (several settings can be combined in the same list). We refit the model with the classic truncation rule, and compare the structural regression coefficients:

fit_pd_classic <- sam(model_pd, data = PoliticalDemocracy,
                      mm_list = list(ind = "ind60",
                                     dem = c("dem60", "dem65")),
                      local_options = list(lambda1_floor = "classic"))
reg <- function(fit) {
  pe <- parameterEstimates(fit)
  pe <- pe[pe$op == "~", ]
  setNames(pe$est, paste0(pe$lhs, "~", pe$rhs))
}
round(rbind(debias  = reg(fit_pd),
            classic = reg(fit_pd_classic),
            shift   = reg(fit_pd) - reg(fit_pd_classic)), 3)
        dem60~ind60 dem65~ind60 dem65~dem60
debias        1.444       0.589       0.847
classic       1.454       0.558       0.871
shift        -0.010       0.031      -0.024

With the classic rule, no truncation is needed (the sample root is larger than one plus the classic margin), and the summary() output of fit_pd_classic contains no note. The largest difference between the two sets of coefficients is 0.031, which is small compared with the standard errors of these coefficients. This is why the note in the summary() output of the default analysis consisted of a single line (Section 18.6.1).

Two consequences of an engaged truncation (\lambda^{\star} < 1) are worth knowing. First, the latent variance matrix then retains a fraction (1 - \lambda^{\star}) of the measurement error (co)variances, and the structural estimates are biased (typically attenuated). To judge how much this matters, sam() computes, where available, two diagnostics for the regression coefficients, both also expressed in standard error units. The first is a delta-method approximation of the maximal shrinkage bias; it has the correct direction, but tends to overstate the realized attenuation, and should be read as a warning signal, not as a correction. The second is the maximal shift away from the estimates that the classic rule would have produced (the shift that we computed by hand above); it is exact (it only requires one extra fit of the structural part), and is available for the first-order truncation only. The note in the summary() output depends on these diagnostics. How much an engaged truncation matters depends on why the latent variance matrix is almost singular. If a latent outcome is (almost) perfectly predicted (a residual variance close to zero), the truncation is typically harmless. If the latent predictors of an equation are (almost) collinear, the classic estimates tend to become very large, and the truncation can change them substantially; this is also where the linearized bias alone would understate the problem, and the shift is needed. As long as neither diagnostic exceeds half a standard error, or when the diagnostics are not available, the note is a single line with the multiplier that was used; otherwise, it warns that the structural estimates may be biased, and shows the two diagnostics. The intervals are not adjusted for this bias. A per-sample (delta-method) estimate of the shrinkage bias is too noisy to center them (its sampling variability exceeds the standard error of the coefficient), and widening the intervals by this estimate would make the intervals of all the other coefficients far too conservative. In a demanding simulation setting (four correlated latent predictors, reliabilities of 0.4, fourteen structural terms), the 95% intervals of the strongly shrunken product terms covered the true value in about 90% of the samples, while the linear terms and the product terms with a true value of zero were covered at the nominal level. Second, a truncated \lambda^{\star} is a function of the data, not a constant: the local standard errors (Section 18.7.1) and the corrected structural test (Section 18.8.1) account for its sampling variability whenever the truncation binds. When no truncation binds, both are unaffected. (Because the local standard errors already overcover when a truncation engaged, the small-sample corrections of the sandwich meat, information_meat_hc of Section 8.4.9, are not applied in that case.)

18.9.2 The alpha correction

A second, optional small-sample device interpolates between local SAM and naive factor score regression. With local_options = list(alpha_correction = alpha) for some integer 0 \le \alpha \le N- 1, the subtracted matrix \mathbf{M}\hat{\boldsymbol{\Theta}}\mathbf{M}^{\prime} is rescaled by the factor 1 - \alpha/(N-1) before the lambda correction is applied:

\widehat{\text{Var}(\boldsymbol{\eta})} = \mathbf{M}\mathbf{S}\mathbf{M}^{\prime} - \left(1 - \frac{\alpha}{N- 1}\right) \mathbf{M}\hat{\boldsymbol{\Theta}}\mathbf{M}^{\prime}. \tag{18.18}

With \alpha = 0 (the default) nothing changes; with \alpha = N- 1 the bias correction vanishes entirely and the result coincides with naive FSR (Section 18.5). Intermediate values trade a little bias for less variance, which can be beneficial in very small samples; typical suggested values are P+1 or P+5, with P the number of predictors in the structural model (Wall & Amemiya, 2000), or (N-1)/2 (Bogaert et al., 2026). When \alpha > 0, the reported standard errors are blended accordingly (a weighted combination of the naive and the corrected covariance matrices).

18.9.3 Small-sample attenuation of the latent correlations

The lambda and alpha corrections act on the latent variance matrix as a whole. A third small-sample effect is specific to the blockwise step 1 with one factor per block (the default mm_list). The loadings and residual variances of each block are estimated from that block alone, and their estimation error enters the mapping matrix \mathbf{M} of every block separately. The result is that the estimated latent correlations are attenuated (pulled towards zero), by a factor of approximately

1 - \frac{(1 - \rho_{mm'}^2)/2 + h_m + h_{m'}}{N- 1}, \tag{18.19}

where \rho_{mm'} is the correlation between the two factors, and the block terms h_m and h_{m'} depend only on the noise-to-signal ratios \theta_{pp}/\lambda_{pm}^2 of the indicators of each factor: they vanish for reliable indicators, grow quadratically in the noise-to-signal ratio, and decrease roughly in proportion to the number of indicators per factor. The first term is the familiar small-sample bias of a sample correlation; the block terms are the price of estimating the measurement blocks separately. With three indicators per factor, standardized loadings of 0.5 and a true correlation of 0.6, the predicted attenuation is about -0.13 when N= 100 and -0.03 when N= 400; with standardized loadings of 0.7 it is -0.03 and -0.01. The bias is absent when all factors are placed in a single measurement block (mm_list = list(c("f1", "f2", "f3"))), because the latent variance matrix then equals the (bounded) joint ML estimate; that choice still separates the measurement part from the structural part, but a misspecification in one part of the measurement model can then affect the estimates of all the factors. Merging only the weakly measured factors into a common block, or using more indicators per factor, are intermediate options.

After step 1, sam() computes the prediction of Equation 18.19 from the step-1 estimates, for every pair of factors that are measured by separate congeneric blocks of at least three indicators, when the data are continuous, complete and single-level, the blocks are estimated by ML without equality constraints, and the ML mapping is used. The prediction is stabilized (the noise-to-signal ratios are winsorized at three times the pooled ratio of their block, and the relative attenuation is capped at 50 percent). The summary() output lists the latent correlations whose predicted bias is at least 0.05 in absolute value, and lavInspect(fit, "sam_attenuation") returns the full results. For the running example (loadings of 0.6 to 0.8 and N= 300), the predicted bias is about -0.01 for every pair, and no note is printed. A small sample with weak indicators is a different matter. We take two factors with three indicators each, standardized loadings of 0.5 and a true correlation of 0.6; with std_lv = TRUE, the single structural coefficient of sam() is that correlation:

pop_weak <- '
  f1 =~ 0.5*y1 + 0.5*y2 + 0.5*y3
  f2 =~ 0.5*y4 + 0.5*y5 + 0.5*y6
  f2 ~ 0.6*f1
  f1 ~~ 1*f1
  f2 ~~ 0.64*f2
  y1 ~~ 0.75*y1; y2 ~~ 0.75*y2; y3 ~~ 0.75*y3
  y4 ~~ 0.75*y4; y5 ~~ 0.75*y5; y6 ~~ 0.75*y6
'
model_weak <- '
  f1 =~ y1 + y2 + y3
  f2 =~ y4 + y5 + y6
  f2 ~ f1
'
Data_weak <- lavSimulateData(pop_weak, sample_nobs = 100, seed = 70)
fit_weak <- sam(model_weak, data = Data_weak, std_lv = TRUE)
summary(fit_weak)
This is lavaan 0.7-4 -- using the SAM approach to SEM

  SAM method                                     Local
  Mapping matrix M method                           ML
  Number of measurement blocks                       2
  Estimator measurement part                        ML
  Estimator structural part                         ML

  Number of observations                           100

Summary Information Measurement + Structural:

  Block Latent Nind Chisq Df
      1     f1    3     0  0
      2     f2    3     0  0

  Model-based reliability latent variables:

     f1    f2
  0.548 0.677

  Note: the following latent correlations are expected to be attenuated
  (small-sample bias; see ?sam):
    f1 ~~ f2               est =  0.496   predicted bias = -0.119 (-24%)

  Summary Information Structural part:

  chisq df pvalue cfi rmsea srmr
      0  0     NA   1     0    0

Parameter Estimates:

  Standard errors                                Local
  Information                                 Expected
  Information bread                           Observed
  Information saturated (h1) model          Structured

Regressions:
                   Estimate  Std.Err  z-value  P(>|z|)
  f2 ~                                                
    f1                0.496    0.184    2.689    0.007

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)
    f1                1.000                           
   .f2                0.754    0.183    4.132    0.000

The note predicts an attenuation of 0.12, about a quarter of the estimated correlation, and close to the population-based prediction of 0.13 that we gave above. By default nothing is corrected: the estimates and standard errors are those of Section 18.3.2. The local option bias_correction = "plugin" applies an analytic plug-in correction: each latent covariance is multiplied by 1 + \min(c,\, \kappa(N- 1))/(N- 1), where c = (1 - \rho^2)/2 + h_m + h_{m'} is the predicted (stabilized) curvature term of the pair, estimated from the step-1 estimates, and \kappa = 1/2 if N\ge 100 and 1/4 otherwise. The latent variances are not changed, so only the correlations move and the metric is untouched. If the corrected latent variance matrix is not positive definite, the correction is shrunk, with a warning.

fit_weak_bc <- sam(model_weak, data = Data_weak, std_lv = TRUE,
                   local_options = list(bias_correction = "plugin"))
summary(fit_weak_bc)
This is lavaan 0.7-4 -- using the SAM approach to SEM

  SAM method                                     Local
  Mapping matrix M method                           ML
  Number of measurement blocks                       2
  Estimator measurement part                        ML
  Estimator structural part                         ML

  Number of observations                           100

Summary Information Measurement + Structural:

  Block Latent Nind Chisq Df
      1     f1    3     0  0
      2     f2    3     0  0

  Model-based reliability latent variables:

     f1    f2
  0.548 0.677

  Note: the latent correlations were corrected for their small-sample
  attenuation (plug-in correction of the blockwise step 1; see ?sam).
    f1 ~~ f2               corrected =  0.614   uncorrected =  0.496 (+24%)

  Summary Information Structural part:

  chisq df pvalue cfi rmsea srmr
      0  0     NA   1     0    0

Parameter Estimates:

  Standard errors                                Local
  Information                                 Expected
  Information bread                           Observed
  Information saturated (h1) model          Structured

Regressions:
                   Estimate  Std.Err  z-value  P(>|z|)
  f2 ~                                                
    f1                0.614    0.228    2.689    0.007

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)
    f1                1.000                           
   .f2                0.623    0.281    2.218    0.027

The corrected correlation (0.614) is closer to the population value (0.6) than the uncorrected one (0.496). For the comparison with the system-wide estimate we use the standardized coefficient, because sem() with std_lv = TRUE fixes the residual variance of f2 (not its total variance) to one:

std_beta <- function(fit) {
  std <- standardizedSolution(fit, se = FALSE)
  std$est.std[std$op == "~"]
}
fit_weak_sem <- sem(model_weak, data = Data_weak, std_lv = TRUE)
round(c(sem = std_beta(fit_weak_sem), sam = std_beta(fit_weak),
        sam_plugin = std_beta(fit_weak_bc)), 3)
       sem        sam sam_plugin 
     0.538      0.496      0.614 

A single sample proves little; a small Monte Carlo experiment shows the pattern. We draw 200 samples of size 100 from the population model and record the standardized structural coefficient of the three approaches:

res_weak <- t(sapply(1:200, function(r) {
  d <- lavSimulateData(pop_weak, sample_nobs = 100, seed = 1000 + r)
  c(sem = std_beta(sem(model_weak, data = d, std_lv = TRUE)),
    sam = std_beta(sam(model_weak, data = d, std_lv = TRUE,
                       se = "none")),
    sam_plugin = std_beta(sam(model_weak, data = d, std_lv = TRUE,
                       se = "none",
                       local_options = list(bias_correction = "plugin"))))
}))
round(rbind(mean = colMeans(res_weak),
            rmse = sqrt(colMeans((res_weak - 0.6)^2))), 3)
       sem   sam sam_plugin
mean 0.590 0.446      0.589
rmse 0.207 0.242      0.234

The system-wide estimate is nearly unbiased here, and it has the smallest RMSE (the measurement model is correctly specified, and some of the samples end at a boundary solution with a correlation of one). The uncorrected SAM estimate is attenuated by about a quarter, and the plug-in correction removes most of the attenuation without increasing the RMSE (in a few of the samples the correction was shrunk to keep the latent variance matrix positive definite, which the chunk’s suppressed warnings report).

The local standard errors (Section 18.7.1) condition on the correction factor: the step-1 Jacobian of the latent moments is rescaled by it. The classic two-step standard errors (se = "twostep", "twostep.robust", "twostep.huber.white", and "standard") are computed from the joint information matrix and do not involve the factor; if they are requested when a correction was applied, they are replaced by se = "local", with a note. With se = "bootstrap" the correction is recomputed in every bootstrap sample. One caveat concerns the metric. The correction targets the latent correlations, and hence the standardized structural coefficients (exactly so for a saturated two-factor regression, as a first-order approximation otherwise). The unstandardized coefficients in the marker-variable metric also depend on the marker loadings of step 1, whose own small-sample bias partly offsets the attenuation and is not corrected, so that in the marker metric the corrected unstandardized coefficients can overshoot. Use std_lv = TRUE, or the standardized solution, when the correction is requested.

18.10 Latent interactions and product terms

One capability of sam() deserves its own section, because it has no counterpart in the rest of the package: latent interactions. As explained in Section 4.9, the linear model matrices leave no room for a product of latent variables, and sem() rejects a term like f1:f2 with an error. For sam(), however, the stepwise logic offers a possibility that system-wide estimation does not have. The structural part of a local SAM analysis never uses the raw data: it only needs the mean vector and variance matrix of the latent variables (Section 18.3.2). If those moments can be supplied for an extended latent vector that includes the product terms, say (\eta_1, \eta_2, \eta_3, \eta_1\eta_2), then step 2 proceeds exactly as in the linear case, with the product term as one more “latent variable” in the structural model.

That is precisely what sam() does (Rosseel et al., 2025). In step 1, the measurement blocks are estimated as usual; Bartlett factor scores are then computed for the components, and the moments involving the product terms are estimated from products of these factor scores. Naive products of factor scores are biased for products of factors, because the measurement error in the scores does not cancel in second and higher-order moments. An analytic bias correction, based on the step-1 estimates, removes the error contribution. Just as in the linear case, the bias-corrected moment matrix of the extended latent vector is not guaranteed to be positive definite, and a second-order version of the lambda correction of Section 18.9.1 handles this. Its truncation margin is governed by the local option lambda2_floor, which takes the same values as lambda1_floor: the (current) default "debias" is the same gated rule (no change whenever the sample margin is sufficiently positive), while "classic" requests the classic margin P_2/(N-1), with P_2 the number of latent variables plus the number of product terms. The debiased margin matters most in weakly identified product-term models (several product terms, weakly reliable indicators, strongly correlated predictors), where the classic vanishing margin could make the accuracy of the structural estimates deteriorate with increasing sample size. One caveat: when the debiased truncation engages, large product-term coefficients are somewhat shrunken, and their confidence intervals can be slightly anti-conservative; the note in the summary() output (Section 18.9.1) flags this situation. The corrected moments then enter the step-2 computations described above. Because a product of (even normal) latent variables is itself nonnormal, the standard errors are computed with the local sandwich estimator of Section 18.7.1: se = "local" is forced for these models.

The matrix \hat{\boldsymbol{\Gamma}}_{\boldsymbol{\eta}} behind these standard errors (and behind the corrected structural test) needs special care here, because the product-term moments are not a function of the sample statistics \mathbf{s} alone: they are averages of casewise quantities that depend on the step-1 estimates. There are therefore two sources of sampling variability: the casewise contributions \mathbf{l}_i to the latent summary statistics themselves, and the step-1 (measurement) estimates. In the current implementation (local option gamma_eta = "casewise", the default), \hat{\boldsymbol{\Gamma}}_{\boldsymbol{\eta}} is the covariance matrix of the joint casewise contributions \mathbf{a}_i = \mathbf{l}_i + \mathbf{C}\,\boldsymbol{\psi}_i, where \boldsymbol{\psi}_i is the casewise influence of the step-1 estimates (the casewise scores of the measurement blocks, premultiplied by the inverted information) and \mathbf{C} is the jacobian of the latent statistics with respect to the step-1 parameters. The older form (gamma_eta = "additive") adds the two sources as separate terms, \widehat{\text{Var}}(\mathbf{l}_i) + N\, \mathbf{C}\,\hat{\boldsymbol{\Omega}}_{11}\mathbf{C}^{\prime} (with \hat{\boldsymbol{\Omega}}_{11} the block-diagonal covariance matrix of the step-1 estimates; see Section 18.2.1), and thereby ignores the covariance between them. This is not negligible: the estimated indicator intercepts are sample means, whose influence functions contain the factor scores. The practical difference is confined to specific parameters: the regression coefficients and (residual) variances are hardly affected, but the additive standard errors of the covariances between the latent variables and the product terms are too large (by a factor of about 1.3 to 1.5), and the corrected structural test loses its power when these covariances are restricted. Measurement blocks for which no casewise scores are available fall back to the additive form.

Latent interactions can also be combined with missing = "ml". The factor scores that feed the product-term moments are then computed per missing-data pattern, using pattern-specific mapping matrices and measurement-error covariances. The first-order latent moments come from the EM-based (\mathsf{H}_1) statistics and remain consistent under MAR; the second-order (interaction) layer is moment-based and assumes MCAR. Cases with too few observed indicators to be scored are dropped from the interaction moments (with a warning), but still contribute to the first-order moments.

On the user side, none of this requires any special syntax beyond the colon operator: interactions (f1:f2), quadratic terms (f1:f1), and mixed latent-by-observed products (f1:x1) are all written directly in the structural part:

set.seed(123)
n <- 500
eta1 <- rnorm(n); eta2 <- rnorm(n)
eta3 <- 0.3*eta1 + 0.3*eta2 + 0.4*eta1*eta2 + rnorm(n, sd = sqrt(0.5))
lam <- 0.8
Data <- data.frame(
  x1 = lam*eta1 + rnorm(n, sd = .6), x2 = lam*eta1 + rnorm(n, sd = .6),
  x3 = lam*eta1 + rnorm(n, sd = .6),
  z1 = lam*eta2 + rnorm(n, sd = .6), z2 = lam*eta2 + rnorm(n, sd = .6),
  z3 = lam*eta2 + rnorm(n, sd = .6),
  y1 = lam*eta3 + rnorm(n, sd = .6), y2 = lam*eta3 + rnorm(n, sd = .6),
  y3 = lam*eta3 + rnorm(n, sd = .6))

model_int <- '
  fx =~ x1 + x2 + x3
  fz =~ z1 + z2 + z3
  fy =~ y1 + y2 + y3
  fy ~ fx + fz + fx:fz
'
fit_int <- sam(model_int, data = Data)
pe <- parameterEstimates(fit_int)
pe[pe$op == "~", c("lhs", "op", "rhs", "est", "se", "pvalue")]
   lhs op   rhs   est    se pvalue
10  fy  ~    fx 0.362 0.059      0
11  fy  ~    fz 0.351 0.055      0
12  fy  ~ fx:fz 0.488 0.096      0

The population values are recovered well: in the marker-variable metric (all the loadings are 0.8), they are 0.3 and 0.3 for the two linear terms and 0.4/0.8 = 0.5 for the product term. The whole analysis takes a fraction of a second. This scalability is the main practical advantage: whereas the feasibility of the traditional one-step methods (the product-indicator approach and LMS) deteriorates quickly as nonlinear terms accumulate, the cost of an extra product term in sam() is essentially one extra row and column in the latent moment matrices. Models with dozens of interaction and quadratic terms still take only seconds. The simulation evidence in Rosseel et al. (2025) and, for more complex nonlinear structures, Vieira et al. (2026) shows that this local SAM approach is a practical and accurate alternative to the one-step methods precisely in these more demanding settings; for the single-interaction textbook case, LMS (available through the modsem package) remains the reference maximum-likelihood method.

Two final remarks are in order. First, standardization: for models with product terms, standardizedSolution() applies the component-based treatment discussed in Section 12.1.6: the interaction coefficient is scaled by SD(\eta_1)\,SD(\eta_2) (not by the standard deviation of the product), and the main effects are reported as simple slopes at the component means. The same holds for observed and mixed product terms. Second, the corrected structural test and fit measures of Section 18.8.1 and Section 18.8.2 are available for these models as well, so that the fit of the nonlinear structural part can be judged separately from the measurement part. Keep in mind that a single-equation model like the example above is structurally saturated (zero degrees of freedom); the test only becomes informative once the structural part contains restrictions, such as omitted paths in a larger system.

18.11 Supported settings and current limitations

The sam() function covers a large part of lavaan’s feature space, but not all of it. As of version 0.7-4, the following settings are supported:

  • Missing data: missing = "ml"; the measurement blocks are fitted by FIML, and the latent moments are computed from the EM-based (\mathsf{H}_1) statistics (see Section 7.3.4).

  • Categorical endogenous indicators: the blocks are fitted with the default WLSMV-type estimation on the latent-response scale; the mapping method is switched to "ULS", the sample statistics are rescaled to the latent-response metric, and a request for se = "twostep" (the default for global SAM) is replaced by "twostep.robust" (for global SAM, the structural estimator becomes DWLS). An ordered endogenous variable in the structural part is supported as well. Details on the categorical estimation are given in chapter 14.

  • Multiple groups: fully supported, including across-group equality constraints in the measurement part (which require the cross-group covariance of the latent statistics; this is handled automatically).

  • Clustered data (cluster=, without level: syntax): the step-1 standard errors switch to their cluster-robust versions, and se = "twostep" is replaced by "twostep.robust".

  • Two-level models: supported for local SAM; the level-specific latent moments are computed from the \mathsf{H}_1 (saturated) estimates by default (local_options = list(twolevel_method = "h1"), with "anova" and "mean" as alternatives). Level 3 is not supported.

  • Higher-order factors and latent interactions: supported for local SAM; latent interaction models compute Bartlett factor scores for the product terms and force se = "local" (see Section 18.10). Latent interactions may be combined with missing = "ml": the product-term moments are then computed per missing-data pattern (consistent under MCAR for the second-order layer).

  • Fixed latent covariances, including orthogonal = TRUE (all the latent covariances are fixed to zero): they are restrictions of the structural part, and are imposed in step 2 (in the local approach, the latent variance matrix of step 1 is unrestricted, and the restrictions contribute to the degrees of freedom of the structural test); covariances that are fixed between factors of the same measurement block (e.g., an orthogonal bifactor model) are also imposed when that block is fitted.

  • Composites: supported for sam_method = "local", "global" and "fsr", with all the two-step standard errors, in multiple groups and with a mean structure; all the composites are joined in a single measurement block (Section 18.2.1).

  • Pairwise maximum likelihood (estimator = "PML", Section 7.5): local methods only; se = "local" is the only available two-step correction (single group, complete data, all-ordinal indicators); otherwise naive standard errors are reported.

  • Exogenous covariates: treated as (pseudo-)latent variables by default, with free variances and covariances when the local standard errors are used (Section 18.7.1); conditional_x = TRUE is supported for single-group, single-level models (and is the recommended setting for categorical data with covariates).

  • The attenuation diagnostic and the plug-in correction of the latent correlations (Section 18.9.3): local SAM with the ML mapping, continuous, complete, single-level data, and, per factor, a separate measurement block with at least three congeneric indicators estimated by ML without equality constraints; other pairs of factors are left uncorrected.

The main limitations to be aware of:

  • Composites (<~) are not available with sam_method = "cfsr", in combination with latent interaction terms, or in a measurement block that is fitted with a multi-stage estimator. A model with a single composite needs the mm_list argument (Section 18.2.1).

  • Every measurement block must be identified (and empirically well-behaved) on its own, and the structural part must be identified from the latent moments alone (Section 18.3.3). Both conditions are checked, with informative error messages.

  • With std_lv = TRUE, the unit variances of the exogenous latent variables stay fixed in the structural part (Section 18.3.3), except under conditional_x = TRUE and in models with latent interaction terms (lavaan 0.7-4): there, they are freed in step 2, and they are only equal to one when the structural part does not restrict the latent covariances.

  • The Yuan–Chan global test is not available under conditional_x = TRUE (the unscaled test is reported, with a warning), and several robust options fall back to simpler ones in corner cases, always with a message stating which standard errors or test were actually computed. The Standard errors line in the summary() header reports the method that was ultimately used.

  • For sam_method = "global", the behavior of the usual fit measures under two-step estimation has not been studied; fitMeasures() warns accordingly.

  • When only summary statistics are provided (sample_cov=, as in Section 18.1.1), everything that needs the raw data is not available: latent interactions, conditional_x = TRUE, the bootstrap, and (unless the nacov= argument is supplied) the ADF-based standard errors (se = "local" and "twostep.robust"; the normal-theory variant se = "local.nt" remains available, and is the default in this case). An informative error message is given in each case, and se = "twostep.huber.white" falls back to "twostep" with a warning.

Since the returned object is an ordinary lavaan object, update(), getCall(), and the full set of extractor functions work as expected; a fitted SAM object can even be passed back to sam() as the model= argument, in which case the stored options are reused unless overridden.

18.12 Implementation notes

This section collects details that are tied to the current implementation of lavaan (the R package, version 0.7-4) rather than to the concepts of the main text. Internal file and function names may change or move at any release, while everything reachable through the user interface stays put. Table 18.2 maps the stepwise SAM procedure of this chapter to its source files.

Table 18.2: Source files of the SAM implementation.
Topic File(s)
the sam() driver xxx_sam.R
step 0: processing the joint model lav_sam_step0.R
step 1: fitting the measurement blocks lav_sam_step1.R
step 1 (local): the per-block computation (lav_sam_step1_local(), with higher-order factors absorbed there), the analytic Jacobian of the latent moments (lav_sam_step1_local_jac()) and its memory-lean casewise product (lav_sam_gamma_eta_g()) lav_sam_step1_local.R
step 2: fitting the structural part; the structural parameter table is extracted by lav_pt_subset_sm() lav_sam_step2.R
lav_partable_subset.R
two-step standard errors, incl. the robust branch, the blending for \alpha > 0, and the bootstrap (lav_sam_step2_se(), lav_sam_step2_se_bootstrap()) lav_sam_step2_se.R
helpers: block detection (lav_sam_get_mmlist()), mapping matrices (lav_sam_mapping_mat(), lav_sam_mapping_mat_tmat()), latent moments (lav_sam_veta(), lav_sam_eeta(), lav_sam_veta2()), the structural fit object and its baseline (lav_sam_struc_fit_object()), the Yuan-Chan global test (lav_sam_global_test()), the joint output object (lav_sam_step3_joint()) lav_sam_utils.R
smallest root of the lambda correction (lav_mat_sym_diff_smallest_root()); the correlation-preserving transformation reused by sam_method = "cfsr" (lav_predict_tmat_det_internal()) lav_matrix.R
lav_predict.R

In the source code, the central quantities of local SAM carry short names: VETA and EETA for the estimated latent variance matrix and latent mean vector (Equation 18.7 and Equation 18.8), MSM and MTM for the two building blocks \mathbf{M}\mathbf{S}\mathbf{M}^{\prime} and \mathbf{M}\hat{\boldsymbol{\Theta}}\mathbf{M}^{\prime} of Equation 18.7, Sigma.11 for the block-diagonal covariance matrix \hat{\boldsymbol{\Omega}}_{11} of the step-1 estimates, and Gamma.eta for the matrix \hat{\boldsymbol{\Gamma}}_{\boldsymbol{\eta}} of Equation 18.10. The same names appear in the list-type output of sam(): besides the default output = "lavaan", the function accepts output = "list" (the intermediate results of both steps, including the two components V2 and V1 of Equation 18.15) and output = "list.step1.only" (stop after step 1 and return its results, including the mapping matrices, the latent moments and the multiplier \lambda^{\star} of Equation 18.17). These lists are meant for development and debugging; their element names are not part of the user interface and may change at any release.

For the default continuous complete-data setting, the product in Equation 18.10 is computed in a memory-lean casewise form that never materializes the full P^{\star} \times P^{\star} matrix \hat{\boldsymbol{\Gamma}}. The influence \mathbf{P} of the sample statistics on the step-1 estimates (Section 18.7.3) comes from the same Jacobian routine (lav_sam_step1_local_jac(p_only = TRUE)). In step 2 of local SAM, the structural fit is a lavaan() call that receives the structural parameter table as its model and VETA, EETA and Gamma.eta as its sample_cov, sample_mean and nacov arguments. For global SAM, the measurement parameters are fixed in the parameter table of the joint model (their free entries are set to zero, and their ustart values to the step-1 estimates).

The gated truncation rule of Section 18.9.1 (lambda1_floor = "debias") proceeds as follows. First, an inexpensive estimate of the sampling noise of the smallest root \lambda is obtained from six (deterministic, interleaved) half-samples. If the sample margin is sufficiently positive, \lambda - 1 \geq \max(2\,\mathrm{se}(\lambda), 1/(N-1)), the debiasing step is skipped. Otherwise, a small casewise bootstrap (200 draws) of the (Bartlett) factor scores provides an estimate of the bias and the standard error of \lambda, and the margin is set to the bias-corrected value of \lambda - 1, capped at three standard errors above the sample margin, and never below twice the standard error of \lambda, nor below the classic margin. The bootstrap uses a fixed internal seed. The gated margins share a single core (lav_sam_lambda_floor_debias()), used by both the first-order (lav_sam_veta()) and the second-order (lav_sam_veta2()) lambda corrections. When a truncation engaged, the per-coefficient versions of the two diagnostics that summary() condenses into their maxima (the approximate shrinkage bias and the shift away from the classic estimates) are computed by lav_sam_trunc_bias() and stored in the fitted object (the bias and move elements of @internal$sam_trunc; an internal slot with no public accessor in version 0.7-4). The @internal slot also holds the SAM metadata (measurement blocks, their fit statistics, the structural fit object, the options used) from which the summary() header is assembled, and the @test slot holds the "standard" test next to the corrected "satorra.bentler" (local) or "yuan.chan" (global) test. The casewise influence of the step-1 estimates that enters \hat{\boldsymbol{\Gamma}}_{\boldsymbol{\eta}} for models with latent product terms (Section 18.10) is computed by lav_sam_step1_casewise().