Test used for lavaan multigroup comparisons?

40 views
Skip to first unread message

Toby

unread,
Nov 13, 2025, 10:01:18 PM (8 days ago) Nov 13
to lavaan
Forgive me for this probably very novice question!

I understand that one can test for between group path and intercept comparisons using code like so:

group: 1
depression~ groupAfin*finances + sex
depression~ depression_groupA_int*1

group: 2
depression~ groupBfin*finances + sex
depression~ depression_groupB_int*1

depression_int_diff := depression_groupA_int - depression_groupB_int
finances_slope_diff := groupAfin - groupBfin

My question is - what test is lavaan running here to compare these group differences, exactly? A simple Wald z-test?

I am using MLR, if that changes anything.

Thank you so much! And apologies again - I just cannot seem to find the relevant information in the user's manual.

Best wishes

T

Shu Fai Cheung (張樹輝)

unread,
Nov 14, 2025, 1:04:30 AM (8 days ago) Nov 14
to lavaan
The delta method is used to compute the standard error of a function of parameters. The difference is a function of model parameters (slopes or intercepts). Therefore, the delta method is also used computationally, I believe (unless linear functions are handled differently in the code).

However, in this special case, the difference is just a linear function of two model parameters. Therefore, its standard error can be easily computed manually, using the variance-covariance matrix of the two model parameters, just like how we compute the standard error of a difference in other contexts. This is an illustration:

``` r
library(lavaan)
#> This is lavaan 0.6-20
#> lavaan is FREE software! Please report any bugs.

dat <- HolzingerSwineford1939

mod <-
"
x2 ~ c(b1, b2)*x1 + x3
x2 ~ c(int1, int2)*1

int_diff := int1 - int2
b_diff := b1 - b2
"

fit <- sem(
          mod,
          data = dat,
          group = "school",
          estimator = "MLR"
        )
est <- parameterEstimates(
          fit,
          ci = FALSE
        )
fit_vcov <- vcov(fit)

# ==== b_diff

(b_diff <- est$est[1] - est$est[10])
#> [1] -0.00305765
est[20, "est"]
#> [1] -0.00305765

# Derive the SE of the difference
(b_diff_vcov <- fit_vcov[c("b1", "b2"), c("b1", "b2")])
#>              b1           b2
#> b1 6.561641e-03 2.887112e-29
#> b2 2.887112e-29 9.202942e-03
(i <- matrix(c(1, -1), 2, 1))
#>      [,1]
#> [1,]    1
#> [2,]   -1
(b_diff_v <- t(i) %*% b_diff_vcov %*% i)
#>            [,1]
#> [1,] 0.01576458
(b_diff_se <- sqrt(b_diff_v))
#>           [,1]
#> [1,] 0.1255571
# Compare with lavaan SE
est[20, "se"]
#> [1] 0.1255571


# ==== int_diff

(int_diff <- est$est[3] - est$est[12])
#> [1] -0.1721258
est[19, "est"]
#> [1] -0.1721258

# Derive the SE of the difference
(int_diff_vcov <- fit_vcov[c("int1", "int2"), c("int1", "int2")])
#>              int1         int2
#> int1 1.298780e-01 5.557666e-28
#> int2 5.557666e-28 1.641784e-01
(i <- matrix(c(1, -1), 2, 1))
#>      [,1]
#> [1,]    1
#> [2,]   -1
(int_diff_v <- t(i) %*% int_diff_vcov %*% i)
#>           [,1]
#> [1,] 0.2940563
(int_diff_se <- sqrt(int_diff_v))
#>           [,1]
#> [1,] 0.5422696
# Compare with lavaan SE
est[19, "se"]
#> [1] 0.5422696
```

Whether ML or MLR is used does not affect the method, although it affects the variance-covariance matrix of the model parameters.

Hope this helps.

-- Shu Fai

Toby

unread,
Nov 14, 2025, 1:17:40 AM (8 days ago) Nov 14
to lavaan
Thank you so much, Shu Fai!

The reason I ask is that I am being asked to clarify the name of this test for a journal article. Would it suffice to refer to say: linear functions for relevant model parameter pairs was used to compute differences between groups.

It would be lovely if there was an actual name for it is all. Do you know of the name of this test?

Again, sorry for the novice questioning!

Victor Avasi

unread,
Nov 14, 2025, 1:38:27 AM (8 days ago) Nov 14
to lav...@googlegroups.com
Hi Toby,
Your syntax shows that you are indeed running the Wald Z- test where you answer the question "How many standard errors away is my estimate from the test value?". When you use the := operator, you are asking the software to first calculate a difference. Second, calculate the standard error of that difference using the Delta Method. Third, perform the Wald Z-test by dividing the difference by its standard error to get the Z-value and convert that into a p-value.

This procedure allows you to test your specific hypotheses.

Best regards,

Victor

--
You received this message because you are subscribed to the Google Groups "lavaan" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lavaan+un...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/lavaan/1dedab7f-5d0d-43e4-872b-9aba06a0df5fn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages