View source: R/mvmr_ivw_rjags.R
mvmr_ivw_rjags | R Documentation |
Bayesian multivariate inverse variance weighted model with a choice of prior distributions fitted using JAGS.
mvmr_ivw_rjags(
object,
prior = "default",
betaprior = "",
n.chains = 3,
n.burn = 1000,
n.iter = 5000,
seed = NULL,
...
)
object |
A data object of class |
prior |
A character string for selecting the prior distributions;
|
betaprior |
A character string in JAGS syntax to allow a user defined prior for the causal effect. |
n.chains |
Numeric indicating the number of chains used in the MCMC estimation, the default is |
n.burn |
Numeric indicating the burn-in period of the Bayesian MCMC estimation. The default is |
n.iter |
Numeric indicating the number of iterations in the Bayesian MCMC estimation. The default is |
seed |
Numeric indicating the random number seed. The default is the rjags default. |
... |
Additional arguments passed through to |
An object of class mvivwjags
containing the following components:
The mean of the simulated causal effects
Standard deviation of the simulated causal effects
The credible interval for the causal effect, which indicates the lower (2.5%), median (50%) and upper intervals (97.5%)
Output of the Bayesian MCMC samples with the different chains
The specified priors
Burgess, S., Butterworth, A., Thompson S.G. Mendelian randomization analysis with multiple genetic variants using summarized data. Genetic Epidemiology, 2013, 37, 7, 658-665 \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1002/gepi.21758")}.
if (requireNamespace("rjags", quietly = TRUE)) {
dat <- mvmr_format(
rsid = dodata$rsid,
xbeta = cbind(dodata$ldlcbeta,dodata$hdlcbeta,dodata$tgbeta),
ybeta = dodata$chdbeta,
xse = cbind(dodata$ldlcse,dodata$hdlcse,dodata$tgse),
yse = dodata$chdse
)
fit <- mvmr_ivw_rjags(dat)
print(fit)
summary(fit)
plot(fit$samples)
# 90% credible interval
fitdf <- do.call(rbind.data.frame, fit$samples)
cri90 <- sapply(fitdf, quantile, probs = c(0.05, 0.95))
print(cri90)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.