Package 'semTests'

Title: Robust Test Statistics for Structural Equation Models
Description: Supports penalized eigenvalue block-averaging and penalized regression p-values (Foldnes, Moss, Grønneberg, 2024) <doi:10.1080/10705511.2024.2372028>, including their extension to nested model comparison (Foldnes, Grønneberg, Moss, 2026) <doi:10.3758/s13428-026-02968-4>, as well as traditional p-values such as Satorra-Bentler. All p-values can be calculated using unbiased or biased gamma estimates (Du, Bentler, 2022) <doi:10.1080/10705511.2022.2063870> and two choices of chi square statistics. The tests apply to any minimum-discrepancy estimator -- ML, GLS, ULS, and categorical WLSMV/DWLS -- with experimental support for full-information maximum-likelihood (FIML) fits under missing data.
Authors: Jonas Moss [aut, cre] (ORCID: <https://orcid.org/0000-0002-6876-6964>), Njål Foldnes [ctb] (ORCID: <https://orcid.org/0000-0001-6889-6067>), Steffen Grønneberg [ctb] (ORCID: <https://orcid.org/0000-0003-2785-6530>)
Maintainer: Jonas Moss <[email protected]>
License: GPL (>= 3)
Version: 0.9.0
Built: 2026-06-09 16:38:54 UTC
Source: https://github.com/cran/semTests

Help Index


Print method for p-values from pvalues() / pvalues_nested().

Description

Prints the p-values, then a one-line provenance footer (estimator, data type, information, df) recording the options used.

Usage

## S3 method for class 'semTests_pvalues'
print(x, ...)

Arguments

x

A semTests_pvalues object.

...

Passed to the default print method.

Value

x, invisibly.


Calculate p-values for one or two lavaan objects.

Description

Calculate p-values for a lavaan object using several methods, including penalized eigenvalue block-averaging and penalized regression estimators. The recommended choices of p-values are included as default values. Multiple p-values can be returned simultaneously.

Usage

pvalues(object, tests = if (is_classic_nt(object)) "pEBA4_RLS" else "pEBA4")

pvalues_nested(
  m0,
  m1,
  method = c("2000", "2001"),
  tests = if (is_classic_nt(m0)) "PALL_UG_ML" else "PALL",
  A.method = c("exact", "delta")
)

Arguments

object, m0, m1

One or two lavaan objects. pvalues does goodness-of-fit testing on one object, pvalues_nested does hypothesis testing on two nested models.

tests

A list of tests to evaluate on the form "(test)_(ug?)_(rls?)"; see the default arguments and details below. The defaults are the recommended options.

method

For nested models, choose between 2000 and 2001. Note: 2001 and Satorra-Bentler will not correspond with the variant in the paper.

A.method

For nested FIML models, choose "exact" for the literal parameter restriction map or "delta" for the local moment-tangent restriction map.

Details

The test argument is a list of character strings on the form (test)(ug?)(ml?), for instance, SB_UG_RLS.

  • The first part of the string specifies the desired test. The supported tests are listed below.

  • If UG is included in the string the unbiased estimator of the fourth order moment matrix (Du, Bentler, 2022) is used. If not, the standard biased matrix is used. There is no simple relationship between p-value performance and the choice of unbiased.

  • The final part specifies the chi square statistic. The ML choice uses the chi square based on the normal discrepancy function (Bollen, 2014). The RLS choice (default) uses the reweighted least squares statistic of Browne (1974).

The peba method is the recommended default. It partitions the eigenvalues into j equally sized sets (if not possible, the smallest set is incomplete), shrinks them towards their common mean, and averages within each set. Provide a list of integers j to partition with respect to; the best choices are typically about 26. It was introduced by Foldnes, Moss, & Grønneberg (2024).

pols is a penalized regression method with a penalization term ranging from 0 to infinity. Foldnes, Moss, & Grønneberg (2024) studied pols=2, which has good performance in a variety of contexts.

pall penalizes all eigenvalues in ugamma, while all uses all eigenvalues without penalization. pall is the recommended option for nested models, for which the penalized methods were extended and evaluated by Foldnes, Grønneberg, & Moss (2026).

The eba method is the unpenalized predecessor of peba (Foldnes & Grønneberg, 2018): it averages within the eigenvalue blocks without shrinkage. It is generally outperformed by peba and is kept mainly for comparison; eba with j=2j=4 tends to work best.

In addition, you may specify a

  • std the standard p-value where the choice of chisq is approximated by a chi square distribution.

  • sb Satorra-Bentler p-value. The p-value proposed by Satorra and Bentler (1994).

  • ss The scaled and shifted p-value proposed by Asparouhov & Muthén (2010).

  • sf The scaled F p-value proposed by Wu and Lin (2016).

The unbiased argument is TRUE if the unbiased estimator of the fourth order moment matrix (Du, Bentler, 2022) is used. If FALSE, the standard biased matrix is used. There is no simple relationship between p-value performance and the choice of unbiased.

The chisq argument controls which basic test statistic is used. The ml choice uses the chi square based on the normal discrepancy function (Bollen, 2014). The rls choice uses the reweighted least squares statistic of Browne (1974).

Estimators and data types

The authoritative list of supported estimators, data types, and configurations – the matrix this function is validated against – is semTests-support (?semTests-support). In brief:

The limiting null law of the test statistic is a weighted sum of chi-squares for any minimum-discrepancy estimator, so these tests are not specific to normal-theory ML. pvalues() supports ML/MLM/MLR, GLS, ULS, FIML (missing data), and categorical WLSMV/DWLS, with single- and multi-group continuous and categorical fits; pvalues_nested() supports the continuous estimators (nested categorical is not yet implemented). The model must be fit so that lavaan exposes the asymptotic moment covariance – fit with a robust test such as test = "satorra.bentler", or with estimator = "MLM"/"MLR"/"DWLS". Off the classical continuous-complete-data ML case, the RLS statistic (browne.residual.nt.model) and the unbiased (UG) Du-Bentler gamma are undefined and are refused; the standard statistic and the biased gamma are used instead. ADF/WLS is the degenerate exception, where the test equals the ordinary chi-square and the correction adds nothing.

Support beyond classical normal-theory ML – GLS, ULS, categorical WLSMV/DWLS, FIML missing data, and nested FIML comparison – is experimental as of 0.9.0; see the Stability note in semTests-support.

The information matrix (expected vs observed) is taken from the fit; to control it, fit the lavaan model with information = "expected" or "observed". The returned object records the estimator, statistic, information type, data type and degrees of freedom actually used; see its printed footer and attr(x, "semtests").

Value

A named numeric vector of p-values, of class semTests_pvalues, carrying an "semtests" attribute that records the options used (estimator, statistic, information type, gamma type, data type, and degrees of freedom).

References

Foldnes, N., Moss, J., & Grønneberg, S. (2024). Improved goodness of fit procedures for structural equation models. Structural Equation Modeling: A Multidisciplinary Journal, 1-13. https://doi.org/10.1080/10705511.2024.2372028

Foldnes, N., Grønneberg, S., & Moss, J. (2026). Penalized eigenvalue block averaging: Extension to nested model comparison and Monte Carlo evaluations. Behavior Research Methods. https://doi.org/10.3758/s13428-026-02968-4

Satorra, A., & Bentler, P. M. (1994). Corrections to test statistics and standard errors in covariance structure analysis. https://psycnet.apa.org/record/1996-97111-016

Asparouhov, & Muthén. (2010). Simple second order chi-square correction. Mplus Technical Appendix. https://www.statmodel.com/download/WLSMV_new_chi21.pdf

Wu, H., & Lin, J. (2016). A Scaled F Distribution as an Approximation to the Distribution of Test Statistics in Covariance Structure Analysis. Structural Equation Modeling. https://doi.org/10.1080/10705511.2015.1057733

Foldnes, N., & Grønneberg, S. (2018). Approximating Test Statistics Using Eigenvalue Block Averaging. Structural Equation Modeling, 25(1), 101-114. https://doi.org/10.1080/10705511.2017.1373021

Du, H., & Bentler, P. M. (2022). 40-Year Old Unbiased Distribution Free Estimator Reliably Improves SEM Statistics for Nonnormal Data. Structural Equation Modeling: A Multidisciplinary Journal, 29(6), 872-887. https://doi.org/10.1080/10705511.2022.2063870

Bollen, K. A. (2014). Structural Equations with Latent Variables (Vol. 210). John Wiley & Sons. https://doi.org/10.1002/9781118619179

Browne. (1974). Generalized least squares estimators in the analysis of covariance structures. South African Statistical Journal. https://doi.org/10.10520/aja0038271x_175

See Also

semTests-support for the full list of supported configurations.

Examples

library("semTests")
library("lavaan")
model <- "visual  =~ x1 + x2 + x3
          textual =~ x4 + x5 + x6
          speed   =~ x7 + x8 + x9"
object <- cfa(model, HolzingerSwineford1939, estimator = "MLM")
pvalues(object)

# For the pEBA6 method with biased gamma and ML chisq statistic:
pvalues(object, "pEBA6_ML")

# Nested model comparison (constrain the textual loadings to be equal):
constrained <- "visual  =~ x1 + x2 + x3
                textual =~ a*x4 + a*x5 + a*x6
                speed   =~ x7 + x8 + x9"
m1 <- cfa(model, HolzingerSwineford1939, estimator = "MLM")
m0 <- cfa(constrained, HolzingerSwineford1939, estimator = "MLM")
pvalues_nested(m0, m1)