14  Categorical data in the SEM framework

14.1 Beyond continuous data

Up to this point, we have (mostly) assumed that all observed variables are continuous. In many applications, however, the endogenous variables are binary (yes/no, correct/incorrect) or ordinal (Likert-type items with a small number of ordered response options). Treating such variables as if they were continuous is common practice, and with five or more well-behaved (roughly symmetric) response categories the resulting bias is often tolerable (Rhemtulla et al., 2012). But with few categories, skewed response distributions, or a genuine interest in the measurement scale itself, a dedicated treatment is called for.

This chapter describes how lavaan handles binary and ordinal endogenous variables. The approach follows the mainstream SEM tradition: each observed categorical variable is regarded as a coarsely categorized version of an underlying continuous latent response variable, and the structural equation model is formulated for these latent responses. Estimation then proceeds in stages: first, thresholds and polychoric (or polyserial, or tetrachoric) correlations are estimated from the data; next, the model parameters are fitted to these summary statistics by (diagonally) weighted least squares. This is the three-stage estimator introduced by Muthén (1984), and it is the estimator lavaan applies when the widely used WLSMV shorthand is requested. An alternative, more likelihood-based route is pairwise maximum likelihood (PML) (Katsikatsou et al., 2012), which estimates all parameters simultaneously from the bivariate likelihoods.

Several elements of this approach have already been introduced in earlier chapters: the threshold (|) and scaling (~*~) operators in the model syntax chapter (Section 2.2.4), the extra threshold and scaling parameters in the parameter table chapter (Section 3.2.12), the additional model matrices (\boldsymbol{\tau} and \boldsymbol{\Delta}) in the matrix representation chapter (Section 4.8), the categorical sample statistics in the data handling chapter (Section 5.6.8), and the DWLS and PML estimators in the estimation chapter (Section 7.4.3 and Section 7.5). This chapter brings these elements together, works out the details, and documents the internal computations: the univariate and bivariate estimation kernels, the construction of the categorical \boldsymbol{\Gamma} matrix, the estimator aliases (WLSMV and related names), robust standard errors and test statistics, the multiple-group and longitudinal setting (where the Delta and Theta parameterizations start to matter and measurement invariance takes its Wu–Estabrook form), and the handling of missing data.

Throughout the chapter, a single worked example is used: an ordinal version of the Holzinger–Swineford dataset, obtained by cutting the nine test scores into four ordered categories.

14.2 The latent response formulation

14.2.1 From latent responses to observed categories

Let y_p be an observed ordinal variable with C_p ordered categories, labeled 1, 2, \ldots, C_p. The latent response formulation postulates a continuous, normally distributed variable y^{\star}_p underlying y_p: we only observe in which of C_p contiguous intervals y^{\star}_p falls. The interval boundaries are the thresholds of the variable:

y_p= c \quad\iff\quad \tau^{(c-1)}_p< y^{\star}_p\leq \tau^{(c)}_p, \qquad c = 1, \ldots, C_p, \tag{14.1}

where the outer thresholds are fixed at \tau^{(0)}_p= -\infty and \tau^{(C_p)}_p= +\infty. A variable with C_p categories thus has C_p- 1 free thresholds; a binary variable has a single threshold.

The structural equation model is specified for the vector of latent responses \mathbf{y}^{\star}, not for the observed \mathbf{y}. As noted in Section 4.8, \mathbf{y}^{\star} follows the standard all-y LISREL measurement and structural models, so that the familiar model matrices (\boldsymbol{\Lambda}, \boldsymbol{\Theta}, \boldsymbol{\Psi}, \mathbf{B}) retain their usual meaning: they now describe relations among the latent responses. Assuming y^{\star}_p is (marginally) standard normal, the probability of observing category c is governed by the standard normal distribution function \Phi(\cdot):

\Pr(y_p= c) = \Phi\bigl(\tau^{(c)}_p\bigr) - \Phi\bigl(\tau^{(c-1)}_p\bigr). \tag{14.2}

This is the probit formulation. lavaan also defines a link argument, but for the estimators discussed in this chapter (the WLS family and PML) only link = "probit" is supported; link = "logit" is reserved for the (experimental) marginal maximum likelihood estimator (estimator = "MML"), which we do not discuss further.

14.2.2 Identification: setting the scale of the latent responses

The latent response y^{\star}_p is never observed directly, and Equation 14.1 makes clear that its location and scale are not identified: if we shift y^{\star}_p by a constant and shift all thresholds along with it, or multiply both by a positive constant, the implied category probabilities are unchanged. Only standardized quantities are estimable from ordinal data. The conventional resolution is to standardize each latent response:

\mathrm{E}(y^{\star}_p) = 0, \qquad \text{Var}(y^{\star}_p) = 1 . \tag{14.3}

Three consequences follow. First, the intercept (\boldsymbol{\nu} element) of an ordinal variable is fixed to zero; the thresholds take over the role of location parameters. Second, the variance of y^{\star}_p is not a free parameter: the diagonal elements of the model-implied variance matrix of \mathbf{y}^{\star} that correspond to ordinal variables are constrained to one. When all endogenous variables are ordinal, the model therefore describes a correlation matrix; when ordinal and continuous variables are mixed, only the rows and columns of the ordinal variables are in the correlation metric, while the continuous variables keep their means and variances. The correlations among the latent responses are the polychoric correlations (tetrachoric when both variables are binary); the correlation between a latent response and an observed continuous variable is the polyserial (or biserial) correlation. Third, because the residual variance of y^{\star}_p can no longer be free either, the unit-variance constraint must be imposed in another way. lavaan offers two conventions, the Delta and Theta parameterizations, which are discussed in Section 14.5.2.

This is the default identification, and lavaan applies it whenever the thresholds of a variable are left free. It is a convention, not a necessity: the thresholds, the intercept, and the scale of y^{\star}_p are entangled, and any choice that fixes one location and one scale is sufficient. The alternative is to fix thresholds instead. Fixing one threshold to a constant identifies the location of y^{\star}_p, so that its intercept can be freed; fixing two thresholds identifies its scale as well, so that both the intercept and the scale (the scaling factor under the Delta parameterization, the residual variance under the Theta parameterization) can be freed:

y1 | 0*t1 + 1*t2    # two thresholds fixed
y1 ~ 1              # intercept freed
y1 ~*~ y1           # scale freed (Delta parameterization)

lavaan does not free these parameters on its own: the user adds them to the model syntax, and is responsible for matching the number of freed parameters to the number of fixed thresholds. Done this way, the alternative identification is a reparameterization of the default one, with identical fit and identical standardized solution. It is the convention of Millsap and Yun-Tein (2004), and one of the identification schemes that measEq.syntax() can generate (Section 14.6.3). The rest of this chapter assumes the default identification.

Note that when exogenous covariates are present (and conditional_x = TRUE, the default in the categorical setting), the standardization applies to the conditional distribution of y^{\star}_p given the covariates: the residual of the probit regression of y^{\star}_p on \mathbf{x} has unit variance. This mirrors the conditional approach for continuous data described in Section 4.7.3.

14.3 Declaring ordered variables

lavaan treats an endogenous observed variable as ordinal if either (a) the variable is an ordered factor in the data frame, or (b) the variable is listed in the ordered= argument of the fitting functions. The ordered= argument accepts a character vector with variable names, or the value TRUE as a shorthand for all endogenous variables:

# three equivalent ways
fit <- cfa(model, data = mydata, ordered = c("y1", "y2", "y3"))
fit <- cfa(model, data = mydata, ordered = TRUE)  # all endogenous ov's
mydata[c("y1", "y2", "y3")] <- lapply(mydata[c("y1", "y2", "y3")], ordered)
fit <- cfa(model, data = mydata)                  # auto-detected

Internally, the declared measurement level is recorded in the variable table (see the varTable() function and Section 5.1.1): ordinal variables receive type "ordered", and the number of observed response categories is stored in the nlev column. An ordinal variable must have at least two categories; more than 12 categories triggers a warning, since such a variable is usually better treated as continuous. Ordinal variables are normally endogenous: under the default settings, declaring an exogenous covariate as ordered triggers a warning, and the covariate is used as numeric (the exception is described in Section 14.4.5). The category labels are irrelevant; internally the categories are recoded to consecutive integers 1, 2, \ldots, C_p.

For the running example, we discretize the nine Holzinger–Swineford test scores into four ordered categories, cutting at the empirical quartiles so that the categories are roughly balanced:

HSord <- HolzingerSwineford1939
for (v in paste0("x", 1:9)) {
  HSord[[v]] <- cut(HolzingerSwineford1939[[v]],
                    breaks = quantile(HolzingerSwineford1939[[v]],
                                      probs = seq(0, 1, 0.25)),
                    include.lowest = TRUE, labels = FALSE)
  HSord[[v]] <- ordered(HSord[[v]])
}
sapply(HSord[paste0("x", 1:9)], table)
  x1 x2 x3 x4 x5 x6 x7 x8 x9
1 82 90 84 83 85 85 85 77 78
2 82 82 80 89 79 68 67 75 77
3 65 60 63 60 62 78 74 74 71
4 72 69 74 69 75 70 75 75 75

This construction is deterministic: no random numbers are involved. The usual three-factor model can now be fitted directly:

model <- '
  visual  =~ x1 + x2 + x3
  textual =~ x4 + x5 + x6
  speed   =~ x7 + x8 + x9
'
fit <- cfa(model, data = HSord, ordered = TRUE)

Because the data are categorical, several defaults change silently. The resolved options can always be inspected afterwards:

lavInspect(fit, "options")[c("estimator", "se", "test",
                             "parameterization", "missing")]
$estimator
[1] "DWLS"

$se
[1] "robust.sem"

$test
[1] "standard"       "scaled.shifted"

$parameterization
[1] "delta"

$missing
[1] "listwise"

The default estimator becomes WLSMV, which in turn expands to the point estimator DWLS with robust standard errors and a scaled-and-shifted test statistic (see Section 14.5.4). In addition, meanstructure = TRUE is switched on (Mplus style), and, when exogenous covariates are present, conditional_x = TRUE becomes the default, so that the model is formulated conditionally on the covariates. (In this example there are no covariates, so conditional_x is reset to FALSE during option processing.) Plain estimator = "ML" is not available for ordinal endogenous variables; requesting it results in an error message suggesting WLSMV.

14.3.1 What changes in the parameter table

Two new parameter types appear in the parameter table, corresponding to the two operators introduced in the model syntax chapter (Section 2.2.4). The thresholds use the | operator, with right-hand-side labels t1, t2, and t3:

pt <- parTable(fit)
pt[pt$op == "|" & pt$lhs %in% c("x1", "x2"),
   c("lhs", "op", "rhs", "free", "start", "est")]
   lhs op rhs free  start    est
10  x1  |  t1    7 -0.605 -0.605
11  x1  |  t2    8  0.113  0.113
12  x1  |  t3    9  0.709  0.709
13  x2  |  t1   10 -0.527 -0.527
14  x2  |  t2   11  0.180  0.180
15  x2  |  t3   12  0.741  0.741

