4,267 views

Skip to first unread message

Aug 18, 2018, 12:41:38 PM8/18/18

to lavaan

Dear all,

I am relatively new to the Lavaan package and I was wondering how I could carry out a simple mediation analysis with and without covariates.

The first scenario (simple mediation without covariates. This is similar to the example given on the Lavaan website; http://lavaan.ugent.be/tutorial/mediation.html)

My outcome (Y) is binary

My mediator (M) is binary

My predictor (X) is continuous

From what I understand from the lavaan website I can use binary exogenous categorical variables as 0/1 coding. This coding should be done for both M and Y (treat them as numeric variables).

However my M, depending on the path (see below), is both exogenous (Y ~ b*M) and endogenous (M ~ a*X). Should I declare my M as ordered??

```
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)
'
fit <- sem(model, data = Data)
summary(model, fit.measures=TRUE, rsquare=TRUE, standardized=TRUE)
```

In my first attempt I decided to leave the M as numeric (not ordered). Is my above reasoning sound for carrying out a simple mediation with a binary outcome and binary mediator?

In my second scenario I would like to extend the model by adding covariates (Sex and SES). I would like to control for Sex and Age in the entire analysis.

```
model_2 <- ' # direct effect
Y ~ c*X + Sex + SES
# mediator
M ~ a*X + Sex + SES
Y ~ b*M
# indirect effect (a*b)
ab := a*b
# total effect
total := c + (a*b)
'
fit <- sem(model_2, data = Data)
summary(model_2, fit.measures=TRUE, rsquare=TRUE, standardized=TRUE)
```

Am I correct to specify the model as above? Thank you in advance.

Andy

Aug 18, 2018, 3:30:04 PM8/18/18

to lavaan

Am I correct to specify the model as above?

Yes. Make sure M and Y are recognized as binary/ordered, if they are not stored that way in Data.

`sem(..., ordered = c("M","Y"), ...)`

Terrence D. Jorgensen

Postdoctoral Researcher, Methods and Statistics

Research Institute for Child Development and Education, the University of Amsterdam

UvA web page: http://www.uva.nl/profile/t.d.jorgensen

Sep 25, 2018, 6:36:37 AM9/25/18

to lavaan

Dear Terrence,

Mo

Op zaterdag 18 augustus 2018 21:30:04 UTC+2 schreef Terrence Jorgensen:

Do you know if the decomposition into direct and indirect would be accurate given that either the mediator and or the outcome is binary?

Kind regards,

Mo

Op zaterdag 18 augustus 2018 21:30:04 UTC+2 schreef Terrence Jorgensen:

Sep 25, 2018, 7:10:01 AM9/25/18

to lavaan

Do you know if the decomposition into direct and indirect would be accurate given that either the mediator and or the outcome is binary?

Categorical outcomes are handled by assuming they have an underlying latent normally distributed response, which is how the effects are interpreted. So the decomposition works the same way, but is interpreted relative to the latent responses, not observed discrete responses. But this is an empirical question that you could answer yourself by fitting mediation models and direct-effect-only models to see if the numbers add up.

Terrence D. Jorgensen

Postdoctoral Researcher, Methods and Statistics

Research Institute for Child Development and Education, the University of Amsterdam

Sep 26, 2018, 4:54:22 AM9/26/18

to lavaan

Dear all,

I have a similar problem and I am not sure whether my code to run a multiple mediation analysis works.

I do not get any output when running it so apparently it does not work.

Here my code and variables:

I have 5 mediators (PE, EE, SI, HM and FC), 1 outcome variable (BI), three predictors (CarUse, PublicTransportUse, TechAcceptance)

mod.PE <-' PE =~ V2_PE1 + V2_PE2 + V2_PE3

EE =~ V2_EE1 + V2_EE2 + V2_EE3

SI =~ V2_SI1 + V2_SI2 + V2_SI3

BI =~ V2_BI1 + V2_BI2 + V2_BI3

HM =~ V2_HM1 + V2_HM2 + V2_HM3

FC =~ V2_FC1 + V2_FC2 + V2_FC3

BI ~ b1 * PE + b2 * EE + b3 * SI + b4 * FC + b5 * HM + c1 * CarUse + c2 * PublicTransportUse + c3 * TechAcceptance PE ~ a1 * CarUse + a1 * PublicTransportUse + a1 * TechAcceptance EE ~ a2 * CarUse + a2 * PublicTransportUse + a2 * TechAcceptance SI ~ a3 * CarUse + a3 * PublicTransportUse + a3 * TechAcceptance FC ~ a4 * CarUse + a4 * PublicTransportUse + a4 * TechAcceptance HM ~ a5 * CarUse + a5 * PublicTransportUse + a5 * TechAcceptance

indirect1 := a1 * b1

indirect2 := a2 * b2

indirect3 := a3 * b3

indirect4 := a4 * b4

indirect5 := a5 * b5

total := CarUse + (a1 * b1) + (a2 * b2) + (a3 * b3) + (a4 * b4) + (a5 * b5) + PublicTransportUse + (a1 * b1) + (a2 * b2) + (a3 * b3) + (a4 * b4) + (a5 * b5) + TechAcceptance + (a1 * b1) + (a2 * b2) + (a3 * b3) + (a4 * b4) + (a5 * b5)

PE ~~ EE

PE ~~ SI

PE ~~ FC

PE ~~ HM

EE ~~ SI

EE ~~ FC

EE ~~ HM

SI ~~ FC

SI ~~ HM

FC ~~ HM’

fit.PE <- sem(model = mod.PE, data = Datensatz_neu.sav)

summary(fit)

Many thanks!!!!

Sep 28, 2018, 5:47:01 AM9/28/18

to lavaan

I do not get any output when running it so apparently it does not work.

There do not appear to be line breaks between the regression models for different outcomes:

BI ~ b1 * PE + b2 * EE + b3 * SI + b4 * FC + b5 * HM + c1 * CarUse + c2 * PublicTransportUse + c3 * TechAcceptance PE ~ a1 * CarUse + a1 * PublicTransportUse + a1 * TechAcceptance EE ~ a2 * CarUse + a2 * PublicTransportUse + a2 * TechAcceptance SI ~ a3 * CarUse + a3 * PublicTransportUse + a3 * TechAcceptance FC ~ a4 * CarUse + a4 * PublicTransportUse + a4 * TechAcceptance HM ~ a5 * CarUse + a5 * PublicTransportUse + a5 * TechAcceptance

Sep 28, 2018, 8:33:19 AM9/28/18

to lavaan

Dear Terrence,

Thank you for taking the time to answer my question. I don't completely follow your explanation; apologies I am new to structural equation modeling and mediation analysis. If I understand correctly, in a case where we have a continuous exposure, continuous mediator, and a binary outcome Lavaan treats all variables the same and therefore the coefficients are multiplied to derive the indirect effect?

I have been reading up on the topic and found a guide by Nathaniel Herr that deals with the exact problem (when the either the mediator or the outcome is binary): http://www.nrhpsych.com/mediation/logmed.html and is also described in the paper by Mackinnon & Dwyer, 1993 (http://journals.sagepub.com/doi/abs/10.1177/0193841X9301700202). It seems that standardizing of the coefficients is required to estimate the indirect effect. I have applied this method and found similar estimates compared to the ones that Lavaan was giving. I am guessing at this point that Lavaan "correctly" handles a situation when either the mediator or the outcome is binary?

Kind regards,

Mo

Oct 11, 2018, 5:25:41 AM10/11/18

to lavaan

I don't completely follow your explanation

Put your regression equations on separate lines in the syntax

BI ~ b1 * PE + b2 * EE + b3 * SI + b4 * FC + b5 * HM + c1 * CarUse + c2 * PublicTransportUse + c3 * TechAcceptancePE ~ a1 * CarUse + a1 * PublicTransportUse + a1 * TechAcceptanceEE ~ a2 * CarUse + a2 * PublicTransportUse + a2 * TechAcceptanceSI ~ a3 * CarUse + a3 * PublicTransportUse + a3 * TechAcceptanceFC ~ a4 * CarUse + a4 * PublicTransportUse + a4 * TechAcceptanceHM ~ a5 * CarUse + a5 * PublicTransportUse + a5 * TechAcceptance

Reply all

Reply to author

Forward

0 new messages

Search

Clear search

Close search

Google apps

Main menu