3  The parameter table

$$

$$

The parameter table is the central data structure of lavaan: it captures the full specification of a model. It contains a complete record of all parameters, and once the model is estimated, it also stores the corresponding results, including point estimates and standard errors. Many functions in lavaan, such as parameterEstimates() and summary(), present information drawn from the parameter table, either as a standard R data.frame or as formatted text output.

Three aspects of the parameter table are distinguished throughout this chapter. First, there is the parameter table as a concept: a tabular description of a model, one row per parameter, with a fixed set of columns whose names and meanings have been stable for fifteen years. Second, there is its R representation: within lavaan, the table is stored as a plain list, and is presented to the user as a data.frame. Third, there is its role as an interchange format: the parameter table is how lavaan communicates with the packages built on top of it (blavaan, semTools, lavaan.mi, and many others read or write parameter tables), which makes the column semantics, in effect, a contract with an entire ecosystem. The concept and the contract are durable; the R representation is an implementation choice.

3.1 Building the parameter table: step 1

The primary method for specifying a model in lavaan is through its model syntax. This syntax is designed to be readable for human users, but for the software it is only a collection of strings, symbols, and numbers. When lavaan receives a model syntax, it first parses it using the lavParseModelString() function. This step ‘flattens’ the model description, creating a list (referred to as flat in the lavaan source code) that can be easily converted into a data.frame. At this stage, the resulting data.frame is an initial, incomplete version of what will eventually become the full parameter table.

As an example, consider the following simple one-factor model:

model <- 'f =~ x1 + start(1.2)*x2 + la3*x3'
flat <- lavParseModelString(model, as_data_frame = TRUE)
flat
  lhs op rhs block label start mod.idx
1   f =~  x1     1                   0
2   f =~  x2     1         1.2       1
3   f =~  x3     1   la3             2

This table contains three rows, corresponding to the three factor loadings. The first three columns (lhs, op, and rhs), together with the block column, uniquely identify each parameter in the model. The op column (short for ‘operator’) defines the type of relationship; in this case, it is consistently =~, indicating that all parameters are factor loadings.

The mod.idx column is nonzero whenever a modifier is present. If so, the modifier’s value is stored in additional columns such as fixed, start, or label. In this example, two modifiers are specified: a starting value (1.2) for the loading of x2, and a label ("la3") for the loading of x3. Note that only modifier columns that are actually used in the model syntax are included in the table; because this example contains no fixed() modifiers, for instance, there is no fixed column.

At this point, the flat table captures exactly the information provided in the model syntax. However, representing the model in a structured table makes it significantly easier for software to process and analyze the specification. From this flat representation, it is already possible to extract key information, such as the names of the observed variables:

lavNames(flat, "ov")
[1] "x1" "x2" "x3"

or the names of the latent variables:

lavNames(flat, "lv")
[1] "f"

The flat table also summarizes any user-specified modifiers, including fixed values, starting values, and labels. It is therefore a complete and organized record of the model, as defined by the user.

3.1.1 Intercepts in the parameter table

As a second example, consider a regression model that includes an intercept:

model2 <- 'y ~ 1 + x1 + x2 + x3'
flat2 <- lavParseModelString(model2, as_data_frame = TRUE)
flat2
  lhs op rhs block mod.idx
1   y ~1         1       0
2   y  ~  x1     1       0
3   y  ~  x2     1       0
4   y  ~  x3     1       0

The key point in this example is how lavaan handles intercepts. In the parsed model syntax, the operator used for the intercept is ~1, and the corresponding rhs field is empty. This design avoids introducing the constant 1 as a variable name in the rhs column, which is reserved exclusively for variable names. Furthermore, using a distinct operator (~1) for intercepts allows lavaan to more easily identify and manage different parameter types internally.

3.1.2 Equality and inequality constraints

When parameters are assigned labels, those labels can be used to define equality or inequality constraints. For example:

model3 <- '
  y ~ 1 + b1*x1 + b2*x2 + b3*x3
  b1 < (b2 + b3)^2
  b2 == exp(b3)
'

The first constraint specifies an inequality, while the second is an equality constraint. Although these constraints are arbitrary and not meaningful in this context, they serve to illustrate how constraints can be specified. When parsing this model syntax, the resulting parameter table appears as follows:

flat3 <- lavParseModelString(model3, as_data_frame = TRUE)
flat3
  lhs op rhs block label mod.idx
1   y ~1         1             0
2   y  ~  x1     1    b1       1
3   y  ~  x2     1    b2       2
4   y  ~  x3     1    b3       3

Note that the constraints themselves are not included directly in the parameter table. Instead, they are stored in the constraints attribute of the flat3 object. This attribute is a list, with each element corresponding to a separate constraint. For example, the first constraint can be accessed as follows:

constraints <- attr(flat3, "constraints")
constraints[[1]]
$op
[1] "<"

$lhs
[1] "b1"

$rhs
[1] "(b2+b3)^2"

$user
[1] 1

Each constraint is represented by three components: an operator (==, <, or >), a left-hand side (lhs), and a right-hand side (rhs). Additionally, the user element is set to 1, indicating that this constraint was explicitly specified by the user. This constraints list can be passed as an argument to the lavParTable() function, which will be examined shortly.

3.1.3 Preparing for step 2

Before lavaan can construct the final parameter table, it first needs to examine the data. Based on the flat table, lavaan determines which observed variables must be extracted from the dataset (or from the sample statistics). If a multiple group analysis is requested, lavaan also needs to establish how many groups are present in the data. Similarly, if the model includes ordered categorical variables as dependent variables, it must determine the number of categories for these categorical variables.

Once this information has been gathered, lavaan is ready to build the complete parameter table. This task is handled by the lavParTable() function, although originally it was called lavaanify(). The original name reflects the central role of the parameter table in lavaan. Both function names can be used interchangeably (in the lavaan sources, lavParTable() is a thin alias for lavaanify()).

3.2 Building the parameter table: step 2

The lavParTable() function represents the final step in constructing the full parameter table. It includes numerous arguments that control which parameters are incorporated and whether they are fixed or freely estimated. Details of these options will be discussed in the sections that follow, but the simplest usage involves supplying only the flat table as input:

model <- 'f =~ x1 + start(1.2)*x2 + la3*x3'
flat <- lavParseModelString(model, as_data_frame = TRUE)
lavParTable(flat)
  id lhs op rhs user block group free ustart exo label plabel
1  1   f =~  x1    1     1     1    1     NA   0         .p1.
2  2   f =~  x2    1     1     1    2    1.2   0         .p2.
3  3   f =~  x3    1     1     1    3     NA   0   la3   .p3.
4  4  x1 ~~  x1    0     1     1    0    0.0   0         .p4.
5  5  x2 ~~  x2    0     1     1    0    0.0   0         .p5.
6  6  x3 ~~  x3    0     1     1    0    0.0   0         .p6.
7  7   f ~~   f    0     1     1    0    0.0   0         .p7.

This call produces a full parameter table for the one-factor model, including all the parameters required for estimation. However, some key aspects, such as setting variances and establishing the latent variable’s metric, are not yet handled and will be discussed shortly.

Alternatively, the flat table step can be skipped by passing the model syntax directly to lavParTable(). Internally, the syntax is first converted into a flat table (via lavParseModelString()) before further processing. As a result, the following call is functionally identical:

lavParTable(model)
  id lhs op rhs user block group free ustart exo label plabel
1  1   f =~  x1    1     1     1    1     NA   0         .p1.
2  2   f =~  x2    1     1     1    2    1.2   0         .p2.
3  3   f =~  x3    1     1     1    3     NA   0   la3   .p3.
4  4  x1 ~~  x1    0     1     1    0    0.0   0         .p4.
5  5  x2 ~~  x2    0     1     1    0    0.0   0         .p5.
6  6  x3 ~~  x3    0     1     1    0    0.0   0         .p6.
7  7   f ~~   f    0     1     1    0    0.0   0         .p7.

3.2.1 The columns of the parameter table

The flat table initially contains only three rows, directly reflecting the input from the model syntax. In contrast, the full parameter table includes seven rows. Four additional parameters, the variances of the observed and latent variables, have been added automatically. The user column indicates their origin: parameters specified in the syntax have user = 1, while those added by lavParTable() have user = 0. A few other codes are in use as well; Section 3.2.2 lists them all.

The first column (id) records the original row number of each parameter in the parameter table. In most cases, this matches the actual row number, so that the column appears redundant. However, when a subset of the full parameter table is created, the row numbers may change, while the id values remain constant. The id is also used to construct internal parameter labels stored in the plabel column, where labels take the form .pXX., with XX replaced by the corresponding id number. This approach ensures that each parameter has a unique label. If the user has specified custom labels in the model syntax (like "la3"), they appear in the label column.

The lhs, op, and rhs columns together define the parameter. The op column (for operator) specifies the type of parameter (for example, a factor loading, a variance, or a regression coefficient), while lhs and rhs indicate which variables are involved. Combined with the block column, these fields uniquely identify a single parameter in the model.

In multiple group analyses, the group column indicates the group number to which each parameter belongs. If there are G groups, they are numbered 1, 2, \ldots, G. For historical reasons, the group column is always included in the parameter table, even when there is only a single group.

The block column specifies the block to which a parameter belongs. In most models, there is only a single block, but multiple group and multilevel models involve multiple blocks. If a multilevel analysis is conducted, an additional level column is included to indicate the level associated with each parameter. The two columns are not treated consistently: the level column is added only when multiple levels exist, whereas the group column is always present, even for a single group. This inconsistency is retained, because several external packages rely on it. A further optional column, lag, appears only when the model syntax uses indexed names for repeated measures (Section 2.8): it holds the difference between the wave numbers of the left- and right-hand side of a parameter (1 for wx2 ~ wx1, 0 for wx2 ~~ wy2, NA for parameters without a common index), or the lag of a lagged variable in a two-level panel model (Section 16.14).

Perhaps the most important column, aside from lhs, op, and rhs, is the free column. Nonzero entries in this column represent free parameters, while zeros represent fixed parameters. Free parameters are numbered sequentially, indicating their position in the parameter vector passed to the optimizer. Normally, each free parameter receives a unique number. However, in models with simple equality constraints (and when ceq_simple = TRUE), duplicate numbers may appear, indicating that the corresponding parameters are constrained to be equal.

If a parameter is fixed, its fixed value is typically stored in the ustart column, short for ‘user-specified starting value’. The second row shows the starting value (1.2) that was explicitly provided in the model syntax. For all other free parameters, the ustart value is NA, the R notation for a missing value. This signals that lavaan will have to provide starting values for these parameters, before the estimation process starts.

Finally, the exo column is relevant only when the model includes exogenous observed variables. In our example, since there are no exogenous variables, all entries in this column are zero. When exogenous variables are present, their treatment depends on the settings of the fixed_x and conditional_x arguments. If either of these options is set to TRUE, the associated parameters are not treated as free; instead, they are considered fixed, and the corresponding entries in the exo column are set to 1. This topic will be revisited in greater detail when the fixed_x and conditional_x arguments are discussed.

3.2.2 The codes in the user column

The user column is an integer code that records where each row of the parameter table came from. The two codes of the example above account for almost all rows in ordinary models, but lavaan uses a few other codes to mark rows that it generated itself for a specific purpose, and that it needs to recognize again later on. Table 3.1 lists the codes that are currently in use.

Table 3.1: The codes used in the user column of the parameter table.
Code Origin of the row
1 specified by the user in the model syntax: model parameters, but also equality and inequality constraints (==, <, >) and defined parameters (:=)
0 added automatically by lavParTable(): residual variances, latent (co)variances, intercepts, thresholds, and the moments of exogenous covariates (the auto_* arguments; see the next sections)
2 equality constraints (==) generated by lavaan rather than written by the user: the constraints implied by duplicated labels and by group_equal (Section 3.2.8; these rows are omitted when ceq_simple = TRUE, see Section 3.2.9), and the constraint and the fixed thresholds added by effect_coding (Section 3.2.7)
3 parameters that were added or set free when a part of the model (a measurement block, or the structural part) is extracted from the full model in a multi-stage analysis, for example intercepts and covariances among exogenous variables that the submodel needs (local SAM, Section 18.3); these tables are built internally and are not normally seen by the user
7 identification restrictions of an exploratory (EFA) block: the echelon zero loadings and the factor covariances fixed to zero before rotation; after rotation these parameters are set free again, so they must stay distinguishable from ordinary fixed parameters (Section 15.2.2)
77 the same EFA restrictions when they are redundant because the loadings are constrained to be equal across groups or blocks; the parameters then stay free (Section 15.9.2)
10 parameters that were added, as free parameters, to a temporarily extended model to compute modification indices or score tests for fixed parameters (Section 10.11, Section 11.4.3); the extended model is internal and the column is dropped from the output

The code 2 is the one most likely to be encountered in practice. For example, requesting equal loadings across two groups adds three generated constraint rows at the bottom of the table:

PT <- lavParTable(model, ngroups = 2, group_equal = "loadings")
PT[PT$user == 2L, c("lhs", "op", "rhs", "user", "free", "block")]
    lhs op   rhs user free block
15 .p1. ==  .p8.    2    0     0
16 .p2. ==  .p9.    2    0     0
17 .p3. == .p10.    2    0     0

Other functions that read a parameter table use these codes to determine how a row is treated. The summary() method, for example, distinguishes the user’s own equality constraints (remove_eq) from the generated ones (remove_system_eq), and hides both by default; the rotation step frees the user = 7 rows again after rotation.

3.2.3 Automatically adding model parameters

Several arguments of the lavParTable() function can add parameters to the model, resulting in additional rows in the parameter table.

For example, setting meanstructure = TRUE adds intercepts (using the ~1 operator) for both observed and latent variables, as shown below:

lavParTable(model, meanstructure = TRUE)
   id lhs op rhs user block group free ustart exo label plabel
1   1   f =~  x1    1     1     1    1     NA   0         .p1.
2   2   f =~  x2    1     1     1    2    1.2   0         .p2.
3   3   f =~  x3    1     1     1    3     NA   0   la3   .p3.
4   4  x1 ~~  x1    0     1     1    0    0.0   0         .p4.
5   5  x2 ~~  x2    0     1     1    0    0.0   0         .p5.
6   6  x3 ~~  x3    0     1     1    0    0.0   0         .p6.
7   7   f ~~   f    0     1     1    0    0.0   0         .p7.
8   8  x1 ~1        0     1     1    0    0.0   0         .p8.
9   9  x2 ~1        0     1     1    0    0.0   0         .p9.
10 10  x3 ~1        0     1     1    0    0.0   0        .p10.
11 11   f ~1        0     1     1    0    0.0   0        .p11.

This adds four new rows to the table, corresponding to intercepts. By default, these intercepts are fixed at zero, but this can be changed by the int_ov_free and int_lv_free arguments, which will be discussed shortly.

Although users can explicitly set meanstructure = TRUE when calling one of the fitting functions, lavaan often enables this option automatically based on the model syntax, the characteristics of the data, or other settings. Typically, lavaan omits the mean structure unless it is required, but it will automatically activate it under the following conditions:

  • The model syntax explicitly specifies at least one intercept.

  • The analysis involves multiple groups, clustering, or a multilevel structure.

  • Some endogenous variables are ordered categorical.

  • The estimator is "PML" (for pairwise maximum likelihood).

  • The missing argument is set to "ml" (alias "fiml"), "ml.x", "two.stage", or "robust.two.stage".

  • The model uses multiple groups, meanstructure = FALSE, but group_equal includes "intercepts" or "means". (If meanstructure = FALSE was requested explicitly, lavaan warns that it is forcing meanstructure = TRUE.)

  • The marker_int_zero option is TRUE.

  • The conditional_x option is TRUE.

In each of these cases, lavaan will automatically include the mean structure, resulting in the addition of intercepts to the parameter table.

The auto_cov_lv_x argument is relevant when the model includes multiple exogenous latent variables. If set to TRUE, it automatically adds and frees parameters for their pairwise covariances.

The auto_cov_y argument adds and frees residual covariance parameters among ‘pure’ endogenous variables, that is, variables that are outcomes but do not serve as predictors for other variables. These covariances are added only among observed variables or among latent variables, not between the two. This argument is typically set to TRUE in multivariate regression models, where it is common to freely estimate all residual covariances among the dependent variables.

The auto_cov_rv argument is only relevant for two-level models with random slopes (the rv() modifier). If set to TRUE, the covariances between each random slope and the other random effects of the between level (the other random slopes, the random intercepts, and the between-level factors) are added and set free; see Section 16.13.2.

The auto_cov_x argument is relevant when the model contains both exogenous latent variables and exogenous observed covariates. By default, lavaan adds covariances among the exogenous latent variables (via auto_cov_lv_x) and, if fixed_x = TRUE, the fixed covariances among the observed covariates, but not the covariances between the two sets. Setting auto_cov_x = TRUE removes this inconsistency: the covariances between the exogenous latent variables and the observed exogenous covariates are then added and freed automatically (this implies auto_cov_lv_x = TRUE), while the observed covariates keep their fixed-exogenous status. As an illustration, consider a model where f is regressed on both an exogenous latent variable g and an observed covariate x1:

model_covx <- 'f =~ y1 + y2 + y3
               g =~ z1 + z2 + z3
               f ~ g + x1'
lavParTable(model_covx, auto = TRUE, model_type = "sem",
            fixed_x = TRUE, auto_cov_x = TRUE)
   id lhs op rhs user block group free ustart exo label plabel
1   1   f =~  y1    1     1     1    0      1   0         .p1.
2   2   f =~  y2    1     1     1    1     NA   0         .p2.
3   3   f =~  y3    1     1     1    2     NA   0         .p3.
4   4   g =~  z1    1     1     1    0      1   0         .p4.
5   5   g =~  z2    1     1     1    3     NA   0         .p5.
6   6   g =~  z3    1     1     1    4     NA   0         .p6.
7   7   f  ~   g    1     1     1    5     NA   0         .p7.
8   8   f  ~  x1    1     1     1    6     NA   0         .p8.
9   9  y1 ~~  y1    0     1     1    7     NA   0         .p9.
10 10  y2 ~~  y2    0     1     1    8     NA   0        .p10.
11 11  y3 ~~  y3    0     1     1    9     NA   0        .p11.
12 12  z1 ~~  z1    0     1     1   10     NA   0        .p12.
13 13  z2 ~~  z2    0     1     1   11     NA   0        .p13.
14 14  z3 ~~  z3    0     1     1   12     NA   0        .p14.
15 15   f ~~   f    0     1     1   13     NA   0        .p15.
16 16   g ~~   g    0     1     1   14     NA   0        .p16.
17 17   g ~~  x1    0     1     1   15     NA   0        .p17.
18 18  x1 ~~  x1    0     1     1    0     NA   1        .p18.

Compared to the default settings, the parameter table contains one extra free parameter: the covariance g ~~ x1. The current default of auto_cov_x is FALSE in all fitting functions (including sem() and cfa()), so this covariance must be requested explicitly (or added manually in the model syntax). Note that auto_cov_x is ignored when conditional_x = TRUE, because these covariances cannot be represented when the model is conditioned on the covariates. If orthogonal_x = TRUE, the added covariances are fixed to zero.

When fitting a model with multiple groups, the ngroups argument must be set to specify the number of groups. This ensures that the parameter table includes a full set of parameters for each group, with the group column indicating the group to which each parameter applies.

3.2.4 Automatically freeing or fixing parameters

In addition to adding parameters, many arguments either set parameters free or fix them to a default value (typically 0 or 1). The following list describes the effect of setting each of these arguments to TRUE:

  • int_ov_free: Frees the intercepts of the observed variables.

  • int_lv_free: Frees the intercepts of the latent variables.

  • marker_int_zero: Fixes the intercepts of the marker indicators to zero and frees the intercepts of the corresponding latent variables.

  • auto_var: Frees the variances of all variables in the model, both observed and latent.

  • auto_fix_first: Fixes the first factor loading of each latent variable to 1. This is typically used to set the scale of latent variables. When this is TRUE, std_lv is automatically set to FALSE.

  • std_lv: Fixes the variances of latent variables to 1, as an alternative method of setting their scale. When this is TRUE, auto_fix_first is automatically set to FALSE.

  • orthogonal: Fixes all covariances among latent variables to zero.

  • orthogonal_y: Fixes covariances among endogenous latent variables to zero.

  • orthogonal_x: Fixes covariances among exogenous latent variables to zero.

  • orthogonal_efa: Fixes covariances among latent variables involved in exploratory factor analysis (EFA) blocks to zero.

  • auto_fix_single: Fixes the residual variance of an observed indicator to zero if it is the sole indicator of a latent variable.

  • auto_th: Frees the thresholds of ordered endogenous observed variables.

  • auto_delta: Frees the response scaling parameters of endogenous observed variables.

  • auto_efa: Adds the constraints needed to identify unrotated EFA blocks: latent variable variances are fixed to 1, covariances are constrained to zero, and loadings follow an echelon (triangular) structure.

  • group_w_free: Frees the group frequencies (in log scale) for every group.

It is important to note that these arguments only affect parameters already present in the parameter table. For instance, if no thresholds are included, setting auto_th = TRUE has no effect. In other words, these arguments never add parameters; they only operate on existing ones.

To generate the parameter table for a one-factor model, a typical call to lavParTable() has the following form:

model <- 'f =~ x1 + x2 + x3'
lavParTable(model, auto_var = TRUE, auto_fix_first = TRUE)
  id lhs op rhs user block group free ustart exo label plabel
1  1   f =~  x1    1     1     1    0      1   0         .p1.
2  2   f =~  x2    1     1     1    1     NA   0         .p2.
3  3   f =~  x3    1     1     1    2     NA   0         .p3.
4  4  x1 ~~  x1    0     1     1    3     NA   0         .p4.
5  5  x2 ~~  x2    0     1     1    4     NA   0         .p5.
6  6  x3 ~~  x3    0     1     1    5     NA   0         .p6.
7  7   f ~~   f    0     1     1    6     NA   0         .p7.

This produces a parameter table that includes all the required parameters and sets the scale of the latent variable using a marker indicator.

3.2.5 lavaan() versus sem(), cfa() and growth()

The lavaan() function is the core function of the lavaan package. It directly manages model specification, parsing, and estimation. However, it requires users to explicitly define several modeling options that are automatically handled by the more user-friendly wrapper functions: sem(), cfa(), and growth().

The key difference between lavaan() and these wrapper functions lies in the default values of several auto_* and int_* arguments, which are passed internally to the lavParTable() function.

The table below summarizes the default values of these arguments across the different fitting functions:

