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