Threshold parameters are added automatically for every declared ordinal variable (one fewer than the number of levels recorded in the variable table), and they are freed automatically because the fitting functions set auto_th = TRUE. When no dataset is available, the number of thresholds per variable can be communicated to lavParTable() directly via the nthresholds argument, as explained in the parameter table chapter (Section 3.2.12).

The scaling factors use the ~*~ operator:

pt[pt$op == "~*~", c("lhs", "op", "rhs", "free", "est")][1:3, ]
   lhs  op rhs free est
52  x1 ~*~  x1    0   1
53  x2 ~*~  x2    0   1
54  x3 ~*~  x3    0   1

Under the default Delta parameterization the scaling factors are fixed to one, while the residual variances of the ordinal variables are no longer free parameters (their free column is zero); their values are derived from the unit-variance constraint Equation 14.3. Finally, the intercepts of the ordinal variables are fixed to zero. All information needed to distinguish ordinal from continuous variables is available via lavNames():

lavNames(fit, "ov_ord")
[1] "x1" "x2" "x3" "x4" "x5" "x6" "x7" "x8" "x9"

14.4 Estimating the unrestricted model

For continuous complete data, the unrestricted (\mathsf{H}_1) model is trivially estimated by the sample means and (co)variances. In the categorical setting, the saturated parameters are the thresholds and the latent response correlations, and their estimation requires more effort: the sample statistics \mathbf{s} are themselves estimates, obtained by maximizing univariate and bivariate likelihoods. lavaan follows the stage-wise approach of Muthén (1984; Jöreskog, 1994; see also Muthén & Satorra, 1995):

  1. Step 1 (univariate): estimate the thresholds of each ordinal variable (plus probit regression slopes when covariates are present), and the means/variances (plus linear regression slopes) of each continuous variable, one variable at a time.

  2. Step 2 (bivariate): estimate the correlation of each pair of variables from its bivariate likelihood, holding the univariate parameters fixed at their step 1 values.

  3. Step 3 (sampling variability): compute the joint sampling variance matrix of all step 1 and step 2 estimates. Scaled by N, this is the categorical version of the \boldsymbol{\Gamma} matrix (see Section 5.6.2 and Section 8.3); its inverse (or the inverse of its diagonal) provides the weight matrix for (D)WLS estimation.

The three steps are carried out when the sample statistics are assembled. Each step has its own loop over the variables or variable pairs, built on a small family of univariate and bivariate estimation kernels; the implementation notes at the end of this chapter (Section 14.9) map them to their source files.

The description below starts from the baseline setting, in which all endogenous variables are ordinal and no exogenous covariates are present; this is the setting of the running example. Two extensions change the content of the three steps, but not their logic. In the mixed setting, some endogenous variables are continuous: step 1 then also produces means and variances, step 2 polyserial and Pearson correlations, and the sample statistics are partly in the correlation and partly in the covariance metric. With exogenous covariates (and conditional_x = TRUE, the current default in the categorical setting), all three steps work on the conditional distribution of the latent responses given the covariates, and regression slopes are added to the sample statistics. Each step notes what changes; Section 14.4.4 and Section 14.4.5 then work out the two extensions in full, with the layout of the resulting sample statistics.

14.4.1 Step 1: thresholds and probit regressions

Without covariates, the univariate marginal likelihood of an ordinal variable depends only on the category proportions, and the ML estimates of the thresholds are available in closed form: the threshold \tau^{(c)}_p is the standard normal quantile of the cumulative proportion of the first c categories. This is easily verified:

prop <- prop.table(table(HSord$x1))
qnorm(cumsum(prop))[-4]                    # closed-form thresholds x1
         1          2          3 
-0.6054945  0.1126614  0.7088697 
lavInspect(fit, "sampstat")$th[1:3]        # what lavaan reports
     x1|t1      x1|t2      x1|t3 
-0.6054945  0.1126614  0.7088697 

With exogenous covariates (and conditional_x = TRUE), the closed form no longer applies and each ordinal variable is regressed on the covariates with an ordered probit regression, estimated by ML. The log-likelihood contribution of case i for variable p is

\log L_{ip} = \log\Bigl[ \Phi\bigl(\tau^{(c)}_p- \mathbf{x}_i^{\prime}\boldsymbol{\beta}_p\bigr) - \Phi\bigl(\tau^{(c-1)}_p- \mathbf{x}_i^{\prime}\boldsymbol{\beta}_p\bigr) \Bigr], \qquad c = y_{ip}, \tag{14.4}

which lavaan maximizes with a bounded quasi-Newton optimizer, using analytic gradient and Hessian functions (given in appendix C.3). The starting values are equally spaced normal quantiles for the thresholds and zeros for the slopes. The same covariates are used for every variable, irrespective of the model: step 1 estimates the saturated regression of each variable on the full set of exogenous covariates, and it is the model that later restricts the slopes (Section 14.4.5).

A continuous endogenous variable is handled by an ordinary linear regression on the same covariates (appendix C.2): its intercept, slopes, and residual variance are the ML estimates (the variance with N in the denominator). Without covariates, this reduces to the sample mean and the sample variance. The step 1 loop collects, for every variable, the parameter estimates and the casewise score vectors. The scores are the input for step 3.

The resulting (residual) thresholds and probit slopes coincide with what any standard ordered probit routine would produce. Using the ageyr variable as a covariate:

model2 <- ' visual =~ x1 + x2 + x3
            visual ~ ageyr '
fit_x <- sem(model2, data = HSord, ordered = TRUE)
lavInspect(fit_x, "sampstat")$res.slopes
    ageyr
x1 -0.036
x2 -0.041
x3  0.061
MASS::polr(x1 ~ ageyr, data = HSord, method = "probit")$coefficients
      ageyr 
-0.03644764 

The sample statistics now carry the res. prefix (res.th, res.slopes, res.cov, …) because they describe the distribution of the latent responses after conditioning on the covariates. The thresholds of the marginal distribution of each ordinal variable, ignoring the covariates, are kept as well and can be retrieved with lavInspect(fit_x, "res_th_nox"); they are the closed-form values of the previous paragraph.

One practical complication is handled at this stage as well: empty categories. If a declared response category is not observed in (a group of) the data, its threshold is not identified, and by default (allow_empty_cell = FALSE) lavaan stops with an error that names the variable and its category frequencies. With allow_empty_cell = TRUE, pseudo-values are inserted for unobserved extreme categories (-4 for a missing first category, +4 for a missing last one, values far in the tails) and lavaan keeps track of which thresholds are real; unobserved middle categories are not supported and raise an error even then. The option is meant for simulation and bookkeeping purposes, not to salvage the estimation of a model, and lavaan gives a warning to that effect.

14.4.2 Step 2: polychoric, polyserial, and Pearson correlations

Step 2 estimates one correlation per variable pair, treating the univariate parameters as known. For a pair of ordinal variables (y_p, y_{p^{\prime}}), the latent responses (y^{\star}_p, y^{\star}_{p^{\prime}}) are assumed bivariate standard normal with correlation \rho, so the probability of observing the category pair (a, b) is a rectangle probability of the bivariate normal distribution function \Phi_2:

\pi_{ab}(\rho) = \Phi_2\bigl(\tau^{(a)}_{p}, \tau^{(b)}_{p^{\prime}}; \rho\bigr) - \Phi_2\bigl(\tau^{(a-1)}_{p}, \tau^{(b)}_{p^{\prime}}; \rho\bigr) - \Phi_2\bigl(\tau^{(a)}_{p}, \tau^{(b-1)}_{p^{\prime}}; \rho\bigr) + \Phi_2\bigl(\tau^{(a-1)}_{p}, \tau^{(b-1)}_{p^{\prime}}; \rho\bigr), \tag{14.5}

the same expression that underlies the PML fitting function in Section 7.5.1. The bivariate log-likelihood \sum_{a}\sum_{b} n_{ab}\log \pi_{ab}(\rho), with n_{ab} the observed bivariate frequencies, is maximized over the single parameter \rho. Estimating \rho with the thresholds fixed at their univariate estimates is the two-step estimator studied by Olsson (1979), who showed that it is nearly as efficient as full bivariate ML while being much faster, an important consideration since the number of pairs grows quadratically with the number of variables.

For a continuous/ordinal pair (y_p, y_{p^{\prime}}), with y_p continuous and y_{p^{\prime}} ordinal, the polyserial correlation is estimated along the same lines (Olsson et al., 1982). The bivariate likelihood factors into the marginal normal density of y_p and the conditional probability of the observed category of y_{p^{\prime}} given y_p. Writing z_{ip} = (y_{ip} - \hat{\mu}_p)/\hat{\sigma}_p for the standardized value of the continuous variable, the contribution of case i with y_{ip^{\prime}} = b is

L_i(\rho) = \frac{1}{\hat{\sigma}_p}\,\phi(z_{ip}) \left[ \Phi\!\left(\frac{\tau^{(b)}_{p^{\prime}} - \rho\, z_{ip}} {\sqrt{1 - \rho^2}}\right) - \Phi\!\left(\frac{\tau^{(b-1)}_{p^{\prime}} - \rho\, z_{ip}} {\sqrt{1 - \rho^2}}\right) \right], \tag{14.6}

where the mean, the variance, and the thresholds are held fixed at their step 1 values, and only \rho is estimated. The biserial correlation is the special case of a binary y_{p^{\prime}}. For two continuous variables, the correlation is the ML solution of the bivariate normal likelihood with the step 1 means and variances held fixed, which for complete data is the Pearson correlation.

With exogenous covariates, all three kernels work on the conditional distributions produced by step 1: a continuous variable enters through its standardized residual, z_{ip} = (y_{ip} - \hat{\boldsymbol{\beta}}_p^{\prime} \mathbf{x}_i)/\hat{\sigma}_p, with \hat{\sigma}_p the residual standard deviation, and the thresholds of an ordinal variable are shifted by its probit linear predictor, \tau^{(c)}_{p} - \hat{\boldsymbol{\beta}}_p^{\prime} \mathbf{x}_i, as in Equation 14.4. The correlation estimated in step 2 is then the correlation between the latent responses after the covariates have been partialled out: a residual polychoric, polyserial, or Pearson correlation.

In the step 2 pair loop, the per-pair work is done by three kernels (polychoric, polyserial, and Pearson), whose log-likelihoods, scores, and Hessians are given in appendix C.5, C.7 and C.6. The polychoric kernel uses the same quasi-Newton optimizer (analytic gradient and Hessian, bounds -0.999 < \rho < 0.999), retrying from \rho = 0 if the first attempt fails. A few special cases are intercepted for 2\times2 tables: two empty cells on a diagonal imply \rho = \pm 1; an odds ratio of one (the two products of diagonally opposite cells are equal) implies \rho = 0; and when both thresholds are zero, the closed-form solution \rho = -\cos(2\pi\, n_{11}/n) is used.

Empty cells in the bivariate table require attention, because a zero frequency can make the polychoric likelihood ill-behaved. Three options control the behavior:

  • zero_add: a numeric vector of length two, with the value added to an empty cell in a 2\times2 table (first element, default 0.5) and in a larger table (second element, default 0.0, i.e., nothing is added);

  • zero_keep_margins: for 2\times2 tables only; if TRUE (the default), the other three cells are adjusted so that the margins of the table are preserved;

  • zero_cell_warn: if TRUE, warn whenever a bivariate table contains empty cells (default FALSE; the affected pairs are always recorded and can be retrieved with lavInspect(fit, "zero_cell_tables")).