Default values of the auto_* and int_* arguments for the different fitting functions.
argument lavaan sem cfa growth
auto_fix_first FALSE TRUE TRUE TRUE
auto_fix_single FALSE TRUE TRUE TRUE
auto_var FALSE TRUE TRUE TRUE
auto_cov_lv_x FALSE TRUE TRUE TRUE
auto_cov_y FALSE TRUE TRUE TRUE
auto_cov_rv FALSE TRUE TRUE TRUE
auto_th FALSE TRUE TRUE TRUE
auto_delta FALSE TRUE TRUE TRUE
auto_efa FALSE TRUE TRUE TRUE
int_ov_free FALSE TRUE TRUE FALSE
int_lv_free FALSE FALSE FALSE TRUE

The auto argument in the lavParTable() function provides a shortcut for setting default values of all auto_* and int_* arguments, determined by the chosen model_type. The model_type argument can be specified as lavaan, sem (the default), cfa, or growth. With auto = TRUE, the values from the corresponding column of the table above are used: model_type = "sem", "cfa", and "growth" each activate the defaults of the matching fitting function (with "cfa" currently identical to "sem"), while model_type = "lavaan" leaves all auto_* and int_* arguments at their FALSE default. For example:

model <- 'f =~ x1 + x2 + x3'
lavParTable(model, meanstructure = TRUE, auto = TRUE,
            model_type = "lavaan")
   id lhs op rhs user block group free ustart exo label plabel
1   1   f =~  x1    1     1     1    1     NA   0         .p1.
2   2   f =~  x2    1     1     1    2     NA   0         .p2.
3   3   f =~  x3    1     1     1    3     NA   0         .p3.
4   4  x1 ~~  x1    0     1     1    0      0   0         .p4.
5   5  x2 ~~  x2    0     1     1    0      0   0         .p5.
6   6  x3 ~~  x3    0     1     1    0      0   0         .p6.
7   7   f ~~   f    0     1     1    0      0   0         .p7.
8   8  x1 ~1        0     1     1    0      0   0         .p8.
9   9  x2 ~1        0     1     1    0      0   0         .p9.
10 10  x3 ~1        0     1     1    0      0   0        .p10.
11 11   f ~1        0     1     1    0      0   0        .p11.

produces a parameter table in which all auto_* and int_* arguments are set to FALSE. Changing the specification to model_type = "sem" instead results in:

model <- 'f =~ x1 + x2 + x3'
lavParTable(model, meanstructure = TRUE, auto = TRUE,
            model_type = "sem")
   id lhs op rhs user block group free ustart exo label plabel
1   1   f =~  x1    1     1     1    0      1   0         .p1.
2   2   f =~  x2    1     1     1    1     NA   0         .p2.
3   3   f =~  x3    1     1     1    2     NA   0         .p3.
4   4  x1 ~~  x1    0     1     1    3     NA   0         .p4.
5   5  x2 ~~  x2    0     1     1    4     NA   0         .p5.
6   6  x3 ~~  x3    0     1     1    5     NA   0         .p6.
7   7   f ~~   f    0     1     1    6     NA   0         .p7.
8   8  x1 ~1        0     1     1    7     NA   0         .p8.
9   9  x2 ~1        0     1     1    8     NA   0         .p9.
10 10  x3 ~1        0     1     1    9     NA   0        .p10.
11 11   f ~1        0     1     1    0      0   0        .p11.

3.2.6 A closer look at growth(): convenience and its limits

The growth() function requires a longer discussion, because it is the only wrapper whose defaults can produce an incorrect specification without any warning. In the table above, growth() differs from sem() in exactly two defaults: int_ov_free = FALSE (the intercepts of the observed variables are fixed to zero, rather than freed) and int_lv_free = TRUE (the means of the latent variables are freed, rather than fixed to zero). These are the only differences. A latent growth curve model has no separate measurement intercepts: the repeated measures load on an intercept factor and a slope factor with fixed loadings, so the level of each occasion must be carried by the means of the growth factors. The two changed defaults achieve precisely that.

It follows that growth() does nothing that cannot be specified explicitly with lavaan(). The following two fits are identical:

model_growth <- '
  i =~ 1*t1 + 1*t2 + 1*t3 + 1*t4
  s =~ 0*t1 + 1*t2 + 2*t3 + 3*t4
'
fit_growth <- growth(model_growth, data = Demo.growth)

model_lavaan <- '
  i =~ 1*t1 + 1*t2 + 1*t3 + 1*t4
  s =~ 0*t1 + 1*t2 + 2*t3 + 3*t4
  # what growth() adds internally:
  i ~ 1          # free the growth-factor means
  s ~ 1
  i ~~ s         # and their covariance
'
fit_lavaan <- lavaan(model_lavaan, data = Demo.growth, auto_var = TRUE)

c(growth = fitMeasures(fit_growth, "logl"),
  lavaan = fitMeasures(fit_lavaan, "logl"))
growth.logl lavaan.logl 
  -2755.052   -2755.052 

Both return the same log-likelihood, the same degrees of freedom, and the same estimates. Here auto_var = TRUE supplies the residual variances of t1–t4 and the variances of i and s. Everything else (the fixed loadings, the freed factor means, their covariance) is written out in the syntax. The observed intercepts need no mention, because lavaan() fixes them to zero by default.

The reason to prefer the explicit form is that growth()’s two changed defaults are applied to every latent variable in the model, and this is only appropriate when every latent variable is a growth factor. As soon as the model also contains an ordinary measured latent variable, that is, a construct with its own multi-indicator measurement model, these defaults produce the wrong settings for that variable. Consider adding a latent covariate f, measured by y1, y2, y3, that predicts the growth factors:

model_mixed <- '
  i =~ 1*t1 + 1*t2 + 1*t3 + 1*t4
  s =~ 0*t1 + 1*t2 + 2*t3 + 3*t4
  f =~ y1 + y2 + y3
  i ~ f
  s ~ f
'
pt <- lavParTable(model_mixed, model_type = "growth",
                  auto = TRUE, meanstructure = TRUE)
pt[pt$op == "~1", c("lhs", "op", "free", "ustart")]
   lhs op free ustart
25  t1 ~1    0      0
26  t2 ~1    0      0
27  t3 ~1    0      0
28  t4 ~1    0      0
29  y1 ~1    0      0
30  y2 ~1    0      0
31  y3 ~1    0      0
32   i ~1   16     NA
33   s ~1   17     NA
34   f ~1   18     NA

Consider the mean-structure rows. The growth defaults have fixed the intercepts of y1, y2, y3 to zero and freed the mean of f, which is the growth-factor parameterization. But f is a measured construct, not a random effect: the standard measurement-model convention is the opposite one, with the indicator intercepts free and the latent mean fixed to zero (or identified by a marker intercept). Fixing all three y intercepts to zero imposes a genuine, and almost always unwanted, restriction: it forces the observed means of y1, y2, y3 to be exactly proportional to their loadings on f. In a model where that constraint does not hold, the results are incorrect. In one simulated example, the growth() specification yields a chi-square of about 74 on 17 degrees of freedom, whereas the correct handling (f’s mean fixed to zero and its indicator intercepts freed) gives about 19 on 16. The additional degree of freedom corresponds to the restriction that growth() should not have imposed on the measurement block.

The practical recommendation is therefore to reserve growth() for models in which all latent variables are growth factors, and to build any model that mixes growth factors with measured constructs using lavaan() with auto_var = TRUE, specifying the mean structure by hand. The additional lines are few, and they make the intent explicit and inspectable in the parameter table: which latent variables are random effects carrying an occasion-specific level, and which are ordinary measured constructs.

3.2.7 Automatically adding equality constraints: effect_coding

In addition to arguments that add or modify parameters, lavParTable() also provides arguments that automatically add equality constraints to the parameter table.

The effect_coding argument enables an alternative identification method for latent variable scales based on effect coding. When set to TRUE, it imposes constraints such that the sum of the factor loadings for each latent variable equals the number of non-fixed loadings, and the sum of the intercepts of the observed indicators equals zero. This approach sets the metric of the latent variable without fixing a single factor loading (as with the marker-variable approach) or the latent variance (as with std_lv = TRUE). Effect coding is particularly useful when researchers prefer a more balanced identification method that treats all indicators symmetrically.

The effect_coding argument can also be set to "loadings" or "intercepts", to constrain only the loadings or only the intercepts. The value TRUE is equivalent to c("loadings", "intercepts").

For example, in a simple one-factor model without a mean structure, the parameter table produced by:

lavParTable(model, effect_coding = TRUE)
  id  lhs op         rhs user block group free ustart exo label plabel
1  1    f =~          x1    1     1     1    1     NA   0         .p1.
2  2    f =~          x2    1     1     1    2     NA   0         .p2.
3  3    f =~          x3    1     1     1    3     NA   0         .p3.
4  4   x1 ~~          x1    0     1     1    0      0   0         .p4.
5  5   x2 ~~          x2    0     1     1    0      0   0         .p5.
6  6   x3 ~~          x3    0     1     1    0      0   0         .p6.
7  7    f ~~           f    0     1     1    0      0   0         .p7.
8  8 .p1. == 3-.p2.-.p3.    2     0     0    0     NA   0             

will include an equality constraint at the bottom. This constraint, shown using the == operator, involves automatically generated parameter labels (from the plabel column). Since there is no mean structure, the constraint applies only to the factor loadings, ensuring their sum equals the total number of loadings (here, three). This is mathematically equivalent to stating that the first loading equals three minus the sum of the other two loadings, and this is the version that is used in the table.

3.2.8 Automatically adding equality constraints: group_equal

In multiple-group analyses, it is common to impose equality constraints across groups, for example to test whether certain parameters (like factor loadings or intercepts) are equal across groups. The lavParTable() function supports this through the group_equal argument. This argument accepts a character vector indicating which types of parameters should be constrained to be equal across groups. The possible values are:

  • “loadings”: Constrain factor loadings to be equal.

  • “composite.weights”: Constrain the weights of composites (chapter 4) to be equal.

  • “intercepts”: Constrain intercepts or means of observed variables to be equal.

  • “thresholds”: Constrain the thresholds of ordered observed variables (chapter 14) to be equal.

  • “residuals”: Constrain residual variances of observed variables to be equal.

  • “residual.covariances”: Constrain residual covariances of observed variables to be equal.

  • “lv.variances”: Constrain latent variable variances to be equal.

  • “lv.covariances”: Constrain latent variable covariances to be equal.

  • “means”: Constrain latent intercepts or means to be equal.

  • “regressions”: Constrain regression coefficients to be equal.

In addition, the shortcut group_equal = "all" expands to the complete set of values above, constraining all free parameters to be equal across groups. If the user explicitly requested meanstructure = FALSE, the model contains no mean-structure parameters, and "intercepts" and "means" are left out of this expansion.

For example, to automatically constrain the factor loadings to be equal across groups, the following call can be used:

model <- 'f =~ x1 + x2 + x3'
lavParTable(model, ngroups = 2, group_equal = "loadings", ceq_simple = FALSE)
   id  lhs op   rhs user block group free ustart exo label plabel
