MyNixOS website logo
Description

Utility Functions for Multilevel Mediation Analysis.

The ultimate goal is to support 2-2-1, 2-1-1, and 1-1-1 models for multilevel mediation, the option of a moderating variable for either the a, b, or both paths, and covariates. Currently the 1-1-1 model is supported and several options of random effects; the initial code for bootstrapping was evaluated in simulations by Falk, Vogel, Hammami, and Miočević (2024) <doi:10.3758/s13428-023-02079-4>. Support for Bayesian estimation using 'brms' comprises ongoing work. Currently only continuous mediators and outcomes are supported. Factors for any predictors must be numerically represented.

multilevelmediation

Overview

multilevelmediation contains functions for computing indirect effects with multilevel models and obtaining confidence intervals for various effects using bootstrapping. The ultimate goal is to support 2-2-1, 2-1-1, and 1-1-1 models, the option of a moderating variable at level 1 or level 2 for either the a, b, or both paths. Currently the 1-1-1 model is supported and several options of random effects are supported; the underlying initial code has been evaluated in simulations (see Falk et al in references). Support for Bayesian estimation and the inclusion of covariates comprises ongoing work. Currently only continuous mediators and outcomes are supported. Factors (e.g., for X) must be numerically represented.

Installation

# From GitHub:
# install.packages("devtools")
devtools::install_github("falkcarl/multilevelmediation")

Some relevant references

Bauer, D. J., Preacher, K. J., & Gil, K. M. (2006). Conceptualizing and testing random indirect effects and moderated mediation in multilevel models: New procedures and recommendations. Psychological Methods, 11(2), 142–163. https://doi.org/10.1037/1082-989X.11.2.142

Carpenter, J. R., Goldstein, H., & Rasbash, J. (2003). A novel bootstrap procedure for assessing the relationship between class size and achievement. Applied Statistics, 52(4), 431-443.

Falk, C. F., Vogel, T., Hammami, S., & Miočević, M. (in press). Multilevel mediation analysis in R: A comparison of bootstrap and Bayesian approaches. Behavior Research Methods. doi: https://doi.org/10.3758/s13428-023-02079-4 Preprint: https://doi.org/10.31234/osf.io/ync34

Hox, J., & van de Schoot, R. (2013). Robust methods for multilevel analysis. In M. A. Scott, J. S. Simonoff & B. D. Marx (Eds.), The SAGE Handbook of Multilevel Modeling (pp. 387-402). SAGE Publications Ltd. doi: 10.4135/9781446247600.n22

Krull, J. L., & MacKinnon, D. P. (2001). Multilevel modeling of individual and group level mediated effects. Multivariate behavioral research, 36(2), 249-277. doi: 10.1207/S15327906MBR3602_06

van der Leeden, R., Meijer, E., & Busing, F. M. T. A. (2008). Resampling multilevel models. In J. de Leeuw & E. Meijer (Eds.), Handbook of Multilevel Analysis (pp. 401-433). Springer.

FAQ

  • How to handle missing data?
    • Missing data handling of the sort that lme (the function from the nlme package that fits the models) supports is available. Pass an argument (to modmed.mlm or any of the bootstrapping functions) for na.action that will be passed down to the lme function. For example, na.action = na.omit.
  • Where is support for Bayesian estimation?
    • There is a branch started for use with the brms package. When it is finished an update shall be posted.
  • I receive an error message with a tibble as input
    • Try converting the data to a data frame. Support to automatically do this may eventually be forthcoming, but it should be easy for the end user to do this.

Updates

  • Version 0.3.1
    • Random number seed for boot.modmed.mlm.custom is not set by default (it's NULL).
    • Update to docs.
  • Version 0.3.0
    • Merged branch for brms into master. This means that some support for brms is provided. Covariates with brms are not yet supported and that code could use some more testing. Also protect against possible bug for boot.modmed.mlm.custom.
  • Version 0.2.1
    • Update to docs so that variables in restacked data are hopefully clearer.
    • Support for arbitrary function applied to data after restacking and prior to model fitting in modmed.mlm. Could support additional centering and/or missing data handling.
  • Version 0.2.0
    • boot.modmed.mlm.custom introduced as a new function to unify all case bootstrapping and residual bootstrapping methods into one function and obtain further gains in speed. This reduces reliance on the boot package and appears to be a bit faster. Testing is still in progress, though this function may soon replace boot.modmed.mlm.
    • Update so that missing data can be used with modmed.mlm and boot.modmed.mlm. Pass an argument for na.action that will be passed down to the lme function. For example, na.action = na.omit.
Metadata

Version

0.3.1

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows