standard errors in mediation analysis with binary variables using lavaan

59 views
Skip to first unread message

ccosciar

unread,
May 28, 2020, 9:15:16 AM5/28/20
to lavaan
Hi all, 

I am using lavaan package for mediation analysis considering both exposure and mediator as binary variables. I considererd estimator = DWLS, with "ordered = c(A1, A2)" option as well as robust standard errors (se = "robust"). 

  SEM_model <- "
  A1_bin ~ g1 +  c1 + c2+ c3
  A2_bin ~ a*A1_bin+ g2 + c1 + c2+ c3
  Y ~ b*A1_bin + c*A2_bin + c1 + c2 + c3
fit_model<- lavaan::sem(SEM_model, data = dataset,ordered = c("A1_bin", "A2_bin"), estimator ="DWLS" , se= "robust" )

With these options I am obtaining really high values of the standard errors for the indirect effect (e*c) and with another settings my model does not work at all. I don't know if maybe I have to consider other estimates and estimators for standard errors for binary variables. 

I will appreciate any help!  

Thank you! 

Claudia 

Yves Rosseel

unread,
Jun 1, 2020, 8:30:13 AM6/1/20
to lav...@googlegroups.com
You could use the bootstrap: se = "bootstrap".

Note also that the 'product term' (e*c) is not a good way to assess the
indirect effect when binary variables are involved. See also:

http://www.da.ugent.be/cvs/pages/en/Presentations/Presentation%20Yves%20Rosseel.pdf

Yves.

ccosciar

unread,
Jun 1, 2020, 10:21:28 AM6/1/20
to lavaan
Dear Yves, 

Thank you so much for your reply. 

I followed your suggestions and I got this Lavaan Warning : 

Warning message:
In lavaan::lavaan(model = SEM_model, data = dataset, ordered = c("A2_bin",  :
  lavaan WARNING: not all elements of the gradient are (near) zero;
                  the optimizer may not have found a local solution;
                  use lavInspect(fit, "optim.gradient") to investigate

could you give me some insights on what is happening in my model?

thank you again

Claudia

Yves Rosseel

unread,
Jun 1, 2020, 10:33:23 AM6/1/20
to lav...@googlegroups.com
On 6/1/20 4:21 PM, ccosciar wrote:
> Warning message:
> In lavaan::lavaan(model = SEM_model, data = dataset, ordered =
> c("A2_bin",  :
>   lavaan WARNING: not all elements of the gradient are (near) zero;
>                   the optimizer may not have found a local solution;
>                   use lavInspect(fit, "optim.gradient") to investigate
>
> could you give me some insights on what is happening in my model?

This warning may be harmless, but it also may indicate that your model
truly did not converge.

I can not be sure without seeing the data + script (which you may email
me, if you wish, then I will investigate).

Yves.
Message has been deleted

Ranaivo Rasolofoson

unread,
Jun 1, 2020, 10:42:30 PM6/1/20
to lavaan
Dear Yves,
I was looking at the presentation you shared above. On slide 34, you talked about the bias involve in using the product of coefficients to estimate indirect effect (as shown in Imai 2010). But then you kind of gave a solution. I cannot really grasp the solution you propose. Could you elaborate on that please?
Also could you also describe in plain language the difference between SEM softwares and the "mediation" of Imai et al.
Thank you so much,
Ranaivo

Yves Rosseel

unread,
Jun 2, 2020, 11:10:29 AM6/2/20
to lav...@googlegroups.com
On 6/2/20 4:41 AM, Ranaivo Rasolofoson wrote:
> Dear Yves,
> I was looking at the presentation you shared above. On slide 34, you
> talked about the bias involve in using the product of coefficients to
> estimate indirect effect (as shown in Imai 2010). But then you kind of
> gave a solution. I cannot really grasp the solution you propose. Could
> you elaborate on that please?

Perhaps this paper may help:

Muthén, B. & Asparouhov T. (2015). Causal effects in mediation modeling:
An introduction with applications to latent variables. Structural
Equation Modeling: A Multidisciplinary Journal, 22(1), 12-23.
DOI:10.1080/10705511.2014.935843

(available here: http://www.statmodel.com/Mediation.shtml)

Yves.
Reply all
Reply to author
Forward
0 new messages