1   1    f =~    x1    1     1     1    1     NA   0  .p1.   .p1.
2   2    f =~    x2    1     1     1    2     NA   0  .p2.   .p2.
3   3    f =~    x3    1     1     1    3     NA   0  .p3.   .p3.
4   4   x1 ~~    x1    0     1     1    0      0   0         .p4.
5   5   x2 ~~    x2    0     1     1    0      0   0         .p5.
6   6   x3 ~~    x3    0     1     1    0      0   0         .p6.
7   7    f ~~     f    0     1     1    0      0   0         .p7.
8   8    f =~    x1    1     2     2    4     NA   0  .p1.   .p8.
9   9    f =~    x2    1     2     2    5     NA   0  .p2.   .p9.
10 10    f =~    x3    1     2     2    6     NA   0  .p3.  .p10.
11 11   x1 ~~    x1    0     2     2    0      0   0        .p11.
12 12   x2 ~~    x2    0     2     2    0      0   0        .p12.
13 13   x3 ~~    x3    0     2     2    0      0   0        .p13.
14 14    f ~~     f    0     2     2    0      0   0        .p14.
15 15 .p1. ==  .p8.    2     0     0    0     NA   0             
16 16 .p2. ==  .p9.    2     0     0    0     NA   0             
17 17 .p3. == .p10.    2     0     0    0     NA   0             

The meaning of ceq_simple = FALSE will be clarified shortly. The effect of specifying group_equal = "loadings" can be seen in the label column, where lavaan assigns identical labels (.p1., .p2., and .p3.) to the factor loadings in both groups. This signals to lavaan that these parameters must be constrained to be equal, following the principle that identical labels imply identical values. Because ceq_simple = FALSE, the parameter table then contains three explicit equality constraints, shown in the final three rows.

The group_partial argument specifies parameters that should be excluded from the equality constraints imposed by group_equal. This makes it possible to test for partial invariance by relaxing equality constraints on selected parameters. For instance, to allow the second factor loading (for x2) to vary across groups, the following call can be used:

lavParTable(model, ngroups = 2, group_equal = "loadings", ceq_simple = FALSE,
            group_partial = c("f=~x2"))
   id  lhs op   rhs user block group free ustart exo label plabel
1   1    f =~    x1    1     1     1    1     NA   0  .p1.   .p1.
2   2    f =~    x2    1     1     1    2     NA   0         .p2.
3   3    f =~    x3    1     1     1    3     NA   0  .p3.   .p3.
4   4   x1 ~~    x1    0     1     1    0      0   0         .p4.
5   5   x2 ~~    x2    0     1     1    0      0   0         .p5.
6   6   x3 ~~    x3    0     1     1    0      0   0         .p6.
7   7    f ~~     f    0     1     1    0      0   0         .p7.
8   8    f =~    x1    1     2     2    4     NA   0  .p1.   .p8.
9   9    f =~    x2    1     2     2    5     NA   0         .p9.
10 10    f =~    x3    1     2     2    6     NA   0  .p3.  .p10.
11 11   x1 ~~    x1    0     2     2    0      0   0        .p11.
12 12   x2 ~~    x2    0     2     2    0      0   0        .p12.
13 13   x3 ~~    x3    0     2     2    0      0   0        .p13.
14 14    f ~~     f    0     2     2    0      0   0        .p14.
15 15 .p1. ==  .p8.    2     0     0    0     NA   0             
16 16 .p3. == .p10.    2     0     0    0     NA   0             

Parameter names are constructed by concatenating the entries from the lhs, op, and rhs columns, without spaces. The function lav_pt_labels() can be used to generate these names from a parameter table (prior to the addition of equality constraints):

lav_pt_labels(lavParTable(model, ngroups = 2), type = "free")
[1] "f=~x1"    "f=~x2"    "f=~x3"    "f=~x1.g2" "f=~x2.g2" "f=~x3.g2"

The same parameter names are used in the output of coef().

3.2.9 Simple equality constraints: the ceq_simple argument

Constraints defined through the group_equal argument are treated as simple constraints. A simple constraint takes the form a == b, where both a and b are model parameters.

Such constraints can be introduced in two ways: either explicitly, by adding extra rows with the == operator to the parameter table, or implicitly, by assigning identical values in the free column for the parameters that must be constrained. The implicit method is triggered when ceq_simple = TRUE and is generally more efficient, particularly in models with a large number of constraints (e.g., hundreds).

When ceq_simple = FALSE (as in the earlier example with group_equal = "loadings"), the integers in the free column remain unique, and the equality constraints appear as extra rows at the end of the parameter table, marked with the operator ==. In contrast, setting ceq_simple = TRUE yields:

lavParTable(model, ngroups = 2, group_equal = c("loadings"),
            ceq_simple = TRUE)
   id lhs op rhs user block group free ustart exo label plabel
1   1   f =~  x1    1     1     1    1     NA   0  .p1.   .p1.
2   2   f =~  x2    1     1     1    2     NA   0  .p2.   .p2.
3   3   f =~  x3    1     1     1    3     NA   0  .p3.   .p3.
4   4  x1 ~~  x1    0     1     1    0      0   0         .p4.
5   5  x2 ~~  x2    0     1     1    0      0   0         .p5.
6   6  x3 ~~  x3    0     1     1    0      0   0         .p6.
7   7   f ~~   f    0     1     1    0      0   0         .p7.
8   8   f =~  x1    1     2     2    1     NA   0  .p1.   .p8.
9   9   f =~  x2    1     2     2    2     NA   0  .p2.   .p9.
10 10   f =~  x3    1     2     2    3     NA   0  .p3.  .p10.
11 11  x1 ~~  x1    0     2     2    0      0   0        .p11.
12 12  x2 ~~  x2    0     2     2    0      0   0        .p12.
13 13  x3 ~~  x3    0     2     2    0      0   0        .p13.
14 14   f ~~   f    0     2     2    0      0   0        .p14.

Here, the three factor loadings share the same identifier in the free column. Equality across groups is thus enforced implicitly, without adding constraint rows. For the optimizer, these parameters are treated as one, and their estimates apply simultaneously to both groups.

3.2.10 Adding user-specified constraints

When constraints are included in the model syntax, they are stored as a constraints attribute in the resulting flat table. This attribute is automatically passed to the lavParTable() function, which appends the corresponding constraints to the bottom of the parameter table. For example, consider the earlier case where two constraints were embedded directly within the model syntax:

model3 <- '
  y ~ 1 + b1*x1 + b2*x2 + b3*x3 
  b1 < (b2 + b3)^2
  b2 == exp(b3)
'
lavParTable(model3)
   id lhs op       rhs user block group free ustart exo label plabel
1   1   y ~1              1     1     1    1     NA   0         .p1.
2   2   y  ~        x1    1     1     1    2     NA   0    b1   .p2.
3   3   y  ~        x2    1     1     1    3     NA   0    b2   .p3.
4   4   y  ~        x3    1     1     1    4     NA   0    b3   .p4.
5   5   y ~~         y    0     1     1    0      0   0         .p5.
6   6  x1 ~~        x1    0     1     1    0      0   0         .p6.
7   7  x1 ~~        x2    0     1     1    5     NA   0         .p7.
8   8  x1 ~~        x3    0     1     1    6     NA   0         .p8.
9   9  x2 ~~        x2    0     1     1    0      0   0         .p9.
10 10  x2 ~~        x3    0     1     1    7     NA   0        .p10.
11 11  x3 ~~        x3    0     1     1    0      0   0        .p11.
12 12  x1 ~1              0     1     1    0      0   0        .p12.
13 13  x2 ~1              0     1     1    0      0   0        .p13.
14 14  x3 ~1              0     1     1    0      0   0        .p14.
15 15  b1  < (b2+b3)^2    1     0     0    0     NA   0             
16 16  b2 ==   exp(b3)    1     0     0    0     NA   0             

An alternative approach is to supply the constraints separately using the constraints argument. This argument accepts a string of model syntax that contains only constraint expressions using relational operators (==, <, or >). For example, the same model and constraints can be specified like this:

model3b <- '
  y ~ 1 + b1*x1 + b2*x2 + b3*x3 
'
constraints <- '
  b1 < (b2 + b3)^2
  b2 == exp(b3)
'
lavParTable(model3b, constraints = constraints)
   id lhs op       rhs user block group free ustart exo label plabel
1   1   y ~1              1     1     1    1     NA   0         .p1.
2   2   y  ~        x1    1     1     1    2     NA   0    b1   .p2.
3   3   y  ~        x2    1     1     1    3     NA   0    b2   .p3.
4   4   y  ~        x3    1     1     1    4     NA   0    b3   .p4.
5   5   y ~~         y    0     1     1    0      0   0         .p5.
6   6  x1 ~~        x1    0     1     1    0      0   0         .p6.
7   7  x1 ~~        x2    0     1     1    5     NA   0         .p7.
8   8  x1 ~~        x3    0     1     1    6     NA   0         .p8.
9   9  x2 ~~        x2    0     1     1    0      0   0         .p9.
10 10  x2 ~~        x3    0     1     1    7     NA   0        .p10.
11 11  x3 ~~        x3    0     1     1    0      0   0        .p11.
12 12  x1 ~1              0     1     1    0      0   0        .p12.
13 13  x2 ~1              0     1     1    0      0   0        .p13.
14 14  x3 ~1              0     1     1    0      0   0        .p14.
15 15  b1  < (b2+b3)^2    1     0     0    0     NA   0             
16 16  b2 ==   exp(b3)    1     0     0    0     NA   0             

In both cases, the user-defined constraints are incorporated into the final parameter table and treated as an integral part of the model specification.

3.2.11 Correlation structures

If a correlation structure is to be fitted instead of a covariance structure, the correlation argument should be set to TRUE. For continuous data, this means that the residual variances of the observed variables are no longer free parameters. To ensure that the model-implied variances of the observed variables equal 1 (as required for a correlation matrix), lavaan provides two approaches: if parameterization = "Delta" (the default), the residual variances are adjusted accordingly during estimation; if parameterization = "Theta", the residual variances are fixed to 1, and scaling parameters (using the ~*~ operator) are fixed to values that enforce unit variances.

To illustrate the resulting parameter table, consider this example:

model <- 'f =~ x1 + x2 + x3' 
lavParTable(model, auto_var = TRUE, auto_fix_first = TRUE, correlation = TRUE)
   id lhs  op rhs user block group free ustart exo label plabel
1   1   f  =~  x1    1     1     1    0      1   0         .p1.
2   2   f  =~  x2    1     1     1    1     NA   0         .p2.
3   3   f  =~  x3    1     1     1    2     NA   0         .p3.
4   4  x1  ~~  x1    0     1     1    0      1   0         .p4.
5   5  x2  ~~  x2    0     1     1    0      1   0         .p5.
6   6  x3  ~~  x3    0     1     1    0      1   0         .p6.
7   7   f  ~~   f    0     1     1    3     NA   0         .p7.
8   8  x1 ~*~  x1    0     1     1    0      1   0         .p8.
9   9  x2 ~*~  x2    0     1     1    0      1   0         .p9.
10 10  x3 ~*~  x3    0     1     1    0      1   0        .p10.

Note that in the resulting parameter table, the residual variances are fixed values. In addition, the table includes scaling parameters (represented using the ~*~ operator), which are also fixed. However, during model estimation, either the residual variances or the scaling parameters will be adjusted (depending on the chosen parameterization) to ensure that the model-implied variances of the observed variables are exactly one, as required by the correlation structure. When the model is actually fitted, the default ML estimator handles the unit-variance requirement differently again: it frees the ~*~ scaling rows and estimates them alongside the other parameters (the Delta-augmentation of Section 12.5), so in the fitted object these rows show up as estimated scaling parameters rather than fixed values.

A residual variance written in the model syntax for one of the standardized variables (x1 ~~ v1*x1, say) would make the model unidentified: the total variance is already fixed to one, and the residual variance is derived from that constraint. lavaan therefore warns that such rows are ignored and forces them to be nonfree, as it does for ordered variables under the Delta parameterization. A label attached to the row is kept, so that it can still be used in := definitions and in constraints.

