# The equation of the direct effect

39 views

### Min-Jeong Yang

Jul 13, 2018, 11:00:55 AM7/13/18
to lavaan
Hi everyone,

I have been running mediation models with latent variables and I came up with a question: the equation of the direct effect from the tutorial seems reflecting rather total effect but not the direct effect. I wonder if I am missing anything. Please see below.

In the tutorial (http://lavaan.ugent.be/tutorial/mediation.html), the equation of the direct effect reads like below:
``````model <- ' # direct effect
Y ~ c*X
# mediator
M ~ a*X
Y ~ b*M
# indirect effect (a*b)
ab := a*b
# total effect
total := c + (a*b)``````

However, in my understanding of mediation, the equation of the direct effect would rather read like below (i.e., adding the term b*M):
````model <- ' # ``MY```` direct effect
Y ~ c*X + ````b*M````
# mediator
M ~ a*X
Y ~ b*M
# indirect effect (a*b)
ab := a*b
# total effect
total := c + (a*b)``````

Could anyone let me know if there's anything I am missing? Any comments would be much appreciated. Thank you!

MJ

### Christopher David Desjardins

Jul 13, 2018, 12:38:22 PM7/13/18
Your model won't run and will error because you have that second Y ~ b*M line.

Did you mean do this? If so, they are equivalent.

library("lavaan")
set.seed(1234)
X <- rnorm(100)
M <- 0.5*X + rnorm(100)
Y <- 0.7*M + rnorm(100)
Data <- data.frame(X = X, Y = Y, M = M)

# tutorial model
model1 <- '

# direct effect
Y ~ c*X
# mediator
M ~ a*X
Y ~ b*M
# indirect effect (a*b)
ab := a*b
# total effect
total := c + (a*b)
'
fit1 <- sem(model1, data = Data)
fit1.PE <- parameterEstimates(fit1)

model2 <- '
# my direct effect

Y ~ c*X + b*M
# mediator
M ~ a*X
# Y ~ b*M # NOTE I commented this line out
# indirect effect (a*b)
ab := a*b
# total effect
total := c + (a*b)
'
fit2 <- sem(model2, data = Data)
fit2.PE <- parameterEstimates(fit2)

# identical
fit1.PE[fit1.PE\$label == "c", ]
fit2.PE[fit2.PE\$label == "c", ]

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to lav...@googlegroups.com.

--

### MJ

Jul 13, 2018, 12:59:43 PM7/13/18
to lavaan
Thank you so much for your quick response! That makes sense to remove the Y<-b*M while keeping Y <-b*M + c*X, where c refers to direct effect. I guess the tutorial needs some edits as the current equation of the "direct effect" in the tutorial actually reflects total effect.

Hope you have a nice weekend!

MJ
To unsubscribe from this group and stop receiving emails from it, send an email to lavaan+un...@googlegroups.com.

To post to this group, send email to lav...@googlegroups.com.

### Christopher David Desjardins

Jul 13, 2018, 1:11:25 PM7/13/18
Hi again,

The tutorial is correct because

Y ~ c*X + b*M

and

Y ~ c*X
Y ~ b*M

are equivalent syntax.

c is estimated the same way in both models and is the direct effect.

To unsubscribe from this group and stop receiving emails from it, send an email to lavaan+unsubscribe@googlegroups.com.

To post to this group, send email to lav...@googlegroups.com.

### Christopher David Desjardins

Jul 13, 2018, 1:15:01 PM7/13/18
and the total effect is c + (a * b) as it's listed in the tutorial
Message has been deleted
Message has been deleted