Learn R Programming

psychonetrics (version 0.17.8)

equalityScoreTest: Score (Lagrange Multiplier) test for cross-group equality constraints

Description

Computes the score test (also known as the Lagrange Multiplier test) for releasing cross-group equality constraints in a multi-group psychonetrics model. Both the per-group univariate score statistics and the joint multivariate score statistic (one statistic per equality-constrained parameter, with df = G - 1) are returned.

The algorithm used by method = "jacobian" (the default) is a direct port of the score-test logic in lavaan::lavTestScore (Rosseel, 2012) and reproduces lavaan's output to numerical precision. The derivation closely follows the implementation in R/lav_test_score.R of the lavaan source code (https://github.com/yrosseel/lavaan), reused here with thanks to Yves Rosseel under the GPL (\(\geq\) 2) license shared by both packages. The underlying gradient and Fisher-information machinery is provided by psychonetrics, so no refitting and no run-time dependence on lavaan is required.

With the default method = "jacobian" the algorithm reproduces lavaan::lavTestScore exactly: the model is augmented with G-1 extra parameters per equality-constrained tuple (one per non-reference group), the gradient and expected information are computed at the constrained MLE, and for each constraint the test statistic $$T = N \cdot s' \cdot \tilde{J}^{-1} \cdot s$$ is formed, where \(s\) is the gradient of the log-likelihood and \(\tilde{J}^{-1}\) is the upper-left block of the generalised inverse of the bordered information matrix \([J\ R'^T;\ R\ 0]\), with \(R\) the rows of the constraint Jacobian for the constraints that are NOT being tested. This is the same construction used by lavaan::lavTestScore.

method = "schur" uses a faster Schur-complement construction (the same used by psychonetrics for ordinary modification indices). It is much faster for complex models because it inverts only the (smaller) block of the information matrix corresponding to the currently free parameters, but it is not exactly equivalent to lavaan in unbalanced multi-group samples (it agrees in balanced samples). Both methods follow the same asymptotic chi-square reference distribution.

Usage

equalityScoreTest(x, matrices, top = 10, verbose = TRUE,
                  method = c("jacobian","schur"))

Value

Invisibly returns a list with two data frames:

uni

Univariate score tests, one row per released parameter (i.e. one row per group beyond the reference group), sorted from largest to smallest \(X^2\).

total

Joint multivariate score tests, one row per equality-constrained parameter (i.e. one row per (matrix, row, column) triple), sorted from largest to smallest \(X^2\). The joint test has df = G - 1 when the parameter is constrained equal across all \(G\) groups.

Arguments

x

A fitted (run) multi-group psychonetrics model.

matrices

Optional vector of matrix names to restrict the test to. By default all matrices are considered.

top

How many rows to print in each table.

verbose

Logical, should the formatted tables be printed?

method

Construction of the score test. "jacobian" (default) reproduces lavaan::lavTestScore exactly. "schur" uses a Schur-complement construction that is faster for complex models but only matches lavaan for balanced multi-group samples.

Author

Sacha Epskamp <mail@sachaepskamp.com>. The method = "jacobian" implementation is a port of the score-test machinery in lavaan::lavTestScore by Yves Rosseel.

Details

For two groups (\(G = 2\)) the joint test reduces to the univariate test (both have df = 1). The two tests differ for \(G \ge 3\), where the joint test correctly accounts for the covariance between the released parameters via the (Schur-complemented) Fisher information, instead of summing or otherwise aggregating univariate statistics.

References

Rosseel, Y. (2012). lavaan: An R Package for Structural Equation Modeling. Journal of Statistical Software, 48(2), 1-36. tools:::Rd_expr_doi("10.18637/jss.v048.i02")

lavaan source code: https://github.com/yrosseel/lavaan (in particular R/lav_test_score.R).

See Also

MIs, partialprune

Examples

Run this code
# \donttest{
library("dplyr")
library("psychTools")
data(bfi)

ExData <- bfi %>% select(E1:E5, gender) %>% na.omit
vars <- names(ExData)[1:5]

mod <- ggm(ExData, vars = vars, groups = "gender") %>%
  runmodel %>%
  groupequal("omega") %>%
  runmodel

equalityScoreTest(mod)
# }

Run the code above in your browser using DataLab