These special cases and options apply to the bivariate frequency table, which only exists without covariates. With conditional_x = TRUE, the bounds of the rectangle probabilities differ from case to case, no table is formed, and the zero-cell options have no effect.

The thresholds and correlations produced by steps 1 and 2 can also be obtained directly, without specifying any model, via the lavCor() function, which is a thin wrapper around the same estimation routines:

lavCor(HSord[paste0("x", 1:4)], ordered = TRUE)
      x1    x2    x3    x4
x1 1.000                  
x2 0.307 1.000            
x3 0.384 0.319 1.000      
x4 0.429 0.219 0.145 1.000

These values match the cov slot of lavInspect(fit, "sampstat"), the sample statistics against which the SEM will be fitted.

14.4.3 Step 3: the categorical \boldsymbol{\Gamma} matrix

For WLS estimation, and for all robust standard errors and test statistics, we need the categorical version of the \boldsymbol{\Gamma} matrix of Section 5.6.2: N times the asymptotic variance matrix of the full vector of estimated sample statistics \mathbf{s} (thresholds, slopes, variances, correlations). Because \mathbf{s} is produced by a sequence of estimating equations, the delta method for stage-wise estimators applies (Muthén, 1984; Muthén & Satorra, 1995). Stacking the estimating equations of steps 1 and 2, the estimated variance matrix of \mathbf{s} takes a sandwich form, and \hat{\boldsymbol{\Gamma}} is N times that sandwich:

\hat{\boldsymbol{\Gamma}} = N\, \mathbf{A}^{-1}\, \mathbf{B}\, (\mathbf{A}^{-1})^{\prime}, \qquad \mathbf{A} = \begin{pmatrix} \mathbf{A}_{11} & \mathbf{0} \\ \mathbf{A}_{21} & \mathbf{A}_{22} \end{pmatrix}, \qquad \mathbf{B} = \sum_{i=1}^{N} \mathbf{g}_i^{\vphantom{\prime}}\, \mathbf{g}_i^{\prime}, \tag{14.7}

where \mathbf{g}_i stacks the casewise scores of all univariate models (step 1) and all bivariate correlation models (step 2), evaluated at the estimates; the scores, and the second derivatives used below, are given model by model in appendix C, and appendix C.8 spells out the layout of \mathbf{g}_i and the content of every block of \mathbf{A}, for the all-ordinal, the mixed, and the conditional settings. The bread \mathbf{A} is the matrix of derivatives of the stacked estimating equations with respect to the parameters. It is block lower-triangular because the univariate estimating equations do not involve the correlations:

  • \mathbf{A}_{11} is the information matrix of the univariate models; it is block-diagonal per variable (each variable is estimated separately). For an ordinal variable (a saturated threshold model) it is computed as a “sparse” version of the upper-left block of \mathbf{B}, relying on the information identity; for a numeric variable it is the analytic information matrix of the univariate normal regression;

  • \mathbf{A}_{22} is diagonal, holding the (unit) information of each correlation estimate: the crossproduct of the scores for a polychoric correlation, and the observed second derivative of the bivariate log-likelihood for a Pearson or polyserial correlation;

  • \mathbf{A}_{21} contains the cross-derivatives of the correlation scores with respect to the univariate parameters (again crossproducts for the polychoric pairs, observed second derivatives for the pairs that involve a numeric variable). This block is what propagates the uncertainty of the estimated thresholds into the variance matrix of the correlations. Ignoring it (i.e., treating the thresholds as known) would understate the variability of the polychoric correlations.

The distinction between the two kinds of blocks matters when a numeric variable is not normally distributed, such as a skewed indicator or a 0/1 dummy variable declared numeric. The information identity then does not hold for that variable: a crossproduct bread would understate the standard errors of its loading and residual variance, and for a dummy variable it breaks down entirely, because the scores for its mean and variance are collinear. With the observed derivatives, the moments of the numeric variables obtain their ADF asymptotic variances. Mplus applies the information identity throughout, and mimic = "Mplus" does the same, so that its output for mixed data is reproduced; for purely ordinal data the two choices give identical results.

The block-triangular structure permits an analytic inverse (\mathbf{A}^{-1} requires only \mathbf{A}_{11}^{-1} and \mathbf{A}_{22}^{-1}), so no large matrix ever needs to be factorized. When continuous variables are present, a final delta-rule transformation converts the correlation metric back to the variance metric for the continuous variables. For the special case where all variables are ordinal and no covariates are present, the resulting \hat{\boldsymbol{\Gamma}} coincides (up to the factor N) with the asymptotic variance matrix of thresholds and polychoric correlations derived by Jöreskog (1994).

The result is stored with the sample statistics (see Section 5.6.8; lavInspect(fit, "wls_v") returns the weight matrix derived from it), and takes the place of the ADF estimator \hat{\boldsymbol{\Gamma}} in the formulas of chapter 8 (see also the overview in Section 8.3). Its dimension is P^{\star} \times P^{\star}, where P^{\star} counts all nonredundant sample statistics. In the running example: 9 \times 3 = 27 thresholds plus 9 \cdot 8/2 = 36 correlations, so P^{\star} = 63:

dim(lavInspect(fit, "gamma"))
[1] 63 63

The DWLS weight matrix (exposed as a diagonal matrix via the "wls_v" keyword of lavInspect()) contains exactly the inverted diagonal of this \hat{\boldsymbol{\Gamma}}, as described in Section 7.4.3:

GAMMA <- lavInspect(fit, "gamma")
V     <- lavInspect(fit, "wls_v")
max(abs(diag(V) - 1 / diag(GAMMA)))
[1] 0

Two refinements are available. With sampling weights, the casewise scores are reweighted, and the sampling_weights_type option selects between a design-based meat ("design", matching Mplus) and a frequency interpretation ("frequency"). With clustered data (a cluster= argument), the casewise scores are first summed within each cluster before the outer product in \mathbf{B} is formed, yielding the cluster-robust \hat{\boldsymbol{\Gamma}}^{\mathrm{clus}} used by se = "robust.cluster.sem" (Section 8.3); the weight matrix for point estimation is still the i.i.d. version.

14.4.4 The mixed setting: ordinal and continuous variables

When some endogenous variables are continuous, the three steps run as described, with the continuous variables taking the linear-regression branch of step 1 and the polyserial and Pearson branches of step 2. What changes is the content and the metric of the sample statistics. To illustrate, we return the three textual indicators of the running example to their original continuous scale, and keep the other six ordinal:

HSmix <- HSord
HSmix[paste0("x", 4:6)] <- HolzingerSwineford1939[paste0("x", 4:6)]
fit_mix <- cfa(model, data = HSmix,
               ordered = paste0("x", c(1:3, 7:9)))

The sampstat output has the same three components as before, but the continuous variables fill them differently:

ss <- lavInspect(fit_mix, "sampstat")
round(ss$mean, 3)
   x1    x2    x3    x4    x5    x6    x7    x8    x9 
0.000 0.000 0.000 3.061 4.341 2.186 0.000 0.000 0.000 
round(ss$cov[1:6, 1:6], 3)
      x1    x2    x3    x4    x5    x6
x1 1.000 0.307 0.384 0.490 0.429 0.437
x2 0.307 1.000 0.319 0.263 0.272 0.258
x3 0.384 0.319 1.000 0.153 0.075 0.189
x4 0.490 0.263 0.153 1.351 1.098 0.896
x5 0.429 0.272 0.075 1.098 1.660 1.015
x6 0.437 0.258 0.189 0.896 1.015 1.196

The mean vector is zero for the ordinal variables and holds the sample means of the continuous ones; the threshold vector (not shown) only contains the six ordinal variables. The cov component is in a mixed metric: the ordinal rows and columns are in the correlation metric (polychoric correlations off the diagonal, ones on the diagonal), the continuous block holds ordinary (ML) sample covariances, and an element that pairs a continuous with an ordinal variable is the polyserial correlation multiplied by the standard deviation of the continuous variable, that is, the covariance between the continuous variable and the unit-variance latent response. The sample statistics vector follows the layout of the all-ordinal case with two additions: the means of the continuous variables take the place of their (nonexistent) thresholds, interleaved in the order of the variables, and the variances of the continuous variables are inserted before the correlations:

wls_obs <- lavInspect(fit_mix, "wls_obs")
length(wls_obs)
[1] 60
round(wls_obs[1:24], 3)
 x1|t1  x1|t2  x1|t3  x2|t1  x2|t2  x2|t3  x3|t1  x3|t2  x3|t3   x4~1   x5~1 
-0.605  0.113  0.709 -0.527  0.180  0.741 -0.586  0.113  0.688 -3.061 -4.341 
  x6~1  x7|t1  x7|t2  x7|t3  x8|t1  x8|t2  x8|t3  x9|t1  x9|t2  x9|t3 x4~~x4 
-2.186 -0.576  0.012  0.677 -0.656  0.012  0.677 -0.646  0.037  0.677  1.351 
x5~~x5 x6~~x6 
 1.660  1.196 

The means enter with a minus sign (x4~1 equals -3.061). This is not an artifact of the output but part of the layout: a model-implied threshold is of the form “threshold minus implied mean” (Section 14.5.1), and a continuous variable, which has no threshold, keeps only the second term. The count is 6 \times 3 = 18 thresholds plus 3 means, 3 variances, and 36 correlations/covariances, so P^{\star} = 60, three fewer than in the all-ordinal case: each continuous variable contributes a mean and a variance instead of three thresholds. On the model side, the continuous variables keep a free intercept and a free residual variance, as in a continuous-data analysis, and the degrees of freedom are again 24:

fitMeasures(fit_mix, c("chisq_scaled", "df_scaled", "pvalue_scaled"))
 chisq.scaled     df.scaled pvalue.scaled 
       73.814        24.000         0.000 

In step 3, the continuous variables are where the two kinds of bread blocks of Section 14.4.3 differ. Their univariate information in \mathbf{A}_{11} is the analytic information of the normal regression, their correlation blocks in \mathbf{A}_{21} and \mathbf{A}_{22} use observed second derivatives, and the final delta-rule transformation moves their rows of \hat{\boldsymbol{\Gamma}} from the correlation to the covariance metric (the Jacobian is given in appendix C.8.4). The net effect is that the means, variances, and covariances of the continuous variables obtain the same asymptotic variances as in the continuous-data ADF estimator (Section 8.3): the robust standard errors and test statistics of Section 14.5.6 do not require the continuous variables to be normally distributed. Normality does enter the point estimates, through the polyserial correlations: Equation 14.6 assumes that the continuous variable and the latent response are bivariate normal. A continuous variable with a strongly non-normal distribution, or a 0/1 dummy declared numeric, strains that assumption, and the latter is better declared ordinal (binary) so that a tetrachoric correlation is used instead.

14.4.5 Exogenous covariates: conditional_x = TRUE

An exogenous covariate is an observed variable that only appears on the right-hand side of regression formulas and is not itself endogenous (lavNames(fit, "ov_x")). When such covariates are present in a model with ordinal endogenous variables, two options resolve differently from the continuous case: conditional_x = TRUE and, as a consequence, fixed_x = TRUE (the combination conditional_x = TRUE with fixed_x = FALSE is not supported). The covariates are then not part of the latent response vector at all. Instead, the whole analysis is carried out conditionally on their observed values, in the spirit of a regression model: no distributional assumption is made about the covariates, which may be continuous, binary, or dummy-coded without consequence. The fit_x object of Section 14.4.1 serves as the example:

names(lavInspect(fit_x, "sampstat"))
[1] "res.cov"    "res.int"    "res.th"     "res.slopes" "cov.x"     
[6] "mean.x"    

The residual statistics are the output of the three steps applied to the conditional distributions: res.th holds the thresholds of the probit regressions (Equation 14.4), res.int the intercepts of the linear regressions of the continuous variables (zero for ordinal variables), res.slopes the probit and linear slopes, one row per endogenous variable and one column per covariate, and res.cov the residual correlation (or covariance) matrix of step 2. The two remaining components, cov.x and mean.x, are the sample moments of the covariates themselves; they are carried along for the baseline model and the standardized solution but are not modeled. The sample statistics vector inserts the slopes between the thresholds and the correlations, column by column, so that all slopes on the first covariate come first, then all slopes on the second, and so on (the complete layout, and the slope rows and columns of the step 3 sandwich, are given in appendix C.8.1):

round(lavInspect(fit_x, "wls_obs"), 3)
   x1|t1    x1|t2    x1|t3    x2|t1    x2|t2    x2|t3    x3|t1    x3|t2 
  -1.079   -0.360    0.236   -1.056   -0.348    0.214    0.207    0.906 
   x3|t3 x1~ageyr x2~ageyr x3~ageyr   x1~~x2   x1~~x3   x2~~x3 
   1.482   -0.036   -0.041    0.061    0.305    0.387    0.322 

Here P^{\star} = 9 + 3 + 3 = 15: nine residual thresholds, three slopes on ageyr, and three residual polychoric correlations. Because the standardization of the latent responses now applies to their conditional distribution (Section 14.2.2), the residual thresholds differ from the marginal ones, and the slopes are in the metric of a probit regression with unit residual variance.

Step 1 regressed every indicator on the covariate. The model, in contrast, specifies that ageyr affects the indicators only through the factor, so the three slopes must be reproduced by a single regression coefficient: the model-implied slopes are \boldsymbol{\Lambda}\boldsymbol{\Gamma} (more generally Equation 14.10 of Section 14.5.1), where \boldsymbol{\Gamma} is the model matrix of regression coefficients of the latent variables on the covariates (Section 4.7.3), not to be confused with the categorical \boldsymbol{\Gamma} matrix of Section 14.4.3. The two restrictions this imposes are counted in the degrees of freedom:

fitMeasures(fit_x, c("df", "npar"))
  df npar 
   2   13 

A model with a direct effect of the covariate on one of the indicators (x1 ~ ageyr) would free one of these restrictions, which is how differential item functioning with respect to an observed covariate is tested in this framework. In the summary output, the regression coefficients appear in the Regressions section as usual, and the Thresholds section reports the residual thresholds.

The conditional approach is the default, but not the only option. With conditional_x = FALSE, the covariates are added to the endogenous variables as continuous variables in the joint latent response vector: step 1 estimates their means and variances, step 2 their Pearson correlations with each other and their polyserial correlations with the ordinal indicators, and the model reproduces these joint moments (with the moments of the covariates as free parameters when fixed_x = FALSE, or fixed to their sample values when fixed_x = TRUE). This is the mixed setting of Section 14.4.4 with the covariates among the continuous variables, and it inherits the assumption that each covariate is bivariate normal with every latent response. For continuous covariates the two approaches are close in practice but not identical: they fit different sample statistics, and their test statistics are not comparable. For binary or dummy-coded covariates, the conditional approach is clearly preferable. Both approaches are also available under pairwise maximum likelihood (Section 14.7), where conditional_x = TRUE is handled inside the bivariate likelihoods in the same way.

An exogenous covariate can itself be declared as ordered. What happens then depends on the same two options. With conditional_x = TRUE (the default), we condition on the observed values of the covariate, so its measurement level plays no role: lavaan gives a warning and treats the covariate as numeric. With conditional_x = FALSE and fixed_x = FALSE, the covariate is treated like any other ordered variable. It has its own latent response, and its sample statistics are thresholds and polychoric (or polyserial) correlations with the other variables. The parameter table reflects this: the covariate has free thresholds and a scaling factor, its mean is fixed to zero and its variance to one, and its covariances with the other covariates are free. The interpretation of the regression coefficient changes accordingly: it is the effect of the latent response underlying the covariate, not of the observed category scores. This is appropriate for a covariate that is a coarsened version of a continuous variable (an education level, for example), but not for a genuinely categorical covariate such as a treatment indicator, where the conditional approach should be used. The combination conditional_x = FALSE with fixed_x = TRUE is not supported for an ordered covariate, and stops with an error: the moments of a latent response cannot be fixed to the sample values of the observed scores.

14.5 Fitting the SEM: the WLS family

14.5.1 The model for the latent responses

On the model side, the moment structure \boldsymbol{\sigma}(\boldsymbol{\vartheta}) must produce model-implied counterparts of the sample statistics: thresholds and a correlation matrix (plus slopes when conditional_x = TRUE, and variances/means for any continuous variables). Two model matrices are added to the standard LISREL set (introduced in Section 4.8): the threshold vector \boldsymbol{\tau} and the diagonal scaling matrix \boldsymbol{\Delta}. The model-implied variance matrix and mean vector of the latent responses are

\boldsymbol{\Sigma}(\boldsymbol{\vartheta})= \boldsymbol{\Delta}\, \bigl( \boldsymbol{\Lambda}\, (\mathbf{I} - \mathbf{B})^{-1}\boldsymbol{\Psi}\, (\mathbf{I} - \mathbf{B}^{\prime})^{-1}\boldsymbol{\Lambda}^{\prime} + \boldsymbol{\Theta} \bigr)\, \boldsymbol{\Delta}, \qquad \boldsymbol{\mu}(\boldsymbol{\vartheta})= \boldsymbol{\nu}+ \boldsymbol{\Lambda}\, (\mathbf{I} - \mathbf{B})^{-1}\boldsymbol{\alpha}. \tag{14.8}

For rows/columns corresponding to ordinal variables, the diagonal of Equation 14.8 must equal one (the identification constraint Equation 14.3), while the rows/columns of continuous variables are in the covariance metric, with \delta_p = 1 and a free residual variance (Section 14.4.4). The model-implied threshold c of variable p is

\tau_{pc}(\boldsymbol{\vartheta}) = \delta_p\,\bigl(\tau_{pc} - \mu_p(\boldsymbol{\vartheta})\bigr), \tag{14.9}

the threshold parameter minus the model-implied mean of the latent response (the pth element of \boldsymbol{\mu}(\boldsymbol{\vartheta}) in Equation 14.8), scaled by \delta_p. In a single group, the intercepts of the ordinal variables are fixed to zero and the latent means are zero, so the implied thresholds are simply the elements of \boldsymbol{\tau} (times \delta_p); the mean term becomes active once latent means are freed in a multiple-group or longitudinal model (Section 14.6.2). A continuous variable has no thresholds, and its slot in the implied vector holds -\mu_p(\boldsymbol{\vartheta}) alone, which is why the observed means enter the sample statistics vector with a minus sign (Section 14.4.4). With exogenous covariates (conditional_x = TRUE), the model-implied slopes of the latent responses on the covariates are

\boldsymbol{\Pi}(\boldsymbol{\vartheta}) = \boldsymbol{\Delta}\, \boldsymbol{\Lambda}\, (\mathbf{I} - \mathbf{B})^{-1}\boldsymbol{\Gamma}, \tag{14.10}

with \boldsymbol{\Gamma} the matrix of regression coefficients of the latent variables on the covariates (Section 4.7.3); Equation 14.8 and Equation 14.9 then describe the residual moments, and \boldsymbol{\alpha} and \boldsymbol{\Psi} are the intercepts and the residual (co)variances of the latent variables given the covariates. For the fit_x model of Section 14.4.5, the implied slopes are the loadings times the single regression coefficient:

est <- lavInspect(fit_x, "est")
round(cbind(implied      = lavInspect(fit_x, "implied")$res.slopes[, 1],
            lambda.gamma = (est$lambda %*% est$gamma)[, 1]), 4)
   implied lambda.gamma
x1 -0.0016      -0.0016
x2 -0.0014      -0.0014
x3 -0.0017      -0.0017

How the unit-variance constraint is enforced is precisely the difference between the Delta and Theta parameterizations, the subject of the next section.

14.5.2 Delta versus Theta parameterization

The parameterization= argument offers two equivalent ways to absorb the unit-variance constraint:

  • parameterization = "Delta" (the default): the scaling factors are fixed, \delta_p = 1, and the residual variance of each ordinal variable is derived from the constraint:

    \theta_{pp} = 1 - \bigl[\boldsymbol{\Lambda}\, (\mathbf{I} - \mathbf{B})^{-1}\boldsymbol{\Psi}\, (\mathbf{I} - \mathbf{B}^{\prime})^{-1} \boldsymbol{\Lambda}^{\prime}\bigr]_{pp} . \tag{14.11}

    The diagonal of \boldsymbol{\Theta} is filled in after every parameter update.

  • parameterization = "Theta": the residual variances are fixed, \theta_{pp} = 1, and the scaling factors are derived:

    \delta_p = \Bigl( \bigl[\boldsymbol{\Lambda}\, (\mathbf{I} - \mathbf{B})^{-1}\boldsymbol{\Psi}\, (\mathbf{I} - \mathbf{B}^{\prime})^{-1} \boldsymbol{\Lambda}^{\prime}\bigr]_{pp} + 1 \Bigr)^{-1/2}, \tag{14.12}

    recomputed after every parameter update. This is the parameterization used in IRT-style formulations, where the residual variance of the latent response is set to one (as in a probit regression).

In a single-group, single-occasion model, which is the setting of this and the following sections, the two parameterizations are one-to-one reparameterizations of each other: neither the residual variances nor the scale of \mathbf{y}^{\star} is identified, and fixing either one is merely a labeling convention. The model fit, the model-implied correlations, and the standardized solution are identical; only the raw parameter values differ:

fit_theta <- cfa(model, data = HSord, ordered = TRUE,
                 parameterization = "Theta")
c(delta = fitMeasures(fit, "chisq_scaled"),
  theta = fitMeasures(fit_theta, "chisq_scaled"))
delta.chisq.scaled theta.chisq.scaled 
          74.15248           74.15249 
c(delta = coef(fit)["visual=~x2"],
  theta = coef(fit_theta)["visual=~x2"])
delta.visual=~x2 theta.visual=~x2 
       0.6054671        0.4274035 
max(abs(standardizedSolution(fit)$est.std -
        standardizedSolution(fit_theta)$est.std))
[1] 1.53172e-06

The choice acquires substance only when the same items are measured in several groups or at several occasions, where one of the two fixed quantities is freed in all groups but the first; Section 14.6.1 takes this up.