The correlation argument may also be a character vector of observed variable names. In that case, only the listed variables are standardized to unit variance, while all remaining observed variables keep their original metric, giving a partial correlation structure. For example:

lavParTable(model, auto_var = TRUE, auto_fix_first = TRUE,
            correlation = c("x1", "x2"))
  id lhs  op rhs user block group free ustart exo label plabel
1  1   f  =~  x1    1     1     1    0      1   0         .p1.
2  2   f  =~  x2    1     1     1    1     NA   0         .p2.
3  3   f  =~  x3    1     1     1    2     NA   0         .p3.
4  4  x1  ~~  x1    0     1     1    0      1   0         .p4.
5  5  x2  ~~  x2    0     1     1    0      1   0         .p5.
6  6  x3  ~~  x3    0     1     1    3     NA   0         .p6.
7  7   f  ~~   f    0     1     1    4     NA   0         .p7.
8  8  x1 ~*~  x1    0     1     1    0      1   0         .p8.
9  9  x2 ~*~  x2    0     1     1    0      1   0         .p9.

Here, only x1 and x2 receive fixed residual variances and scaling parameters (~*~ rows), while the residual variance of x3 remains a free parameter. (Related to this, if the model contains observed product terms such as x1:y1 and correlation = TRUE, the product terms are automatically excluded from the correlation set, because the product of two standardized variables does not have unit variance.)

This section only covers the specification side of correlation structures. Standardizing also changes the sampling variability of the statistics being fitted (sample correlations do not vary like sample covariances), and the standard errors must be adjusted accordingly; Section 5.6.5 gives the derivation, and Section 12.5 discusses estimation, the available estimators, and why supplying a correlation matrix to a covariance-structure analysis gives wrong standard errors.

3.2.12 Endogenous ordered categorical variables

When a model contains endogenous ordered categorical variables, the lavParTable() function must be informed which observed variables are numeric and which are ordered. This is usually accomplished through the varTable argument, which takes a variable table: a summary object that provides metadata for each variable, such as type (numeric or ordered), descriptive statistics, and, for ordered variables, the number of response levels. (Details can be found in the documentation for the varTable() function.) Using this information, lavParTable() determines how many threshold parameters are required for each ordered variable.

An alternative approach is to specify the number of thresholds directly with the nthresholds argument. If all ordered variables share the same number of levels, a single integer can be supplied. If the numbers differ across variables, a named vector can be provided, indicating the number of thresholds for each ordered variable. For example:

model <- 'f =~ x1 + x2 + x3'
nth <- c(2, 2, 1)
names(nth) <- c("x1", "x2", "x3")
lavParTable(model, auto_var = TRUE, auto_fix_first = TRUE, 
            nthresholds = nth)
   id lhs  op rhs user block group free ustart exo label plabel
1   1   f  =~  x1    1     1     1    0      1   0         .p1.
2   2   f  =~  x2    1     1     1    1     NA   0         .p2.
3   3   f  =~  x3    1     1     1    2     NA   0         .p3.
4   4  x1   |  t1    0     1     1    0     NA   0         .p4.
5   5  x1   |  t2    0     1     1    0     NA   0         .p5.
6   6  x2   |  t1    0     1     1    0     NA   0         .p6.
7   7  x2   |  t2    0     1     1    0     NA   0         .p7.
8   8  x3   |  t1    0     1     1    0     NA   0         .p8.
9   9  x1  ~~  x1    0     1     1    0      1   0         .p9.
10 10  x2  ~~  x2    0     1     1    0      1   0        .p10.
11 11  x3  ~~  x3    0     1     1    0      1   0        .p11.
12 12   f  ~~   f    0     1     1    3     NA   0        .p12.
13 13  x1 ~*~  x1    0     1     1    0      1   0        .p13.
14 14  x2 ~*~  x2    0     1     1    0      1   0        .p14.
15 15  x3 ~*~  x3    0     1     1    0      1   0        .p15.

In this case, x1 and x2 are treated as ordered variables with three levels each (requiring two thresholds), while x3 is binary and thus requires one threshold. Scaling parameters are also included for each ordered variable, allowing the model to support both parameterization = "Delta" (the default) and parameterization = "Theta".

Including the threshold parameters is not sufficient, however: they must also be set free. This can be achieved by setting auto_th = TRUE.

In multi-group models using parameterization = "Delta", it is possible to automatically free the response scaling parameters in all groups except the first by setting auto_delta = TRUE. This is typically used when threshold parameters are constrained to be equal across groups.

3.2.13 Exogenous observed variables: fixed_x and conditional_x

When a model includes exogenous observed covariates (often referred to as x-variables), two important arguments, fixed_x and conditional_x, determine how these covariates are treated in the parameter table and, by extension, in model estimation.

If fixed_x = TRUE (the default), the observed exogenous variables are treated as fixed or non-random. This means their sample statistics (means, variances, and covariances) are not modeled explicitly but are treated as known constants. As a result, parameters related to the means, variances and covariances of these variables will be flagged as fixed in the parameter table, and the ustart column should contain their sample statistics. In addition, the corresponding values in the exo column are set to 1.

If fixed_x = FALSE, the exogenous covariates are treated as random variables. In this case, parameters related to the means, variances and covariances of these variables will be set free. These variables are then treated in the same way as the other (non-exogenous) observed variables of the model.

If conditional_x = TRUE, the model is interpreted as conditional on the x-variables. In this setup, the x-variables are not part of the modeled variance–covariance structure at all. No parameters are added for their means or (co)variances, regardless of whether fixed_x is TRUE or FALSE. This option is often used in models that specify regression-like relationships where the predictors (the x-variables) are not considered part of the structural system. If the model contains ordered categorical variables, conditional_x = TRUE is the default.

As an example, consider a model where a latent variable f is regressed on an observed covariate x1, using the option fixed_x = TRUE:

model <- 'f =~ y1 + y2 + y3
          f ~ x1'
lavParTable(model, auto_var = TRUE, auto_fix_first = TRUE,
            meanstructure = TRUE, int_ov_free = TRUE,
            fixed_x = TRUE, conditional_x = FALSE)
   id lhs op rhs user block group free ustart exo label plabel
1   1   f =~  y1    1     1     1    0      1   0         .p1.
2   2   f =~  y2    1     1     1    1     NA   0         .p2.
3   3   f =~  y3    1     1     1    2     NA   0         .p3.
4   4   f  ~  x1    1     1     1    3     NA   0         .p4.
5   5  y1 ~~  y1    0     1     1    4     NA   0         .p5.
6   6  y2 ~~  y2    0     1     1    5     NA   0         .p6.
7   7  y3 ~~  y3    0     1     1    6     NA   0         .p7.
8   8   f ~~   f    0     1     1    7     NA   0         .p8.
9   9  x1 ~~  x1    0     1     1    0     NA   1         .p9.
10 10  y1 ~1        0     1     1    8     NA   0        .p10.
11 11  y2 ~1        0     1     1    9     NA   0        .p11.
12 12  y3 ~1        0     1     1   10     NA   0        .p12.
13 13  x1 ~1        0     1     1    0     NA   1        .p13.
14 14   f ~1        0     1     1    0      0   0        .p14.

In the resulting parameter table, the mean (x1 ~ 1) and variance (x1 ~~ x1) of x1 are fixed, and the exo column marks x1 as a fixed exogenous variable. Since no actual data were supplied, the ustart values for these parameters remain NA, but in practice, they would be replaced by the sample statistics for x1.

Now consider the same model, but this time using conditional_x = TRUE:

lavParTable(model, auto_var = TRUE, auto_fix_first = TRUE,
            meanstructure = TRUE, int_ov_free = TRUE,
            fixed_x = TRUE, conditional_x = TRUE)
   id lhs op rhs user block group free ustart exo label plabel
1   1   f =~  y1    1     1     1    0      1   0         .p1.
2   2   f =~  y2    1     1     1    1     NA   0         .p2.
3   3   f =~  y3    1     1     1    2     NA   0         .p3.
4   4   f  ~  x1    1     1     1    3     NA   1         .p4.
5   5  y1 ~~  y1    0     1     1    4     NA   0         .p5.
6   6  y2 ~~  y2    0     1     1    5     NA   0         .p6.
7   7  y3 ~~  y3    0     1     1    6     NA   0         .p7.
8   8   f ~~   f    0     1     1    7     NA   0         .p8.
9   9  x1 ~~  x1    0     1     1    0     NA   1         .p9.
10 10  y1 ~1        0     1     1    8     NA   0        .p10.
11 11  y2 ~1        0     1     1    9     NA   0        .p11.
12 12  y3 ~1        0     1     1   10     NA   0        .p12.
13 13  x1 ~1        0     1     1    0     NA   1        .p13.
14 14   f ~1        0     1     1    0      0   0        .p14.

This version produces a parameter table nearly identical to the previous one, with one key difference: the exo column for the regression term (f ~ x1) is now set to 1, indicating that a conditional model is being used. This distinction indicates that the model matrices must be constructed for a conditional analysis. The matrix representation of the conditional approach is described in Section 4.7 (in particular Section 4.7.3), and its consequences for the sample statistics in Section 5.6.4. For models with ordered categorical variables, where conditional_x = TRUE is the default, see Section 14.4.

3.2.14 The columns of the parameter table after fitting the model

When a model is fitted to data, lavaan estimates all free parameters specified in the model. Before estimation can begin, however, every free parameter with a missing value (NA) in the ustart column must first be assigned a starting value. Unless the user has provided custom values, this typically requires initialization of all free parameters. Once starting values are in place, lavaan proceeds to estimate the free parameters by identifying values that are “optimal” according to a chosen fitting criterion. In most cases, this involves an iterative optimization procedure, although non-iterative methods are also available. By default, lavaan computes standard errors for the free parameters after estimation. The starting values, parameter estimates, and standard errors are stored as additional columns in the parameter table.

To illustrate this process, consider fitting a simple one-factor model with the sem() function and then retrieving the updated parameter table using parameterTable() (or its shortcut alias parTable()):

model <- 'f =~ x1 + x2 + x3'
fit <- sem(model, data = HolzingerSwineford1939)
parTable(fit)
  id lhs op rhs user block group free ustart exo label plabel start   est    se
1  1   f =~  x1    1     1     1    0      1   0         .p1. 1.000 1.000 0.000
2  2   f =~  x2    1     1     1    1     NA   0         .p2. 0.778 0.778 0.141
3  3   f =~  x3    1     1     1    2     NA   0         .p3. 1.107 1.107 0.214
4  4  x1 ~~  x1    0     1     1    3     NA   0         .p4. 0.679 0.835 0.118
5  5  x2 ~~  x2    0     1     1    4     NA   0         .p5. 0.691 1.065 0.105
6  6  x3 ~~  x3    0     1     1    5     NA   0         .p6. 0.637 0.633 0.129
7  7   f ~~   f    0     1     1    6     NA   0         .p7. 0.050 0.524 0.130

The first columns, up to and including plabel, remain unchanged, preserving the original layout of the parameter table. What is new are three appended columns. The start column lists the starting values, computed automatically by lavaan unless the parameter was fixed or a user-specified starting value was provided. The est column contains the final point estimates: free parameters are replaced by their estimated values, while fixed parameters retain their fixed numbers. The se column reports the standard errors for the free parameters; for fixed parameters, this value is always zero, reflecting the fact that fixed quantities do not vary even under repeated sampling. This expanded table structure integrates starting values, estimates, and standard errors into a single framework, making results straightforward to inspect, report, and analyze.

Because the parameter table provides a complete model specification, it can be used as input to lavaan’s fitting functions (sem() or lavaan()) in place of the usual model syntax. As an illustration, consider fitting a one-factor model, extracting the parameter table, removing the start, est, and se columns, and then refitting the model using this table directly:

fit1 <- sem(model, data = HolzingerSwineford1939)
PT <- parTable(fit1)
# remove the start/est/se columns
PT$start <- PT$est <- PT$se <- NULL
fit2 <- sem(PT, data = HolzingerSwineford1939)

The resulting objects fit1 and fit2 will be identical, demonstrating that the parameter table itself fully defines the model.

3.3 Extracting information from a parameter table

Internally, lavaan represents the parameter table as a list, but the parameterTable() function (and its alias parTable()) returns it as a standard R data.frame. This makes it straightforward to explore and manipulate the table using familiar base R tools.

Consider the following example, where a three-factor confirmatory factor analysis (CFA) model is fitted to the Holzinger & Swineford dataset:

HS_model <- '
  visual  =~ x1 + x2 + x3
  textual =~ x4 + x5 + x6
  speed   =~ x7 + x8 + x9 
'
fit <- sem(HS_model, data = HolzingerSwineford1939)
PT <- parameterTable(fit)

With the parameter table stored in PT, R functions can be used to isolate specific information. For example, the factor loadings of the visual factor can be inspected by filtering the table as follows:

subset(PT, subset = (op == "=~" & lhs == "visual"),
           select = c("lhs", "op", "rhs", "est"))
     lhs op rhs   est
1 visual =~  x1 1.000
2 visual =~  x2 0.554
3 visual =~  x3 0.729

This produces a filtered view of the table, including only rows corresponding to factor loadings (op == "=~") with visual on the left-hand side, and restricting the output to the lhs, op, rhs, and est columns. Such filtered views are especially useful in larger models, where it is helpful to focus on selected parts of the parameter table.

As another illustration, the names of the latent variables can be extracted. Since rows with op == "=~" correspond to factor loadings, the lhs entries in these rows give the latent variable names. Deduplicating them yields the full set of latent variables:

lv_idx <- which(PT$op == "=~")    # indices of factor loadings
lv_names_all <- PT$lhs[lv_idx]    # all latent variable names
lv_names <- unique(lv_names_all)  # unique latent variable names
lv_names
[1] "visual"  "textual" "speed"  

This results in the list of latent variables defined in the model. The same logic can be extended to obtain observed variable names or other categories of parameters.

Because such tasks are frequent, lavaan provides a helper function, lavNames(), which streamlines the process of extracting variable names.1 The use of lavNames() will be discussed next.

3.3.1 The lavNames() function

The lavNames() function is a convenient utility in lavaan for extracting variable names from a fitted model object or a parameter table. The function is especially helpful for retrieving specific types of variables used in a model (e.g., latent variables, observed exogenous variables, observed indicators of latent variables, etc.), without manually filtering the parameter table.

To illustrate the functionality of the lavNames() function, consider a multiple-group CFA model fitted to the Holzinger & Swineford dataset. In this example, each group is specified to include a different set of latent variables, making the demonstration more informative:

HS_model <- '
  group: 1
    visual  =~ x1 + x2 + x3 
    textual =~ x4 + x5 + x6
  group: 2
    visual  =~ x1 + x2 + x3
    speed   =~ x7 + x8 + x9 
'
fit <- sem(HS_model, data = HolzingerSwineford1939, group = "school")
PT <- parameterTable(fit)

The lavNames() function accepts either a fitted lavaan model (fit) or the corresponding parameter table (PT) as input:

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

By default, it returns the observed variable names used across all groups. To extract names for a specific group, the group argument can be specified:

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

If variable names from multiple groups are required (for example, groups 1 and 2), a vector of group indices can be provided:

lavNames(fit, group = c(1,2))
[[1]]
[1] "x1" "x2" "x3" "x4" "x5" "x6"

[[2]]
[1] "x1" "x2" "x3" "x7" "x8" "x9"

In a multilevel model, the level argument can be used instead of group to retrieve names at a particular level. More generally, in models with multiple blocks (arising from multiple groups, multiple levels, or both), the block argument allows direct access to variables in a specific block:

lavNames(fit, block = 2)
[1] "x1" "x2" "x3" "x7" "x8" "x9"

In short, lavNames() offers a flexible way to extract observed variable names across groups, levels, or blocks, depending on the structure of the model.

Many other variable types can be extracted. The type argument can be used to choose a specific type of variables. For example, the argument type = "lv" extracts the latent variable names:

lavNames(fit, type = "lv")
[1] "visual"  "textual" "speed"  

The table below provides an overview of the available variable types, along with a brief description of each.

Overview of the variable types that can be requested using the lavNames() function
type description
ov All observed variables
ov.x Observed variables included in eqs.x, but not in ov.ind or ov.y
ov.nox Observed variables not included in ov.x
ov.model Modeled observed variables (same as ov if conditional_x, ov.nox otherwise)
ov.y Observed variables in eqs.y, but not in ov.ind
ov.num Numeric observed variables
ov.ord Ordinal observed variables
ov.ind Observed indicators of latent variables
ov.cind Observed indicators (components) of composites (defined by <~)
ov.orphan Observed variables with intercepts/variances but not part of a latent variable or a regression
ov.interaction Interaction terms involving observed variables (contain a colon :)
ov.efa Observed variables involved in exploratory factor analysis
th Thresholds for ordinal variables
th.mean Thresholds and means/intercepts for numeric variables
lv All latent variables, including those in lv.rv
lv.regular Latent variables defined by =~ only
lv.formative Alias for lv.composite
lv.composite Composite constructs defined by <~
lv.x Latent variables in eqs.x, but not in eqs.y or lv.ind
lv.y Latent variables in eqs.y, but not in eqs.x or lv.ind
lv.nox Latent variables not in lv.x
lv.nonnormal Latent variables with observed indicators not in ov.num
lv.interaction Interaction terms involving latent variables
lv.efa Latent variables involved in exploratory factor analysis
lv.rv Random slopes or random variables
lv.ind Latent indicators (higher-order factors)
lv.ho Higher-order latent variables (with at least one latent indicator)
lv.marker Marker indicators per latent variable
eqs.y Dependent variables (lhs in regression equations)
eqs.x Independent variables (rhs in regression equations)

All of these type options can be used with the lavNames() function to extract specific sets of variable names from a model’s parameter table. One caveat concerns the ov.x category: if the model syntax explicitly mentions the variance (or the intercept) of an exogenous observed variable, that variable is treated as a modeled variable, and it is no longer included in the list of ov.x names.

3.3.2 Parameter table attributes

A fitted lavaan object keeps a list of parameter table attributes (pta for short): various key pieces of information extracted once from the parameter table and reused throughout model estimation. This list can be generated manually from a parameter table as follows:

pta <- lav_pt_attributes(PT)
names(pta)
 [1] "vnames"         "vidx"           "meanstructure"  "nblocks"       
 [5] "ngroups"        "nlevels"        "nvar"           "nfac"          
 [9] "nfac.nonnormal" "th.idx"        

The pta list includes several useful elements. The vnames element is itself a list and contains variable names categorized by type, similar to what can be retrieved using lavNames():

names(pta$vnames)
 [1] "ov"             "ov.x"           "ov.nox"         "ov.model"      
 [5] "ov.y"           "ov.num"         "ov.ord"         "ov.ind"        
 [9] "ov.cind"        "ov.orphan"      "ov.interaction" "ov.efa"        
[13] "th"             "th.mean"        "lv"             "lv.regular"    
[17] "lv.formative"   "lv.composite"   "lv.x"           "lv.y"          
[21] "lv.nox"         "lv.nonnormal"   "lv.interaction" "lv.efa"        
[25] "lv.rv"          "lv.ind"         "lv.ho"          "lv.marker"     
[29] "eqs.y"          "eqs.x"         

Another element, vidx, holds the indices of observed and latent variables within the ov and lv vectors. This is mostly for internal use.

The list also provides metadata about the model structure:

pta$ngroups        # number of groups
[1] 2
pta$nlevels        # number of levels
[1] 1
pta$nblocks        # number of blocks
[1] 2
pta$meanstructure  # meanstructure included or not
[1] TRUE

Additionally, it includes the number of observed (nvar) and latent (nfac) variables per block:

pta$nvar
[[1]]
[1] 6

[[2]]
[1] 6
pta$nfac
[[1]]
[1] 2

[[2]]
[1] 2

Other elements such as nfac.nonnormal and th.idx are intended for internal use only. The former includes the number of factors (per block) that include indicators that are not numeric. The latter gives the position of the thresholds in the th.mean list, which may contain both thresholds and means/intercepts for numeric observed variables.

3.3.3 Additional extractor functions

Three further extractor functions, lav_pt_npar(), lav_pt_ndat(), and lav_pt_df(), count the number of free parameters, the number of summary statistics, and their difference. Because these counts are the ingredients of the degrees of freedom of a model, they are discussed in Section 3.4.

The lav_pt_labels() function generates unique labels for all parameters in the model. These labels are created by concatenating the lhs, op, and rhs columns into a single string without spaces. If the model includes multiple groups, parameters in the second group and beyond receive a suffix (e.g., .g2 for group 2, .g3 for group 3, and so on). In multilevel models, a similar convention applies, using suffixes like .l2 for level 2. This ensures that each parameter has a unique label.

If users have manually assigned labels in the model syntax, those labels will override the automatically generated ones. These parameter labels are especially useful when retrieving estimated values with the coef() function:

coef(fit)
       visual=~x2        visual=~x3       textual=~x5       textual=~x6 
            0.373             0.541             1.187             0.870 
           x1~~x1            x2~~x2            x3~~x3            x4~~x4 
            0.244             1.344             1.009             0.424 
           x5~~x5            x6~~x6    visual~~visual  textual~~textual 
            0.445             0.297             1.151             0.896 
  visual~~textual              x1~1              x2~1              x3~1 
            0.485             4.941             5.984             2.487 
             x4~1              x5~1              x6~1     visual=~x2.g2 
            2.823             3.995             1.922             0.784 
    visual=~x3.g2      speed=~x8.g2      speed=~x9.g2         x1~~x1.g2 
            0.953             1.278             1.019             0.744 
        x2~~x2.g2         x3~~x3.g2         x7~~x7.g2         x8~~x8.g2 
            0.873             0.551             0.603             0.344 
        x9~~x9.g2 visual~~visual.g2   speed~~speed.g2  visual~~speed.g2 
            0.574             0.574             0.459             0.257 
          x1~1.g2           x2~1.g2           x3~1.g2           x7~1.g2 
            4.930             6.200             1.996             3.921 
          x8~1.g2           x9~1.g2 
            5.488             5.327 

The coef() function returns a named vector containing the estimated values of all free model parameters, with the names generated by the lav_pt_labels() function.

3.4 Degrees of freedom

Degrees of freedom are central to SEM: they determine whether a model can be tested statistically, and they appear in the chi-square test, RMSEA, TLI, CFI, and other quantities reported by summary().

