MyNixOS website logo
Description

Mediation Analysis with External Summary-Level Information on Total Effect.

Fits the hard constraint, soft constraint, and unconstrained models in Boss et al. (2023) <arXiv:2306.17347> for mediation analyses with external summary-level information on the total effect.

R package messi

Mediation Analysis with External Summary-Level Information on the Total Effect of Exposure

Overview

This R package fits the hard constraint, soft constraint, and unconstrained models in Boss et al. (2023) for mediation analyses with external summary-level information on the total effect.

Installation

If the devtools package is not yet installed, install it first:

install.packages('devtools')
# install the package from Github:
devtools::install_github('umich-cphds/messi') 

Once installed, load the package:

library(messi)

Example Usage

For this example, we simulate data and test the cases of null and non-null mediation effect.

Test case with null mediation effect

library(MASS)
set.seed(20230419)
n <- 500
p <- 20
Y <- rnorm(n = n, mean = 0, sd = 1)
M <- mvrnorm(n = n, mu = rep(0, p), Sigma = diag(1, p))
A <- rnorm(n = n, mean = 0, sd = 1)
C <- NULL
method <- "Unconstrained"
s2.fixed <- NULL
T.hat.external <- NULL
var.T.hat.external <- NULL

test <- messi(Y = Y, M = M, A = A, C = C, method = method, T.hat.external = T.hat.external,
              var.T.hat.external = var.T.hat.external, s2.fixed = s2.fixed)

plot_messi(n = n, alpha.a.hat = test$alpha.a.hat, beta.m.hat = test$beta.m.hat, labels = paste0("M",1:p), asym.var.mat = test$asym.var.mat)

set.seed(20230419)
n <- 500
p <- 20
Y <- rnorm(n = n, mean = 0, sd = 1)
M <- mvrnorm(n = n, mu = rep(0, p), Sigma = diag(1, p))
A <- rnorm(n = n, mean = 0, sd = 1)
C <- NULL
method <- "Hard"
s2.fixed <- NULL
T.hat.external <- 0
var.T.hat.external <- NULL

test <- messi(Y = Y, M = M, A = A, C = C, method = method, T.hat.external = T.hat.external,
              var.T.hat.external = var.T.hat.external, s2.fixed = s2.fixed)

plot_messi(n = n, alpha.a.hat = test$alpha.a.hat, beta.m.hat = test$beta.m.hat, labels = paste0("M",1:p), asym.var.mat = test$asym.var.mat)

set.seed(20230419)
n <- 500
p <- 20
Y <- rnorm(n = n, mean = 0, sd = 1)
M <- mvrnorm(n = n, mu = rep(0, p), Sigma = diag(1, p))
A <- rnorm(n = n, mean = 0, sd = 1)
C <- NULL
method <- "Soft EB"
s2.fixed <- NULL
T.hat.external <- 0
var.T.hat.external <- 0.2

test <- messi(Y = Y, M = M, A = A, C = C, method = method, T.hat.external = T.hat.external,
              var.T.hat.external = var.T.hat.external, s2.fixed = s2.fixed)

plot_messi(n = n, alpha.a.hat = test$alpha.a.hat, beta.m.hat = test$beta.m.hat, labels = paste0("M",1:p), asym.var.mat = test$asym.var.mat)

set.seed(20230419)
n <- 500
p <- 20
Y <- rnorm(n = n, mean = 0, sd = 1)
M <- mvrnorm(n = n, mu = rep(0, p), Sigma = diag(1, p))
A <- rnorm(n = n, mean = 0, sd = 1)
C <- NULL
method <- "Soft Fixed"
s2.fixed <- 1
T.hat.external <- 0
var.T.hat.external <- 0.2

test <- messi(Y = Y, M = M, A = A, C = C, method = method, T.hat.external = T.hat.external,
              var.T.hat.external = var.T.hat.external, s2.fixed = s2.fixed)

plot_messi(n = n, alpha.a.hat = test$alpha.a.hat, beta.m.hat = test$beta.m.hat, labels = paste0("M",1:p), asym.var.mat = test$asym.var.mat)

Test case with non-null mediation effect

data(Med)

Y = Med$Y
M = Med$M
A = Med$A
C = Med$C
T.hat.external = Med$T.hat.external
var.T.hat.external = Med$var.T.hat.external

test <- messi(Y = Y, M = M, A = A, C = C, method = 'Unconstrained', T.hat.external = T.hat.external,
              var.T.hat.external = var.T.hat.external, s2.fixed = NULL)

n = Med$n
p = Med$p

plot_messi(n = n, alpha.a.hat = test$alpha.a.hat, beta.m.hat = test$beta.m.hat, 
           labels = paste0("M",1:p), asym.var.mat = test$asym.var.mat)
              
test <- messi(Y = Y, M = M, A = A, C = C, method = 'Hard', T.hat.external = T.hat.external,
              var.T.hat.external = var.T.hat.external, s2.fixed = NULL)
Metadata

Version

0.1.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