14.5.3 WLS or DWLS?

With the sample statistics \mathbf{s} and the categorical \hat{\boldsymbol{\Gamma}} in hand, estimation proceeds by minimizing the WLS discrepancy function Equation 7.9 of Section 7.4.1. The elements of \mathbf{s} are ordered as: thresholds and (minus) means, interleaved in the order of the variables; probit/linear slopes (if conditional_x = TRUE), column by column; variances of continuous variables (if any); and finally the below-diagonal elements of the covariance matrix, which are correlations among the ordinal variables and covariances elsewhere. The examples of Section 14.4.4 and Section 14.4.5 show the layout; the model-implied vector \boldsymbol{\sigma}(\boldsymbol{\vartheta}) follows the same order.

Full WLS (estimator = "WLS") uses \mathbf{W}= \hat{\boldsymbol{\Gamma}}^{-1} (Browne, 1984; Muthén, 1984). As discussed in Section 7.4.2, this “asymptotically optimal” choice behaves poorly unless the sample is very large: \hat{\boldsymbol{\Gamma}} is a P^{\star} \times P^{\star} matrix estimated from fourth-order information, and P^{\star} grows rapidly with the number of variables and categories. The practical remedy is DWLS (estimator = "DWLS"): only the diagonal of \hat{\boldsymbol{\Gamma}} is inverted to form the weight matrix, while the full \hat{\boldsymbol{\Gamma}} is retained for the correction of standard errors and test statistics (Muthén, 1993; Muthén et al., 1997). Simulation evidence consistently favors DWLS (with robust corrections) over full WLS in realistic sample sizes (Forero et al., 2009; Rhemtulla et al., 2012); ULS (identity weight matrix, again with robust corrections) performs comparably and sometimes slightly better (Forero et al., 2009). This is why DWLS, not WLS, is the de facto standard, and lavaan’s default, for ordinal data.

The running example illustrates the problem. With N= 301 and P^{\star} = 63, we are far below the sample sizes at which full WLS can be trusted:

fit_wls <- cfa(model, data = HSord, ordered = TRUE, estimator = "WLS")
idx <- 1:6  # the free factor loadings
round(cbind(est.DWLS = coef(fit)[idx],
            est.WLS  = coef(fit_wls)[idx],
            se.DWLS  = sqrt(diag(vcov(fit)))[idx],
            se.WLS   = sqrt(diag(vcov(fit_wls)))[idx]), 3)
            est.DWLS est.WLS se.DWLS se.WLS
visual=~x2     0.605   0.658   0.116  0.086
visual=~x3     0.607   0.727   0.112  0.094
textual=~x5    1.080   1.085   0.054  0.045
textual=~x6    1.064   1.040   0.050  0.040
speed=~x8      1.259   1.205   0.180  0.131
speed=~x9      1.867   1.558   0.419  0.163

The estimation itself succeeds (inverting a 63 \times 63 \hat{\boldsymbol{\Gamma}} estimated from 301 cases is still numerically feasible), but the point estimates shift noticeably, and the WLS standard errors are markedly smaller than their DWLS counterparts. This is misleading: in samples of this size, full-WLS standard errors tend to understate the true sampling variability, and the associated test statistic overrejects (Forero et al., 2009). With more variables (or more categories), P^{\star} soon exceeds the number of observations, and \hat{\boldsymbol{\Gamma}} becomes singular: full WLS then fails altogether, while DWLS is unaffected.

14.5.4 The estimator aliases: WLSMV and related names

As with MLM and MLR for continuous data (Section 8.6), the categorical estimator names are aliases that expand into a combination of point estimator, standard error method, and test statistic. The expansions are summarized in Table 14.1.

Table 14.1: Estimator aliases for categorical data and their expansions (categorical setting; for continuous data, the raw DWLS and ULS estimators resolve differently, see Section 7.4.3). For all WLS-family rows, h1_information is forced to "unstructured"; for the DWLS and ULS rows, information_bread resolves to "observed" (Section 14.5.6).
Alias Point estimator se= test=
WLS WLS (full weight matrix) "standard" "standard"
DWLS DWLS "robust.sem" "standard" (reported without a p-value)
WLSM DWLS "robust.sem" "satorra.bentler"
WLSMV DWLS "robust.sem" "scaled.shifted"
WLSMVS DWLS "robust.sem" "mean.var.adjusted"
ULS ULS "robust.sem" "standard" (reported without a p-value)
ULSM ULS "robust.sem" "satorra.bentler"
ULSMV ULS "robust.sem" "scaled.shifted"
ULSMVS ULS "robust.sem" "mean.var.adjusted"

In all cases the point estimates within a family are identical: WLSM, WLSMV, and WLSMVS all minimize the same DWLS discrepancy function; they differ only in the test statistic (and, historically, in nothing else). The suffix conventions mirror Mplus (Muthén & Muthén, 2012): M for mean-adjusted, MV for mean-and-variance adjusted. As explained in Section 8.5.7, the WLSMV alias currently maps to the scaled-and-shifted statistic (which keeps the integer degrees of freedom), while the original Satterthwaite-style statistic with fractional degrees of freedom has been renamed WLSMVS.

When estimator = "DWLS" (or "ULS") is requested literally with categorical data, the test defaults to "standard": the unscaled statistic X^2 = (N- 1) F_{\mathrm{DWLS}}(\hat{\boldsymbol{\vartheta}}). Because the DWLS weight matrix is not a consistent estimate of \boldsymbol{\Gamma}^{-1}, this statistic does not follow a chi-square distribution, not even asymptotically, and not even if the data were ideal. lavaan therefore prints P-value (Unknown) and NA. Always use one of the robust aliases (WLSMV, WLSM, WLSMVS) or an explicit robust test= for inference.

14.5.5 Worked example: CFA with ordinal items

The full output for the running example is shown below:

summary(fit)
lavaan 0.7-4 ended normally after 29 iterations

  Estimator                                       DWLS
  Optimization method                           NLMINB
  Number of model parameters                        39

  Number of observations                           301

Model Test User Model:
                                              Standard      Scaled
  Test Statistic                                51.537      74.152
  Degrees of freedom                                24          24
  P-value (Unknown)                                 NA       0.000
  Scaling correction factor                                  0.741
  Shift parameter                                            4.621
    simple second-order correction                                

Parameter Estimates:

  Parameterization                               Delta
  Standard errors                           Robust.sem
  Information                                 Expected
  Information bread                           Observed
  Information saturated (h1) model        Unstructured

Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|)
  visual =~                                           
    x1                1.000                           
    x2                0.605    0.116    5.215    0.000
    x3                0.607    0.112    5.423    0.000
  textual =~                                          
    x4                1.000                           
    x5                1.080    0.054   19.933    0.000
    x6                1.064    0.050   21.408    0.000
  speed =~                                            
    x7                1.000                           
    x8                1.259    0.180    6.988    0.000
    x9                1.867    0.419    4.459    0.000

Covariances:
                   Estimate  Std.Err  z-value  P(>|z|)
  visual ~~                                           
    textual           0.342    0.052    6.633    0.000
    speed             0.184    0.039    4.747    0.000
  textual ~~                                          
    speed             0.103    0.034    3.034    0.002

Thresholds:
                   Estimate  Std.Err  z-value  P(>|z|)
    x1|t1            -0.605    0.078   -7.798    0.000
    x1|t2             0.113    0.073    1.548    0.122
    x1|t3             0.709    0.080    8.901    0.000
    x2|t1            -0.527    0.076   -6.902    0.000
    x2|t2             0.180    0.073    2.465    0.014
    x2|t3             0.741    0.080    9.228    0.000
    x3|t1            -0.586    0.077   -7.575    0.000
    x3|t2             0.113    0.073    1.548    0.122
    x3|t3             0.688    0.079    8.682    0.000
    x4|t1            -0.596    0.077   -7.686    0.000
    x4|t2             0.180    0.073    2.465    0.014
    x4|t3             0.741    0.080    9.228    0.000
    x5|t1            -0.576    0.077   -7.463    0.000
    x5|t2             0.113    0.073    1.548    0.122
    x5|t3             0.677    0.079    8.573    0.000
    x6|t1            -0.576    0.077   -7.463    0.000
    x6|t2             0.021    0.073    0.287    0.774
    x6|t3             0.730    0.080    9.119    0.000
    x7|t1            -0.576    0.077   -7.463    0.000
    x7|t2             0.012    0.073    0.172    0.863
    x7|t3             0.677    0.079    8.573    0.000
    x8|t1            -0.656    0.079   -8.352    0.000
    x8|t2             0.012    0.073    0.172    0.863
    x8|t3             0.677    0.079    8.573    0.000
    x9|t1            -0.646    0.078   -8.242    0.000
    x9|t2             0.037    0.073    0.516    0.606
    x9|t3             0.677    0.079    8.573    0.000

Variances:
                   Estimate  Std.Err  z-value  P(>|z|)
   .x1                0.386                           
   .x2                0.775                           
   .x3                0.774                           
   .x4                0.327                           
   .x5                0.214                           
   .x6                0.237                           
   .x7                0.781                           
   .x8                0.652                           
   .x9                0.236                           
    visual            0.614    0.111    5.544    0.000
    textual           0.673    0.050   13.339    0.000
    speed             0.219    0.072    3.033    0.002

Reading the output from top to bottom:

  • The header reports 39 free parameters: 6 loadings, 3 factor covariances, 3 factor variances, and 27 thresholds. With P^{\star} = 63 sample statistics, the model has 63 - 39 = 24 degrees of freedom, the same degrees of freedom as the continuous version of this model, which is no coincidence: each variable trades one mean and one variance for three thresholds (+9 statistics and +9 parameters relative to the continuous case, when a mean structure is included).

  • The header also shows two test statistics side by side. The Standard column is the raw DWLS statistic (no p-value, as just discussed); the Scaled column is the scaled-and-shifted statistic of Section 8.5.7, together with its scaling correction factor and shift parameter, and labeled simple second-order correction (Asparouhov & Muthén, 2010a).

  • The Parameter Estimates header block shows Standard errors: Robust.sem and Information: Expected, plus the line Information bread: Observed: the standard errors are sandwich estimates whose bread is based on the full Hessian of the DWLS fit function rather than on the expected information (Lai & Simoes, 2023). The default used to be the expected information; the change is discussed in Section 14.5.6.

  • The Latent Variables and Covariances sections look exactly as in the continuous case, but all parameters now refer to the latent responses: the loading of x2 is the expected increase in the (standardized) latent response y^{\star}_2 per unit increase of the visual factor.

  • The Thresholds section lists the 27 threshold estimates with robust standard errors. Because we cut at the quartiles, the estimates are close to the theoretical quartile z-values (\pm 0.67 and 0), as expected.

  • In the Variances section, the residual variances of the ordinal variables (prefixed with a dot) are printed without standard errors: under the (default) Delta parameterization they are not free parameters but derived quantities (Equation 14.11, discussed in Section 14.5.2). The factor (co)variances are ordinary free parameters.

The scaled test statistic and the associated fit measures are available via fitMeasures(); the .scaled suffix refers to the robust versions (and .robust to the distinct robust CFI/RMSEA variants discussed in Section 10.3.1):

