[R-sig-ME] R-sig-mixed-models mailing list submissions: Crossed Random Factors Mediation

b@sii@m@iy m@iii@g oii u@ibe@ch b@sii@m@iy m@iii@g oii u@ibe@ch
Tue Jul 4 15:02:42 CEST 2023


Dear colleagues

I would like to calculate a multilevel mediation using a linear multilevel model with crossed random factors. The code for the model is as follows:

### R-Code:

model <- lmer(outcome ~ condition + rating + (1|id) + (1|stimulusid), data = dat, REML = TRUE)


I am not aware of any mediation package in R that can compute mediation with crossed random factors. Also, Lavaan does not support models with crossed random factors. Therefore, I aimed to implement the indirect effect test with BootMer by myself. I would like to use the semi-parametric bootstrapping. This is my attempt so far:

### R-Code:
function_indirect_effect <- function(x) {
                                                                 fixef(x)[2]*fixef(x)[3]
}

boots <- bootMer(model,
               FUN = function_indirect_effect,
               use.u = FALSE,
type = "parametric",
nsim = 1000)

boots <- bootMer(model,
               FUN = function_indirect_effect,
               use.u = TRUE,
type = "semiparametric",
nsim = 1000)

However, the semi-parametric bootstrapping does not work, and only NAs are produced (�Warning: some bootstrap runs failed (1000/1000)�).
The problem is probably the simulation of the random effects (�use.u = TRUE�), since parametric bootstrapping doesn't work in this case either.


Does anyone have a hint what this could be due to and how I could fix the? Or does anyone know another way/package to compute and test the indirect effect?

Thanks for your time and kind regards,
Basil Maly

	[[alternative HTML version deleted]]



More information about the R-sig-mixed-models mailing list