The core idea is that, for most traditional SEMs, the data can be summarized in a finite number of statistics (variances, covariances, means, and analogues for categorical outcomes), and that these statistics can be reproduced exactly by a saturated (or unrestricted) model in which each of them is a free parameter. Call the number of such statistics n_{\text{dat}}. A structural equation model requires a number of free parameters to be estimated from those statistics. Call this count n_{\text{par}}. The degrees of freedom are their difference: \text{df} = n_{\text{dat}} - n_{\text{par}}.

Not every model fits this framework. Some models have no saturated counterpart: in a multilevel SEM with random slopes, for example, the model-implied covariance matrix varies from cluster to cluster (it depends on the values of the covariates that carry the random slopes), so the data cannot be summarized in a finite vector of statistics that a saturated model could reproduce (see Section 16.13). For such models, degrees of freedom are not defined, and neither are the chi-square test and the fit measures that build on it. The remainder of this section assumes that a saturated model exists.

When \text{df} > 0, the model is over-identified: it has fewer free parameters than summary statistics. This surplus makes hypothesis testing possible. Under the null hypothesis that the model is correctly specified, the likelihood-ratio statistic T follows approximately a \chi^2_{\text{df}} distribution, and many fit indices use \text{df} in their formulas.

When \text{df} = 0, the model is just-identified (saturated): it reproduces the observed statistics exactly and cannot be tested.

When \text{df} < 0, the model is under-identified: there are not enough summary statistics to uniquely determine all free parameters, and estimation (often) fails.

lavaan computes degrees of freedom in two stages: a preliminary count from the parameter table alone (via lav_pt_df()), followed by a refinement, applied when the test statistic is computed, that accounts for equality constraints.

3.4.1 Number of sample statistics

The function lav_pt_ndat() determines n_{\text{dat}} by reading the parameter table rather than the data. For the two-group model of the previous section:

lav_pt_ndat(PT)
[1] 54

The key factors in this count are the number and type of observed variables, whether a mean structure is present, and the values of fixed_x, conditional_x, and correlation.

In the baseline case (continuous observed variables, no mean structure), the non-redundant elements of the sample covariance matrix give P(P+1)/2 summary statistics. Adding a mean structure contributes P sample means, raising the total to P(P+1)/2 + P.

When exogenous covariates are treated as fixed and non-random (fixed_x = TRUE, the default for models with exogenous observed variables), their means, variances, and covariances are not modeled but treated as known constants. Denoting the number of exogenous x-variables as Q, the function subtracts Q(Q+1)/2 covariance terms (plus Q means if a mean structure is included) from the total. Only the statistics for the non-exogenous variables and their cross-covariances with the x-variables remain. More precisely, only x-moments that actually appear as fixed rows in the parameter table are subtracted: a covariance among x-variables that is absent from the table, as in the independence model with baseline_fixed_x_free_cov = FALSE (Section 3.6.2), is constrained to zero, and its sample counterpart therefore remains in the count.

When the model is conditional on the x-variables (conditional_x = TRUE), the x-variables are excluded from the modeled covariance structure entirely. Instead, the conditional distribution introduces P_{\text{nox}} \times Q regression slopes as effective summary statistics, where P_{\text{nox}} is the number of non-exogenous observed variables. For categorical observed outcomes, analogous slope statistics are also added.

For ordered categorical variables, variances and means are replaced by thresholds: a variable with k response categories has k-1 thresholds. The function subtracts the variances and means of all ordered variables and adds the threshold counts in their place:

ndat[b] <- ndat[b] - nvar_ord   # remove variances of ordered variables
ndat[b] <- ndat[b] - nvar_ord   # remove means of ordered variables
ndat[b] <- ndat[b] + nth        # add thresholds

Here b is the block index (one block per group in a single-level model).

When a correlation structure is fitted instead of a covariance structure (correlation = TRUE), the diagonal of the correlation matrix is fixed to 1 and does not contribute summary statistics. One statistic is subtracted for every standardized variable, that is, for every scaling row in the parameter table with the ~*~ operator. For a full correlation structure this amounts to subtracting P; for a partial correlation structure, only the standardized variables are counted.

In a multiple-group analysis, the count is computed independently per block and then summed. For G groups each containing P continuous variables with no mean structure, the total is G\times P(P+1)/2. In the two-group model above, each group contributes 6 \times (6 + 1)/2 + 6 = 27 summary statistics (six observed variables plus a mean structure), giving the total of 54 returned by lav_pt_ndat().

3.4.2 Number of free parameters

The number of free parameters is the number of rows in the parameter table with a strictly positive value in the free column: n_{\text{par}} = \#\{\text{rows with } \texttt{free} > 0\}. This count is returned by lav_pt_npar():

lav_pt_npar(PT)
[1] 38

This counts each row once. Note that it ignores equality constraints: if two parameters share the same integer in the free column (as happens with ceq_simple = TRUE), they are still counted separately here. The adjustment for equality constraints is handled in a second step. This counting rule, like the two rules that follow, is a property of the parameter table itself: any program holding the table can reproduce it.

3.4.3 Adjustments for equality constraints

Combining the two counts gives a preliminary degrees of freedom, \mathrm{df}_{\text{prelim}} = n_{\text{dat}} - n_{\text{par}}, returned by lav_pt_df():

lav_pt_df(PT)
[1] 16

This preliminary count does not yet account for equality constraints. The actual degrees of freedom used in statistical testing are obtained by applying one of two corrections, depending on how the equality constraints are stored.

With ceq_simple = FALSE, equality constraints appear as explicit rows in the parameter table (operator ==) and are enforced via a constraint Jacobian during optimization. Because the row count treats each constrained parameter individually (they still carry distinct free entries), the preliminary degrees of freedom underestimate the true value by the number of independent equality constraints. Rather than counting constraint rows naively (which fails when constraints are redundant or nonlinear), lavaan computes the rank of the constraint Jacobian restricted to its equality rows. This rank, n_{\text{eq}}, is then added to \mathrm{df}_{\text{prelim}}.

With ceq_simple = TRUE, equality is encoded implicitly, by assigning the same integer in the free column to the constrained parameters. The row count then overcounts the unique free parameters, because it sees multiple rows with the same nonzero free index. The corrected count is the maximum of the free column: since free integers are assigned sequentially, parameters sharing an index contribute only once to the maximum. Degrees of freedom are then recomputed directly as n_{\text{dat}} - \max(\texttt{free}).

In both cases, inequality constraints are deliberately ignored. Their effect on the parameter space depends on whether they are active at the solution, and the standard practice in SEM is not to adjust degrees of freedom for them. (The functions behind these rules are listed in the implementation notes at the end of this chapter.)

To illustrate, consider again the three-factor CFA model:

HS_model <- '
  visual  =~ x1 + x2 + x3
  textual =~ x4 + x5 + x6
  speed   =~ x7 + x8 + x9
'
fit <- sem(HS_model, data = HolzingerSwineford1939)
PT <- parameterTable(fit)
lav_pt_ndat(PT)
[1] 45
lav_pt_npar(PT)
[1] 21
lav_pt_df(PT)
[1] 24

With P= 9 continuous variables and no mean structure, n_{\text{dat}} = 9 \times 10 / 2 = 45. The 21 free parameters consist of 6 free factor loadings (3 markers fixed to 1), 9 residual variances, 3 latent variances, and 3 latent covariances, giving \text{df} = 45 - 21 = 24. This matches the degrees of freedom reported by summary(fit).

Now consider fitting the same model in two groups with factor loadings constrained to be equal across groups (metric invariance):

fit2g <- sem(HS_model, data = HolzingerSwineford1939,
             group = "school", group_equal = "loadings")
PT2g <- parameterTable(fit2g)
lav_pt_ndat(PT2g)
[1] 108
lav_pt_npar(PT2g)
[1] 60
lav_pt_df(PT2g)
[1] 48
fitMeasures(fit2g, "df")
df 
54 

Because the analysis now involves multiple groups, lavaan automatically activates the mean structure. Each group therefore contributes 45 + 9 = 54 summary statistics, giving a total n_{\text{dat}} = 108. lav_pt_npar() counts 60 free parameters: per group, the 21 parameters from before plus 9 intercepts for the observed variables (note that the constrained group-2 loadings still occupy rows with nonzero free entries). The preliminary degrees of freedom is therefore 108 - 60 = 48. There are 6 free factor loadings across the 3 factors (2 per factor, since the marker loadings are fixed), and constraining these to equality across groups adds 6 to the degrees of freedom. The value reported by fitMeasures() is therefore 48 + 6 = 54.

3.5 The parameterEstimates() function

The parameterEstimates() function is built directly on top of the parameter table. It takes the complete parameter table as input, augments it with additional columns such as (Wald-based) z-statistics and p-values, and then extracts a targeted subset of columns for display. The result is a clear, reader-friendly table that emphasizes the information of primary interest: point estimates, standard errors, test statistics, p-values, and confidence intervals:

HS_model <- ' 
  visual  =~ x1 + x2 + x3
  textual =~ x4 + x5 + x6
  speed   =~ x7 + x8 + x9 
'
fit <- sem(HS_model, data = HolzingerSwineford1939)
parameterEstimates(fit)
       lhs op     rhs   est    se      z pvalue ci.lower ci.upper
1   visual =~      x1 1.000 0.000     NA     NA    1.000    1.000
2   visual =~      x2 0.554 0.100  5.554      0    0.358    0.749
3   visual =~      x3 0.729 0.109  6.685      0    0.516    0.943
4  textual =~      x4 1.000 0.000     NA     NA    1.000    1.000
5  textual =~      x5 1.113 0.065 17.014      0    0.985    1.241
6  textual =~      x6 0.926 0.055 16.703      0    0.817    1.035
7    speed =~      x7 1.000 0.000     NA     NA    1.000    1.000
8    speed =~      x8 1.180 0.165  7.152      0    0.857    1.503
9    speed =~      x9 1.082 0.151  7.155      0    0.785    1.378
10      x1 ~~      x1 0.549 0.114  4.833      0    0.326    0.772
11      x2 ~~      x2 1.134 0.102 11.146      0    0.934    1.333
12      x3 ~~      x3 0.844 0.091  9.317      0    0.667    1.022
13      x4 ~~      x4 0.371 0.048  7.779      0    0.278    0.465
14      x5 ~~      x5 0.446 0.058  7.642      0    0.332    0.561
15      x6 ~~      x6 0.356 0.043  8.277      0    0.272    0.441
16      x7 ~~      x7 0.799 0.081  9.823      0    0.640    0.959
17      x8 ~~      x8 0.488 0.074  6.573      0    0.342    0.633
18      x9 ~~      x9 0.566 0.071  8.003      0    0.427    0.705
19  visual ~~  visual 0.809 0.145  5.564      0    0.524    1.094
20 textual ~~ textual 0.979 0.112  8.737      0    0.760    1.199
21   speed ~~   speed 0.384 0.086  4.451      0    0.215    0.553
22  visual ~~ textual 0.408 0.074  5.552      0    0.264    0.552
23  visual ~~   speed 0.262 0.056  4.660      0    0.152    0.373
24 textual ~~   speed 0.173 0.049  3.518      0    0.077    0.270

The parameterEstimates() function offers extensive flexibility for customizing the output. It allows control over which columns are displayed, whether standardized estimates should be included (via standardized = TRUE), whether confidence intervals should be omitted (ci = FALSE), and whether certain rows (for example, system-defined constraints or fixed parameters) should be excluded, using options such as remove_system_eq = TRUE or remove_fixed = TRUE. This flexibility makes it straightforward to create a concise and targeted table, whether the purpose is model checking during development, preparing results for publication, or exporting estimates for additional analysis. In effect, parameterEstimates() functions as a filter over the full parameter table, providing convenience and focus while preserving access to all underlying details.

For standardized estimates specifically, the standardizedSolution() function provides a direct alternative. It works similarly to parameterEstimates(), but computes and reports standardized results, including standard errors for standardized parameters.

By default, parameterEstimates() produces a standard R data.frame, which can be easily inspected, subset, or manipulated with standard R tools. If output = "text" is specified, however, the function generates formatted text output, which is also used by the summary() function:

subset(parameterEstimates(fit, output = "text"), op == "=~")
Latent Variables:
                   Estimate  Std.Err  z-value  P(>|z|) ci.lower ci.upper
  visual =~                                                             
    x1                1.000                               1.000    1.000
    x2                0.554    0.100    5.554    0.000    0.358    0.749
    x3                0.729    0.109    6.685    0.000    0.516    0.943
  textual =~                                                            
    x4                1.000                               1.000    1.000
    x5                1.113    0.065   17.014    0.000    0.985    1.241
    x6                0.926    0.055   16.703    0.000    0.817    1.035
  speed =~                                                              
    x7                1.000                               1.000    1.000
    x8                1.180    0.165    7.152    0.000    0.857    1.503
    x9                1.082    0.151    7.155    0.000    0.785    1.378

The same output = "text" argument is also available for the standardizedSolution() function.

3.6 Generating parameter tables

The most common way to create a parameter table in lavaan is by using the lavParTable() function (or its alias lavaanify()). These functions take either model syntax or a parsed, flattened version of the syntax (as returned by lavParseModelString()) and produce the corresponding parameter table.

However, it is also possible to construct a parameter table manually. At a minimum, the table must include three columns: lhs, op, and rhs. For example:

model <- list(lhs = c("f", "f", "f"), 
               op = c("=~", "=~", "=~"), 
              rhs = c("y1", "y2", "y3")
             )
pt <- data.frame(model, stringsAsFactors = FALSE)
pt
  lhs op rhs
1   f =~  y1
2   f =~  y2
3   f =~  y3

This initial table is incomplete. While users can manually add the missing columns, especially free (indicating whether a parameter is freely estimated) and ustart (user-specified starting values), an easier approach is to use the lav_pt_complete() function to complete the table automatically:

as.data.frame(lav_pt_complete(pt))
  id lhs op rhs user block group free ustart exo label start
1  1   f =~  y1    1     1     1    1     NA   0         0.7
2  2   f =~  y2    1     1     1    2     NA   0         0.7
3  3   f =~  y3    1     1     1    3     NA   0         0.7

This function supplements the table with all required columns, ensuring it is valid for further processing. However, unlike lavParTable(), it does not add new parameters (such as variances or intercepts). The user is responsible for ensuring that the model is fully specified and identifiable.

3.6.1 Generating a parameter table for the unrestricted model

After fitting a model, it is possible to generate a parameter table for the unrestricted (or saturated) model, often called the \mathsf{H}_1 or ‘alternative’ model; the role of this model, and how lavaan estimates it, is the topic of Section 5.7. The unrestricted model contains as many free parameters as there are sample statistics, resulting in zero degrees of freedom.

In the case where all variables are numeric and no mean structure is specified, the unrestricted model consists of parameters for all nonredundant elements of the variance–covariance matrix. If a mean structure is included, additional free parameters are added for the means of all observed variables.

As an illustration, consider fitting a simple one-factor model and then generating the unrestricted parameter table:

model <- 'f =~ x1 + x2 + x3'
fit <- sem(model, data = HolzingerSwineford1939)
pt_un <- lav_pt_unrestricted(fit)
PT_un <- as.data.frame(pt_un, stringsAsFactors = FALSE) # convert to data.frame
PT_un
  id lhs op rhs user block group free    ustart exo
1  1  x1 ~~  x1    1     1     1    1 1.3583698   0
2  2  x2 ~~  x2    1     1     1    2 1.3817839   0
3  3  x3 ~~  x3    1     1     1    3 1.2748649   0
4  4  x1 ~~  x2    1     1     1    4 0.4073713   0
5  5  x1 ~~  x3    1     1     1    5 0.5798993   0
6  6  x2 ~~  x3    1     1     1    6 0.4510639   0

In this example, there are P= 3 observed variables, resulting in 3 \times (3 + 1)/2 = 6 unique elements in the variance–covariance matrix. These elements correspond exactly to those appearing in the unrestricted parameter table. Once specified, this unrestricted model can be estimated to obtain quantities such as the unrestricted log-likelihood, which are crucial for computing fit measures and other model comparison indices.

3.6.2 Generating a parameter table for the independence model

In addition to the unrestricted model, lavaan also provides functionality to generate a parameter table for the independence model using the lav_pt_independence() function. The independence model, often referred to as the null model, assumes that all observed variables are uncorrelated, that is, the off-diagonal elements of the variance-covariance matrix are constrained to zero. This model often serves as a baseline for evaluating model fit, especially in comparative fit indices such as the Tucker-Lewis Index (TLI) and the Comparative Fit Index (CFI).

The independence model includes free parameters only for the variances of the observed variables (and for the means, if a mean structure is included). Exogenous observed covariates are the exception: by default (baseline_fixed_x_free_cov = TRUE), the covariances among the covariates are not constrained to zero but are retained in the parameter table: the independence assumption applies to the modeled variables only, not to the covariates. Whether these retained covariances are free or fixed follows the fixed_x setting, exactly as for the variances and means of the covariates: they are freely estimated when fixed_x = FALSE, and fixed at their sample values when fixed_x = TRUE. Both choices yield the same baseline chi-square statistic and degrees of freedom, because the maximum likelihood estimate of a saturated covariate block in an independence model is the sample covariance matrix. Setting baseline_fixed_x_free_cov = FALSE (as mimic = "EQS" does) constrains the covariances among the covariates to zero as well, which yields a larger baseline chi-square statistic with correspondingly more degrees of freedom, and hence, as soon as the covariates are correlated to any substantial degree, higher values for incremental fit indices such as the CFI. The parameter table for the independence model can be extracted from a fitted model as follows:

model <- 'f =~ x1 + x2 + x3'
fit <- sem(model, data = HolzingerSwineford1939, meanstructure = TRUE)
pt_indep <- lav_pt_independence(fit)
PT_indep <- as.data.frame(pt_indep, stringsAsFactors = FALSE)
PT_indep
  id lhs op rhs user block group free   ustart exo
1  1  x1 ~~  x1    1     1     1    1 1.358370   0
2  2  x2 ~~  x2    1     1     1    2 1.381784   0
3  3  x3 ~~  x3    1     1     1    3 1.274865   0
4  4  x1 ~1        1     1     1    4 4.935770   0
5  5  x2 ~1        1     1     1    5 6.088040   0
6  6  x3 ~1        1     1     1    6 2.250415   0

In this example, with P= 3 observed variables and a mean structure included, the independence model will contain three free variances and three free means, while the covariances are constrained to zero (they are absent from the table).

3.6.3 Merging two parameter tables together

The lav_pt_merge() function is designed to combine two or more parameter tables into a single, unified parameter table. This is particularly helpful when constructing complex models from smaller modular components or when incrementally extending an existing model in a programmatic manner. The parameter tables being merged do not need to have identical columns; any missing columns will automatically be added before merging.

To illustrate its use, consider two simple parameter tables, each defining a latent variable model with different sets of indicators:

model1 <- '
  f1 =~ x1 + x2 + x3
'
model2 <- '
  f2 =~ x4 + x5 + x6
'
pt1 <- lavParTable(model1)[,c("lhs", "op", "rhs")]
pt2 <- lavParTable(model2)[,c("lhs", "op", "rhs", "free", "ustart")]
pt_merged <- lav_pt_merge(pt1, pt2)
as.data.frame(pt_merged)
   lhs op rhs block free ustart
1   f1 =~  x1     1    0      0
2   f1 =~  x2     1    0      0
3   f1 =~  x3     1    0      0
4   x1 ~~  x1     1    0      0
5   x2 ~~  x2     1    0      0
6   x3 ~~  x3     1    0      0
7   f1 ~~  f1     1    0      0
8   f2 =~  x4     1    1     NA
9   f2 =~  x5     1    2     NA
10  f2 =~  x6     1    3     NA
11  x4 ~~  x4     1    0      0
12  x5 ~~  x5     1    0      0
13  x6 ~~  x6     1    0      0
14  f2 ~~  f2     1    0      0

This merged parameter table is not yet complete. It is necessary to specify which parameters are free in the first factor model and update the free column to ensure that the parameter indices are sequential. Additionally, the model currently lacks a covariance between the two latent factors. To add individual rows to an existing parameter table, the lav_pt_add() function can be used. The following code completes the merged table:

pt <- lav_pt_add(pt_merged, 
                       add = list(lhs = "f1", op = "~~", rhs = "f2"))
pt$free <- rep(1, length(pt$lhs))                # initially all free
pt$ustart <- rep(as.numeric(NA), length(pt$lhs)) # initially all NA
pt$free[c(1,8)] <- 0                             # markers not free
pt$ustart[c(1,8)] <- 1                           # fix markers to 1
pt <- lav_pt_complete(pt)
PT <- as.data.frame(pt)
PT
   id lhs op rhs user block group free ustart exo label start
1   1  f1 =~  x1    1     1     1    0      1   0         1.0
2   2  f1 =~  x2    1     1     1    1     NA   0         0.7
3   3  f1 =~  x3    1     1     1    2     NA   0         0.7
4   4  x1 ~~  x1    1     1     1    3     NA   0         1.0
5   5  x2 ~~  x2    1     1     1    4     NA   0         1.0
6   6  x3 ~~  x3    1     1     1    5     NA   0         1.0
7   7  f1 ~~  f1    1     1     1    6     NA   0         1.0
8   8  f2 =~  x4    1     1     1    0      1   0         1.0
9   9  f2 =~  x5    1     1     1    7     NA   0         0.7
10 10  f2 =~  x6    1     1     1    8     NA   0         0.7
11 11  x4 ~~  x4    1     1     1    9     NA   0         1.0
12 12  x5 ~~  x5    1     1     1   10     NA   0         1.0
13 13  x6 ~~  x6    1     1     1   11     NA   0         1.0
14 14  f2 ~~  f2    1     1     1   12     NA   0         1.0
15 15  f1 ~~  f2    1     1     1   13     NA   0         0.0

Although this approach may appear laborious and error-prone, it shows how more complex parameter tables can be constructed step-by-step from simpler building blocks.

3.7 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.

The degrees-of-freedom rules of Section 3.4 are implemented by the exported functions lav_pt_ndat(), lav_pt_npar(), and lav_pt_df() (in lav_partable_utils.R; also available under their original names lav_partable_ndat(), lav_partable_npar(), and lav_partable_df()), and by the internal helper lav_test_df() in lav_test_utils.R (called from lav_model_test() when the test statistic is computed), which applies the equality-constraint corrections using the constraint Jacobian stored in the fitted model object. The rules themselves are the specification; the function names and the storage of the Jacobian are implementation detail. The parameter table attributes of Section 3.3.2 are stored in the @pta slot of the fitted object, and lavNames() is a wrapper around the internal lav_pt_vnames().


  1. lavNames() and the exported lav_pt_* functions used in this chapter share one engine. Before version 0.7-2, the lav_pt_* family was called lav_partable_*; the longer names remain exported as aliases. See Section 1.4.↩︎