Delta method for defined parameters

51 views
Skip to first unread message

Henrik Andersen

unread,
Sep 5, 2025, 6:55:58 AM (7 days ago) Sep 5
to lavaan
Hi everyone, 

I would just like to know if lavaan treats all defined parameters equally with respect to how the standard errors are computed. Say I defined a parameter for a simple difference in means. I would do something like: 

y2 ~ m2*1
y1 ~ m1*1
d1 := m2 - m1

Does lavaan use the Delta method (calculating the vector derivatives, getting the covariance matrix of m1, m2, pre- and post-multiplying etc.) even for trivial things like this? I certainly don't know how this could be done programmatically otherwise, but you never know. 

My assumption is that the Delta method is used for even trivial things like this but the distinction is that the solution here is exact, whereas for other non-linear functions (e.g., m2/m1) the solution is only an approximation? Could someone deny or confirm this for me? 

Thanks very much!
Henrik 


 

Felipe Vieira

unread,
Sep 9, 2025, 4:29:05 PM (3 days ago) Sep 9
to lav...@googlegroups.com
Hi Henrik,

I am definitely not the main person to answer this. But, upon checking the source code (lav_model_vcov.R; specifically, under the "3. defined parameters" step in the last function lav_model_vcov_se), it seems like you are right. 

If doing it manually, one also obtains the same results: 

set.seed(1)
n <- 20; y1 <- rnorm(n, mean = 8, sd = 3); y2 <- rnorm(n, mean = 10, sd = 3)
data <- data.frame(y1 = y1, y2 = y2)

model <-
"
  y1 ~ m1*1
  y2 ~ m2*1

  diff := m2 - m1
"

fit <- sem(model, data = data); summary(fit)
#lavaan_diff <- parameterEstimates(fit)[parameterEstimates(fit)$label == "diff", "est"]
lavaan_se <- parameterEstimates(fit)[parameterEstimates(fit)$label == "diff", "se"]; (lavaan_se)

# manual calculation using tge delta method:
vcov_matrix <- vcov(fit)[c("m1", "m2"), c("m1", "m2")]; vcov_matrix
# f(m1, m2) = m2 - m1
# jacobian wrt to m1 = -1 and wrt to m2 = 1
jacobian <- matrix(c(-1, 1), nrow = 1)
# delta method: var(diff) = j * Cov * j'
var_diff <- jacobian %*% vcov_matrix %*% t(jacobian); sqrt(var_diff[1,1])

Anyway, I will double check it or someone will hopefully correct me if I am wrong. 

Best, 
Felipe. 

--
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/890e09b2-cb18-4b7d-b1af-9d948c1b09edn%40googlegroups.com.

Felipe Vieira

unread,
Sep 9, 2025, 4:31:30 PM (3 days ago) Sep 9
to lav...@googlegroups.com
Hi Henrik,

I am definitely not the main person to answer this. But, upon checking the source code (lav_model_vcov.R; specifically, under the "3. defined parameters" step in the last function lav_model_vcov_se), it seems like you are right. 

If doing it manually, one also obtains the same results: 

set.seed(1)
n <- 20; y1 <- rnorm(n, mean = 8, sd = 3); y2 <- rnorm(n, mean = 10, sd = 3) 
data <- data.frame(y1 = y1, y2 = y2)

model <- 
"
  y1 ~ m1*1
  y2 ~ m2*1

  diff := m2 - m1
"

fit <- sem(model, data = data); summary(fit)
#parameterEstimates(fit)[parameterEstimates(fit)$label == "diff", "est"]

lavaan_se <- parameterEstimates(fit)[parameterEstimates(fit)$label == "diff", "se"]; (lavaan_se)

# manual calculation using tge delta method:
vcov_matrix <- vcov(fit)[c("m1", "m2"), c("m1", "m2")]; vcov_matrix
# f(m1, m2) = m2 - m1
# jacobian wrt to m1 = -1 and wrt to m2 = 1
jacobian <- matrix(c(-1, 1), nrow = 1)
# delta method: var(diff) = j * cov * j'
var_diff <- jacobian %*% vcov_matrix %*% t(jacobian); sqrt(var_diff)

Anyway, I will double check it or someone will hopefully correct me if I am wrong. 

Best, 
Felipe. 
On Fri, Sep 5, 2025 at 12:56 PM Henrik Andersen <hander...@gmail.com> wrote:
--

Terrence Jorgensen

unread,
Sep 10, 2025, 9:21:22 AM (2 days ago) Sep 10
to lavaan
I would just like to know if lavaan treats all defined parameters equally with respect to how the standard errors are computed.

Yes.

Does lavaan use the Delta method (calculating the vector derivatives, getting the covariance matrix of m1, m2, pre- and post-multiplying etc.) even for trivial things like this? 

As Felipe posted about the source code, lavaan does not check the formulas for defined parameters to distinguish special cases. 

Terrence D. Jorgensen    (he, him, his)
Assistant Professor, Methods and Statistics
Research Institute for Child Development and Education, the University of Amsterdam
http://www.uva.nl/profile/t.d.jorgensen

Henrik Andersen

unread,
Sep 11, 2025, 3:52:28 AM (yesterday) Sep 11
to lavaan
Thanks Felipe and Terrence! That's exactly the confirmation I was looking for! 

Take care
Henrik 
Reply all
Reply to author
Forward
0 new messages