Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mediation analysis with multiple treatment variables #68

Open
ksgfan opened this issue Jun 27, 2024 · 0 comments
Open

Mediation analysis with multiple treatment variables #68

ksgfan opened this issue Jun 27, 2024 · 0 comments

Comments

@ksgfan
Copy link

ksgfan commented Jun 27, 2024

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant