Skip to content

Mediation analysis with multiple treatment variables #68

@ksgfan

Description

@ksgfan

I want to investigate whether M mediates the relationship of multiple independent variables (X1, X2, X3) on Y. I use the mediation package in R. Is this approach of running 3 mediation analysis with treat = 'X1', treat = 'X2' and treat = 'X3' correct?

fit.totaleffect <- lmer(Y ~ TimePoint + X1 + X2 + X3 + covariate1 + covariate2 + (1 + TimePoint | ID), data = df)
fit.mediator    <- lmer(M ~ TimePoint + X1 + X2 + X3 + covariate1 + covariate2 + (1 + TimePoint | ID), data = df)
fit.dv          <- lmer(Y ~ M + TimePoint + X1 + X2 + X3 + covariate1 + covariate2 + (1 + TimePoint | ID), data = df)

# mediation analysis
results_x1 <- mediation::mediate(fit.mediator, fit.dv, treat='X1', mediator='M', sims = 500)
summary(results_x1)

results_x2 <- mediation::mediate(fit.mediator, fit.dv, treat='X2', mediator='M', sims = 500)
summary(results_x2)

results_x3 <- mediation::mediate(fit.mediator, fit.dv, treat='X3', mediator='M', sims = 500)
summary(results_x3)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions