mediation icon indicating copy to clipboard operation
mediation copied to clipboard

test.TMint for mixed effects models

Open anthonycrane opened this issue 1 year ago • 0 comments

https://github.com/kosukeimai/mediation/blob/a9a5c7b747b1d96d9a6df7b7cfe3d7719a1b0780/R/medtests.R#L78-L84

Hello,

I am performing a mediation analysis with mixed models in the presence of a (potential) treatment * mediator interaction. I would like to test if this interaction is significant. Is there anything wrong with using the same logic in this code to preform this test? My model.m and model.y that I provide to the mediate function are both lmer objects, and test.TMint says that it is not implemented for these models quite yet.

So my question is, is there anything theoretically wrong with this:

mod.m <- lmer(M ~ X + (1|id), data = data) mod.y <- lmer(Y ~ M * X + (1|id), data = data)

med.results <- mediate(mod.m, mod.y, mediator = "M", treat = "X" )

acme_diff = med.results$d1.sims - med.results$d0.sims

quantile(acme_diff, probs = c(0.025, 0.975))

anthonycrane avatar Oct 30 '23 20:10 anthonycrane