fitMeasures(fit, c("chisq", "df", "chisq_scaled", "df_scaled",
                   "pvalue_scaled", "chisq_scaling_factor",
                   "cfi_scaled", "rmsea_scaled", "srmr"))
               chisq                   df         chisq.scaled 
              51.537               24.000               74.152 
           df.scaled        pvalue.scaled chisq.scaling.factor 
              24.000                0.000                0.741 
          cfi.scaled         rmsea.scaled                 srmr 
               0.962                0.083                0.066 

14.5.6 Standard errors and test statistics

No new methods are needed for inference in the categorical setting: the formulas of chapter 8 apply verbatim, with the categorical \hat{\boldsymbol{\Gamma}} of Equation 14.7 taking the place of its continuous-data counterpart. Concretely:

  • se = "robust.sem" (the default for all DWLS and ULS aliases; full WLS defaults to se = "standard") computes a sandwich with meat \hat{\boldsymbol{\Delta}}^{\prime} \mathbf{W}\hat{\boldsymbol{\Gamma}} \mathbf{W}\hat{\boldsymbol{\Delta}}, where \mathbf{W} is the weight matrix of the point estimator (the diagonal DWLS matrix, or the identity for ULS) and \hat{\boldsymbol{\Gamma}} the categorical ADF estimator. For the bread, two choices exist. The classic choice is the expected information \hat{\boldsymbol{\Delta}}^{\prime} \mathbf{W}\hat{\boldsymbol{\Delta}}; the sandwich is then exactly Equation 8.27 of Section 8.4.4 with \mathbf{A}_E(\boldsymbol{\sigma}) = \mathbf{W}, yielding the standard errors of Muthén et al. (1997). But as Lai and Simoes (2023) point out, this bread drops the second-order term of the Hessian of the fit function (the term involving the residuals \mathbf{s}- \hat{\boldsymbol{\sigma}}) and is therefore consistent only if the model fits perfectly; whenever it does not (and even a correctly specified model misfits in a finite sample), the resulting standard errors tend to understate the true sampling variability. lavaan therefore uses the observed information \mathbf{A}_O, the full Hessian of the DWLS fit function, as the default bread in this setting: information_bread = "default" resolves to "observed", and summary() reports this in the Information bread line seen in Section 14.5.5. The observed bread remains consistent regardless of model fit, and reduces to the expected bread for a perfectly fitting model. Only the standard errors are affected (the point estimates and all test statistics are not), and the classic standard errors of Muthén et al. (1997) remain available via information_bread = "expected". The new default is confined to categorical DWLS/ULS with se = "robust.sem", single-level as well as two-level (Section 16.11); full WLS, PML, and the cluster-robust variants are unaffected. Because \hat{\boldsymbol{\Gamma}} requires complete-data casewise scores, se = "robust.sem" is a complete-data (or pairwise-deletion, see Section 14.8) method; also, no normal-theory \hat{\boldsymbol{\Gamma}}^{\mathrm{NT}} exists for categorical data, so se = "robust.sem.nt" is not available and raises an error.

  • The robust tests are the scaled and adjusted statistics of Section 8.5.4, Section 8.5.6, and Section 8.5.7, built from the residual weight matrix \mathbf{U} and the categorical \hat{\boldsymbol{\Gamma}}. The mean-and-variance adjusted statistic was proposed for this very setting by Muthén (1993) (see also Savalei and Rosseel (2022) for a systematic treatment); the scaled-and-shifted variant of Asparouhov and Muthén (2010a) is the WLSMV default. The traces \mathrm{tr}[\mathbf{U}\boldsymbol{\Gamma}] and \mathrm{tr}[(\mathbf{U}\boldsymbol{\Gamma})^2] are accumulated in the T-dimensional parameter space without ever forming the P^{\star} \times P^{\star} product, a substantial saving precisely in the categorical case, where P^{\star} is large.

  • The residual-based tests of Section 8.5.10 are also available; test = "browne.residual.adf" uses the same categorical \hat{\boldsymbol{\Gamma}}, and for full WLS it reproduces the standard WLS chi-square.

  • With clustered data, se = "robust.cluster.sem" combined with the cluster-corrected \hat{\boldsymbol{\Gamma}}^{\mathrm{clus}} (computed in step 3, see Section 14.4.3) is the default whenever a cluster= argument is present, mirroring TYPE = COMPLEX in Mplus.

For example, requesting several test statistics at once:

fit_tests <- cfa(model, data = HSord, ordered = TRUE,
                 test = c("scaled.shifted", "mean.var.adjusted",
                          "browne.residual.adf"))
lavTest(fit_tests, output = "text")
Model Test User Model:
                                              Standard      Scaled
  Test Statistic                                51.537      74.152
  Degrees of freedom                                24          24
  P-value (Unknown)                                 NA       0.000
  Scaling correction factor                                  0.741
  Shift parameter                                            4.621
    simple second-order correction                                
                                                                  
  Test Statistic                                51.537      56.142
  Degrees of freedom                                24      15.647
  P-value (Unknown)                                 NA       0.000
  Scaling correction factor                                  0.918
    mean and variance adjusted correction                         
                                                      
  Browne's residual-based (ADF) test                  
  Test statistic                                82.325
  Degrees of freedom                                24
  P-value (Chi-square)                           0.000

Note the fractional degrees of freedom of the mean-and-variance adjusted statistic, and that all three robust statistics lead to the same substantive conclusion here.

One extension of this approach is covered elsewhere in the book: the three-stage WLSMV pipeline also comes in a two-level version, in which the unrestricted thresholds and within/between (residual) correlations are estimated stage-wise from small two-level probit models, and the model is fitted to them by DWLS. Because the implementation is inseparable from the multilevel structure (level blocks, within/between decomposition, cluster-wise sandwich), it is treated in the multilevel chapter, in Section 16.11.

14.6 Multiple groups and multiple occasions

Up to this point, the setting was a single group, observed once. In that setting, the scale of each latent response y^{\star}_p is a pure convention: the data cannot distinguish one choice from another, and we standardized (\nu_p = 0, unit variance) in the only group there is (Section 14.2.2). The situation changes fundamentally when the same ordinal items are administered to several groups, or to the same subjects at several occasions (Muthén & Asparouhov, 2002). Standardizing the latent responses to unit variance in every group would then no longer be a convention but a substantive restriction: the variance of y^{\star}_p in group g is [\boldsymbol{\Lambda}_g \boldsymbol{\Psi}_g \boldsymbol{\Lambda}_g^{\prime} + \boldsymbol{\Theta}_g]_{pp}, so genuine across-group differences in loadings, factor variances, or residual variances all express themselves as across-group differences in these variances, and forcing them to one in each group hides them. The solution follows the logic of measurement invariance: once enough measurement parameters (thresholds, and possibly loadings) are equated across groups, the scales of the latent responses in the non-reference groups become identified, and can (and should) be estimated.

This section works this out in three steps: how the freed scale of y^{\star}_p is parameterized (the Delta versus Theta choice of Section 14.5.2, which was immaterial until now and here starts to matter); which sequences of across-group equality constraints are identified and genuinely testable (the Wu–Estabrook scheme); and the longitudinal case, where the “groups” are the same subjects at different time points, so that all constraints must be written inside a single model.

14.6.1 The parameterization choice across groups

With multiple groups (or occasions), the two parameterizations of Section 14.5.2 differ. Once cross-group equality constraints on thresholds and loadings identify the scale of the latent responses in the non-reference groups, one of the two fixed quantities can be freed: under the Delta parameterization, the scaling factors (~*~) are freed in the other groups (this is what the auto_delta option automates; see Section 3.2.12), whereas under the Theta parameterization the residual variances (~~) are freed. A small illustration with the school grouping variable, constraining loadings and thresholds to be equal across groups:

mg_delta <- cfa('visual =~ x1 + x2 + x3', data = HSord, ordered = TRUE,
                group = "school",
                group_equal = c("loadings", "thresholds"),
                se = "none", test = "none")  # parameter table only
pt <- parTable(mg_delta)
pt[pt$op == "~*~" & pt$group == 2, c("lhs", "op", "rhs", "group", "free")]
   lhs  op rhs group free
40  x1 ~*~  x1     2   25
41  x2 ~*~  x2     2   26
42  x3 ~*~  x3     2   27

Under the default Delta parameterization, the scaling factors of the second group have become free parameters (through auto_delta). With parameterization = "Theta", the residual variances take that role instead:

mg_theta <- cfa('visual =~ x1 + x2 + x3', data = HSord, ordered = TRUE,
                group = "school", parameterization = "Theta",
                group_equal = c("loadings", "thresholds"),
                se = "none", test = "none")
pt <- parTable(mg_theta)
pt[pt$op == "~~" & pt$lhs == pt$rhs & pt$group == 2 &
   pt$lhs %in% paste0("x", 1:3),
   c("lhs", "op", "rhs", "group", "free", "est")]
   lhs op rhs group free   est
36  x1 ~~  x1     2   24 0.998
37  x2 ~~  x2     2   25 0.611
38  x3 ~~  x3     2   26 0.857

The two model fits are still identical, because the freed \delta_{p,g} and the freed \theta_{pp,g} carry the same information, but the interpretation of the freed parameters differs, and this is where the choice acquires substance (Muthén & Asparouhov, 2002). A freed scaling factor \delta_{p,g} conflates three potential sources of across-group difference (loadings, factor variances, and residual variances) into a single number. The Theta parameterization names the residual variances directly, so hypotheses about them can be expressed: a model with residual variances constrained equal across groups (strict invariance for ordinal indicators) is a well-defined restricted model under parameterization = "Theta", but cannot be specified under the Delta parameterization. The Theta parameterization is therefore the natural choice whenever the residual variances are themselves the object of study. The two parameterizations also differ in how an inadmissible solution appears. Under the Delta parameterization, the derived residual variance in Equation 14.11 can turn negative, and such a Heywood case is immediately visible in the output. Under the Theta parameterization, the derived \delta_p in Equation 14.12 always exists and the residual variance is fixed (in the reference group; a residual variance freed in another group can still be estimated negative), so the same misfit cannot produce a negative variance there; it manifests itself instead in loadings or factor variances that drift to very large values (pushing the implied correlation toward one), or in a failure to converge, which is harder to recognize for what it is. Note also that the two-level categorical implementation requires parameterization = "Theta" (see Section 16.11), and that the automatic bounds of Section 6.2.2 are adapted under the Theta parameterization. Those bounds take the observed variance of an indicator as the ceiling for its residual variance and, through the marker indicator, for the variance of its factor. For an ordinal indicator, the “observed” variance is the unit variance of the standardized latent response, which under the Delta parameterization is indeed the total variance of y^{\star}_p. Under the Theta parameterization, however, the fixed residual variance already accounts for one unit, and the total variance of the unscaled latent response, \lambda_{pm}^2 \psi_{mm} + 1, exceeds one, so the unit ceiling would cut off legitimate solutions. lavaan therefore inflates the variance used for the bounds of every indicator with a fixed unit residual variance and a scaling parameter, dividing it by the minimum marker reliability of optim_bounds, and sets the lower bound of every marker-identified factor variance to that reliability.

14.6.2 Measurement invariance: the Wu–Estabrook scheme

For continuous indicators, multiple-group measurement invariance is tested with the familiar configural–metric–scalar sequence of Section 11.2.10: equate the loadings, then the intercepts, and compare the nested models with lavTestLRT(). This procedure should not be carried over to ordered indicators. The reason lies in the identification analysis of Section 14.2.2. For an ordered indicator, all the data provide is a table of category proportions (per group): the thresholds \boldsymbol{\tau}_p, the intercept \nu_p, the loading \lambda_{pm}, and the scale of the latent response y^{\star}_p are entangled, and the configural model resolves the indeterminacy by fixing \nu_p = 0 and the scale of y^{\star}_p to one in every group, while leaving all thresholds free. In that setting, a naive “metric” step that equates the loadings across groups while the thresholds remain free does not test what it appears to test: the free thresholds can absorb what the constrained loadings no longer can, and the “restricted” model is, in whole or in part, merely a reparameterization of the configural one.

Wu and Estabrook (2016) analyzed this identification problem systematically (building on Millsap & Yun-Tein, 2004) and derived which patterns of cross-group equality constraints are identified and produce genuinely nested, testable comparisons. Their scheme reorders the sequence (for ordered indicators, the thresholds come first), and it obeys one guiding principle: every time a block of measurement parameters is equated across groups, some previously fixed identification parameters become estimable, and must be freed. Concretely, for an ordered indicator with three or more categories:

  1. Configural: same structure in all groups; all thresholds free; \nu_p = 0 and the scale of y^{\star}_p fixed to one in every group;
  2. Threshold invariance: the thresholds are equated across groups; in exchange, in all groups but the first, the intercepts \nu_p and the scales of y^{\star}_p (the scaling factors under the Delta parameterization; the residual variances under the Theta parameterization, cf. Section 14.5.2) are freed;
  3. Threshold + loading invariance: additionally, the loadings are equated;
  4. Threshold + loading + intercept invariance: the intercepts return to being equal across groups (their identification value of zero), and in exchange the latent means are freed in all groups but the first. This is the model that allows for latent mean comparisons.

Step 2 is error-prone when carried out by hand, and lavaan performs it automatically: adding "thresholds" to group_equal= frees the ordinal intercepts and the scaling factors (or residual variances) in the non-reference groups, and "intercepts" triggers the exchange of step 4. Reusing the HSord data and the three-factor model from earlier in this chapter, with school as the grouping variable:

fit_c   <- cfa(model, data = HSord, ordered = TRUE, group = "school")
fit_t   <- cfa(model, data = HSord, ordered = TRUE, group = "school",
               group_equal = "thresholds")
fit_tl  <- cfa(model, data = HSord, ordered = TRUE, group = "school",
               group_equal = c("thresholds", "loadings"))
fit_tli <- cfa(model, data = HSord, ordered = TRUE, group = "school",
               group_equal = c("thresholds", "loadings", "intercepts"))
lavTestLRT(fit_c, fit_t, fit_tl, fit_tli)
Scaled and Shifted Chi-Squared Difference Test (method = "satorra.2000")

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_c   48          62.202                                          
fit_t   57          64.221      6.277 0.00000       9     0.7119    
fit_tl  63          64.793      0.873 0.00000       6     0.9900    
fit_tli 69         118.134     43.890 0.22897       6  7.773e-08 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Because the models were fitted with the default estimator, which implies test = "scaled.shifted", lavTestLRT() automatically applies the scaled-and-shifted difference test (Section 11.2.4). Threshold invariance and loading invariance are not rejected; the intercept step is strongly rejected, the same substantive verdict as for the continuous versions of these data in Section 11.2.10, where the intercepts of x3 and x7 were responsible. The degrees of freedom are worth working out once, as they illustrate the exchange principle. Each item has three thresholds, so step 2 equates 9 \times 3 = 27 thresholds while freeing 9 intercepts and 9 scaling factors in the second group: \Delta df = 27 - 18 = 9. Step 3 equates the six non-marker loadings: \Delta df = 6. Step 4 re-equates the nine intercepts and frees three latent means: \Delta df = 9 - 3 = 6.

When these models are compared by their fit measures, the scaled versions (cfi_scaled, rmsea_scaled) are the ones to use from step 2 onwards. The robust versions (cfi_robust, rmsea_robust) are based on the fit of the model to the polychoric correlations only, with free and unrestricted thresholds (Section 10.3.1); they are available for the configural model, but they are reported as NA (with a warning) as soon as the thresholds are equated across groups.

One boundary case remains. For a binary indicator (a single threshold), the exchange in step 2 is one-for-one: equating its one threshold while freeing its intercept changes nothing, so lavaan does not free the scale for binary items. With purely binary indicators, threshold invariance is empirically indistinguishable from the configural model. Thresholds and loadings must then be equated jointly before anything is testable, which is why Wu and Estabrook (2016) devote separate propositions to the binary case.

14.6.3 Longitudinal data: occasions as dependent groups

When the same ordinal items are administered to the same subjects at several occasions, the time points play the role of the groups (Muthén & Asparouhov, 2002): to compare the latent variable over time, or to fit a growth model to it, the latent responses must be in the same metric at every occasion, which again requires threshold (and loading) invariance, now across occasions; and the scales of the latent responses, fixed at the first occasion, must be freed at the later ones. Forcing unit variances of the latent responses at every occasion is not without consequences. In a growth model, for instance, the variance of y^{\star}_{pt} (item p at occasion t) changes over time by construction (through the slope variance, the intercept–slope covariance, and the occasion-specific residual variance), so a unit-variance-everywhere restriction distorts the very structure the model is meant to capture; with binary indicators it rules out the growth model altogether (Muthén & Asparouhov, 2002).

There is one crucial practical difference with the multiple-group case: the occasions are recorded in the same data rows, so the “groups” are dependent. There is no group= argument, hence no group_equal= and no auto_delta assistance: the items of all waves appear side by side in a single model, and every equality constraint and every freed scale must be written explicitly, using labels. In addition, the residuals of the same item at different occasions are typically correlated, and these residual covariances belong in the model (the WLS estimators accommodate them without difficulty: they are simply additional polychoric correlations to reproduce). For a construct measured by three four-category items at two occasions, the threshold-invariance model reads:

model_wide <- '
  # one factor per occasion
  eta1 =~ 1*y1t1 + la2*y2t1 + la3*y3t1
  eta2 =~ 1*y1t2 + la2*y2t2 + la3*y3t2

  # thresholds: equal across occasions (same labels)
  y1t1 | t11*t1 + t12*t2 + t13*t3
  y1t2 | t11*t1 + t12*t2 + t13*t3
  y2t1 | t21*t1 + t22*t2 + t23*t3
  y2t2 | t21*t1 + t22*t2 + t23*t3
  y3t1 | t31*t1 + t32*t2 + t33*t3
  y3t2 | t31*t1 + t32*t2 + t33*t3

  # y* scales: fixed to one at occasion 1, freed at occasion 2
  y1t2 ~*~ y1t2
  y2t2 ~*~ y2t2
  y3t2 ~*~ y3t2

  # residual correlations: same item, different occasions
  y1t1 ~~ y1t2
  y2t1 ~~ y2t2
  y3t1 ~~ y3t2

  # latent means: fixed at occasion 1, freed at occasion 2
  eta1 ~ 0*1
  eta2 ~ 1
'
fit_wide <- sem(model_wide, data = Data, ordered = TRUE)

Every ingredient of the multiple-group case reappears in labeled form: shared threshold labels across occasions (the analog of group_equal = "thresholds"), shared loading labels (la2, la3), freed ~*~ scale factors at occasion 2 (what auto_delta would have done for a second group), and a freed latent mean at occasion 2, plus the lagged residual covariances, which have no multiple-group counterpart. Under parameterization = "Theta", the freed ~*~ lines are replaced by freed residual variances (y1t2 ~~ y1t2, …).

Writing such syntax by hand is instructive once. For real applications (more occasions, partial invariance, groups and occasions simultaneously, a mix of continuous and ordered indicators), the measEq.syntax() function in the semTools package is the recommended tool. It is considerably more powerful than the group_equal= shortcuts: it generates complete, labeled lavaan syntax for any level of the invariance hierarchy, in either parameterization, under several identification conventions (including the Wu–Estabrook scheme of the previous subsection and the earlier conventions of Millsap and Yun-Tein (2004)), and, crucially, it also handles dependent groups: repeated measures, longitudinal designs, and combinations of independent groups and occasions, exactly the settings where writing the constraints by hand becomes challenging.

14.7 Pairwise maximum likelihood

The three-stage WLS approach is computationally attractive, but it is not a likelihood method: there is no log-likelihood, no likelihood ratio test, and no principled way to handle missing data beyond deletion. Pairwise maximum likelihood (PML), described in Section 7.5, offers an intermediate approach: it maximizes the sum of all bivariate log-likelihoods Equation 7.12, estimating thresholds, correlations, and structural parameters simultaneously in a single optimization. Only bivariate normal probabilities Equation 14.5 are ever evaluated, so the method scales to many factors where marginal ML (with its high-dimensional integrals) becomes infeasible.

fit_pml <- cfa(model, data = HSord, ordered = TRUE, estimator = "PML")

14.7.1 Standard errors: the Huber–White sandwich

Because the pairwise log-likelihood is a composite likelihood (the bivariate contributions overlap and are not independent), the information matrix equality fails by construction, and conventional standard errors would be wrong even for perfectly normal latent responses. The appropriate asymptotic variance matrix is the Huber–White sandwich Equation 8.28 of Section 8.4.8 (the inverse Godambe information, in the terminology of the composite likelihood literature), built from the Hessian of the pairwise log-likelihood (the bread) and the crossproduct of the casewise pairwise scores (the meat). Accordingly, the PML estimator forces information = "observed" and defaults to se = "robust.huber.white" (Katsikatsou et al., 2012). The pairwise log-likelihood has an analytic gradient; the casewise scores feed the first-order information matrix exactly as described in Section 8.2.3. With clustered data, se = "robust.cluster" (the cluster-aggregated version of the same sandwich) is the default.

14.7.2 The pairwise likelihood ratio test

PML also provides a likelihood-ratio-type test for overall fit. The pairwise likelihood ratio test (PLRT) statistic compares the fitted model against the unrestricted (\mathsf{H}_1) model:

\mathrm{PLRT} = 2\bigl[\, pl(\hat{\boldsymbol{\vartheta}}_{\mathrm{h1}}) - pl(\hat{\boldsymbol{\vartheta}}_{\mathrm{h0}}) \,\bigr]. \tag{14.13}

Like the WLS statistics under a misspecified weight matrix, the PLRT is asymptotically distributed as a weighted sum of independent \chi^2(1) variables, with weights given by the eigenvalues of the product of the Hessian and the sandwich matrix of the previous section (Katsikatsou et al., 2012). lavaan applies a first- and second-moment (Satterthwaite-style) adjustment, which is why the only supported test for PML is test = "mean.var.adjusted" (any other single test= value is silently replaced by it, and a vector of tests is rejected): the summary output reports the adjusted statistic with fractional degrees of freedom, labeled mean+var adjusted correction (PML):

fit_pml
lavaan 0.7-4 ended normally after 57 iterations

  Estimator                                        PML
  Optimization method                           NLMINB
  Number of model parameters                        39

  Number of observations                           301

Model Test User Model:
                                              Standard      Scaled
  Test Statistic                                49.716     164.105
  Degrees of freedom                                24      45.551
  P-value (Unknown)                                 NA       0.000
  Scaling correction factor                                  0.303
    mean+var adjusted correction (PML)                            

Internally, the overall PLRT is computed by fitting the unrestricted model with PML to obtain pl(\hat{\boldsymbol{\vartheta}}_{\mathrm{h1}}), and the moment adjustments are computed from the sandwich and Hessian matrices evaluated under \mathsf{H}_0. A technical subtlety: when the thresholds are structured (fixed values or equality constraints), the nuisance-parameter argument underlying the default computation no longer applies, and an alternative implementation is used instead (see the implementation notes, Section 14.9).

For nested model comparisons, lavTestLRT() computes the corresponding adjusted PLRT difference test (Katsikatsou & Moustaki, 2016); the output also reports pairwise information criteria (PL-AIC and PL-BIC):

model0 <- '
  visual  =~ x1 + x2 + x3
  textual =~ x4 + x5 + x6
  speed   =~ x7 + x8 + x9
  visual ~~ 0*textual
'
fit_pml0 <- cfa(model0, data = HSord, ordered = TRUE, estimator = "PML")
lavTestLRT(fit_pml0, fit_pml)
Mean and Variance Adjusted Chi-Squared Difference Test (method = "mean.var.adjusted.PLRT")

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 PL_AIC PL_BIC   Chisq Chisq diff Df diff Pr(>Chisq)  
fit_pml  24  59371  60253  49.715                                
fit_pml0 25  59505  60370 192.820     4.6429       1    0.03118 *
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

14.7.3 DWLS versus PML

For complete data, DWLS/WLSMV and PML nearly always agree closely; both are consistent under the same latent-response model, and simulation studies find very similar bias and efficiency (Katsikatsou et al., 2012). The running example is no exception:

idx <- grep("=~|~~", names(coef(fit)))  # loadings, factor (co)variances
round(cbind(DWLS = coef(fit)[idx],
            PML  = coef(fit_pml)[names(coef(fit))[idx]]), 3)
                  DWLS   PML
visual=~x2       0.605 0.605
visual=~x3       0.607 0.610
textual=~x5      1.080 1.085
textual=~x6      1.064 1.070
speed=~x8        1.259 1.264
speed=~x9        1.867 2.042
visual~~visual   0.614 0.608
textual~~textual 0.673 0.667
speed~~speed     0.219 0.192
visual~~textual  0.342 0.336
visual~~speed    0.184 0.173
textual~~speed   0.103 0.097

The loadings and factor covariances agree to about two decimals almost everywhere; the largest discrepancy occurs for the strong x9 loading. The two estimators weight the bivariate information differently, and finite-sample differences of this magnitude are not unusual; neither estimate can be regarded as the correct one.

The practical trade-offs are as follows: PML is a single-step estimator with a genuine (pseudo-)likelihood, natural LRT-type inference, and better options for missing data (Section 14.8), but it is computationally heavier (every iteration evaluates \Phi_2 for all pairs and all category combinations) and, unlike WLSMV, its test statistic cannot be combined with other test= choices. WLSMV remains the faster default; PML is worth considering with incomplete data, or when likelihood-based nested-model testing is desired.

14.8 Missing data

Missing data handling is the main weakness of the categorical setting. The FIML approach of the continuous case (missing = "ml") relies on the multivariate normal likelihood of the observed variables and is not available here: requesting missing = "ml" (or "two.stage", or "robust.two.stage") with categorical endogenous variables produces an error message. The available options are:

  • missing = "listwise" (the default): delete all cases with any missing value.

  • missing = "pairwise" (WLS, DWLS, and ULS families): each univariate model in step 1 uses all cases observed on that variable, and each bivariate model in step 2 uses all cases observed on that pair. The casewise scores of incomplete cases are set to zero for the statistics they cannot inform, and the step 3 sandwich Equation 14.7 is assembled from these available-case scores. Consistency requires the missingness to be MCAR, or, when covariates are involved, missingness that depends only on the (always observed) exogenous covariates (Asparouhov & Muthén, 2010b).

  • missing = "pairwise" and missing = "available.cases" (PML; for the WLS families the second keyword is accepted as a synonym of the first): the complete-pairs and available-cases pairwise likelihoods (Katsikatsou et al., 2022) discussed in Section 7.5.3. These use the same missing= keywords but a different mechanism: the pairwise log-likelihood itself is restricted to the observed pairs (and, for "available.cases", augmented with univariate contributions of singly observed variables).

  • missing = "doubly.robust" (PML only): the doubly robust approach of Katsikatsou et al. (2022), in which the pairwise likelihood is weighted by estimated conditional probabilities of the missing responses given the observed ones. This option requires additional input from the user: the required conditional probabilities (obtained from a saturated model fitted with missing = "available.cases") must be supplied by the user via the control= argument. The helper functions that compute them are internal (see the implementation notes, Section 14.9); the PML tutorial on the lavaan website gives a worked example.

A small illustration with MCAR missingness (10% per variable):

set.seed(1234)
HSmiss <- HSord
for (v in paste0("x", 1:9)) {
  HSmiss[[v]][sample(nrow(HSmiss), 30)] <- NA
}
fit_pw <- cfa(model, data = HSmiss, ordered = TRUE, missing = "pairwise")
fitMeasures(fit_pw, c("chisq_scaled", "df_scaled", "pvalue_scaled"))
 chisq.scaled     df.scaled pvalue.scaled 
       67.875        24.000         0.000 

No cases are deleted here: all 301 rows contribute to at least some of the sample statistics. The pairwise coverage, the proportion of jointly observed cases for each variable pair, can be inspected with lavInspect(fit_pw, "coverage") and is worth checking, since a sparsely covered pair yields a poorly determined polychoric correlation. Note that the auxiliary-variables approach of Section 7.3.5 is tied to the FIML likelihood and is likewise unavailable here. As a general-purpose alternative that works for any estimator (and under MAR), multiple imputation via the lavaan.mi package remains available (cf. appendix F.2 for the missing-data option overview).

14.9 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 14.2 maps the stage-wise categorical procedures of this chapter to their source files.

Table 14.2: Internal files implementing the categorical \mathsf{H}_1 estimation and the PML procedures. The formulas evaluated by the lav_uv*/lav_bv* kernels are given in appendix C; each of these files has a two-level counterpart (_2l in the file name) used in the multilevel categorical setting (see Section 16.11).
File Contents
lav_uvord.R univariate ordered probit model: thresholds (+ slopes); closed-form thresholds via lav_uvord_th(); ML fit via lav_uvord_fit() (analytic gradient and Hessian on a shared cache environment)
lav_uvreg.R univariate linear regression via lav_uvreg_fit(): intercept, slopes, residual variance (continuous variables)
lav_bvord.R bivariate ordinal model: polychoric (and tetrachoric) correlations via lav_bvord_cor_twostep_fit(), casewise scores, Hessian
lav_bvmix.R bivariate mixed ordinal/linear model: polyserial (and biserial) correlations via lav_bvmix_cor_twostep_fit()
lav_bvreg.R bivariate linear model: Pearson correlations via lav_bvreg_cor_twostep_fit(); also the bivariate normal density/CDF primitives used by the other kernels
lav_uvbv_common.R shared infrastructure: cache environments, optimizer function tables, weight checks
lav_samplestats_step1.R the step 1 loop over variables; lav_samp_step1_empty_cells() tracks the pseudo-thresholds inserted for unobserved extreme categories
lav_samplestats_step2.R the step 2 loop over variable pairs
lav_muthen1984.R muthen1984() drives the three steps; step 3 is decomposed into lav_m84_layout(), lav_m84_a11(), lav_m84_a21(), lav_m84_a22() and the analytic block inverse lav_m84_b_inv(); its numeric_bread argument ("observed", or "identity" under mimic = "Mplus") selects the bread blocks of the pairs that involve a numeric variable, with the observed second derivatives supplied by lav_bvreg_cor_hessian_uni_cache() and lav_bvmix_cor_hessian_uni_cache(); the delta-rule matrix back to the variance metric is called H in the code; the function returns the sandwich \mathbf{A}^{-1}\mathbf{B}(\mathbf{A}^{-1})^{\prime} as WLS.W; multiplied by N it becomes the NACOV slot of the sample statistics object (the weight matrices derived from it are the WLS.V and WLS.VD slots)
lav_samplestats_wls_obs.R
lav_model_wls.R
the layout of the sample statistics vector (lav_samp_wls_obs()) and of its model-implied counterpart (lav_model_wls_est()): thresholds/means (the means with a minus sign), slopes, variances, correlations
lav_representation_lisrel.R model-implied moments for categorical data: lav_lisrel_sigma(), lav_lisrel_th() (Equation 14.9), and lav_lisrel_pi() (the implied slopes, Equation 14.10); derived residual variances (lav_lisrel_residual_variances(), Delta parameterization) and derived scaling factors (lav_lisrel_delta(), Theta parameterization)
lav_options_estimator.R expansion of the estimator aliases: lav_options_est_dwls(), lav_options_est_uls(), and lav_options_est_pml() (which forces information = "observed")
lav_model_gradient_pml.R analytic gradient and casewise scores for pairwise ML
ctr_pml_doubly_robust_utils.R helper functions for missing = "doubly.robust", which compute the conditional probabilities of the missing responses given the observed ones from a saturated available.cases fit (lav_pml_object_uni_pairwise_unconstr() and companions); not exported
lav_pml_plrt.R
lav_pml_plrt2.R
lav_pml_test_plrt.R
PML likelihood-ratio tests: lav_pml_plrt() (overall PLRT), lav_pml_plrt2() (used when the thresholds are structured), nested comparisons

The quasi-Newton optimizer used by the univariate (lav_uvord_fit()) and bivariate (polychoric, polyserial) kernels is R’s nlminb(), called with the analytic gradient and Hessian of each kernel; the wrappers that pair every kernel with its objective, gradient, and Hessian are created by lav_uvbv_min_fns() in lav_uvbv_common.R, and lav_uvbv_optim_fns() drops the derivatives that a given optimizer variant does not use. This is the same routine that serves as the default optimizer for the model parameters (see the implementation notes of the estimation chapter, Section 7.12.1).

Steps 1 and 2 of Section 14.4.1 and Section 14.4.2 can be reproduced by hand with the internal kernels (note the lavaan::: prefix; these functions are not exported and their interface may change). First the univariate fits of x1 and x2, then the two-step polychoric correlation with the univariate parameters held fixed:

f1 <- lavaan:::lav_uvord_fit(y = as.integer(HSord$x1))
f2 <- lavaan:::lav_uvord_fit(y = as.integer(HSord$x2))
lavaan:::lav_bvord_cor_twostep_fit(fit_y1 = f1, fit_y2 = f2)
[1] 0.3067054