The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.
messi
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.
If the devtools package is not yet installed, install it first:
install.packages('devtools')
# install the package from Github:
::install_github('umich-cphds/messi') devtools
Once installed, load the package:
library(messi)
For this example, we simulate data and test the cases of null and non-null mediation effect.
library(MASS)
set.seed(20230419)
<- 500
n <- 20
p <- rnorm(n = n, mean = 0, sd = 1)
Y <- mvrnorm(n = n, mu = rep(0, p), Sigma = diag(1, p))
M <- rnorm(n = n, mean = 0, sd = 1)
A <- NULL
C <- "Unconstrained"
method <- NULL
s2.fixed <- NULL
T.hat.external <- NULL
var.T.hat.external
<- messi(Y = Y, M = M, A = A, C = C, method = method, T.hat.external = T.hat.external,
test 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)
<- 500
n <- 20
p <- rnorm(n = n, mean = 0, sd = 1)
Y <- mvrnorm(n = n, mu = rep(0, p), Sigma = diag(1, p))
M <- rnorm(n = n, mean = 0, sd = 1)
A <- NULL
C <- "Hard"
method <- NULL
s2.fixed <- 0
T.hat.external <- NULL
var.T.hat.external
<- messi(Y = Y, M = M, A = A, C = C, method = method, T.hat.external = T.hat.external,
test 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)
<- 500
n <- 20
p <- rnorm(n = n, mean = 0, sd = 1)
Y <- mvrnorm(n = n, mu = rep(0, p), Sigma = diag(1, p))
M <- rnorm(n = n, mean = 0, sd = 1)
A <- NULL
C <- "Soft EB"
method <- NULL
s2.fixed <- 0
T.hat.external <- 0.2
var.T.hat.external
<- messi(Y = Y, M = M, A = A, C = C, method = method, T.hat.external = T.hat.external,
test 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)
<- 500
n <- 20
p <- rnorm(n = n, mean = 0, sd = 1)
Y <- mvrnorm(n = n, mu = rep(0, p), Sigma = diag(1, p))
M <- rnorm(n = n, mean = 0, sd = 1)
A <- NULL
C <- "Soft Fixed"
method <- 1
s2.fixed <- 0
T.hat.external <- 0.2
var.T.hat.external
<- messi(Y = Y, M = M, A = A, C = C, method = method, T.hat.external = T.hat.external,
test 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)
data(Med)
= Med$Y
Y = Med$M
M = Med$A
A = Med$C
C = Med$T.hat.external
T.hat.external = Med$var.T.hat.external
var.T.hat.external
<- messi(Y = Y, M = M, A = A, C = C, method = 'Unconstrained', T.hat.external = T.hat.external,
test var.T.hat.external = var.T.hat.external, s2.fixed = NULL)
= Med$n
n = Med$p
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)
<- messi(Y = Y, M = M, A = A, C = C, method = 'Hard', T.hat.external = T.hat.external,
test var.T.hat.external = var.T.hat.external, s2.fixed = NULL)
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.