Title: | Bayesian Summary Data Models for Mendelian Randomization Studies |
---|---|
Description: | Bayesian estimation of inverse variance weighted (IVW), Burgess et al. (2013) <doi:10.1002/gepi.21758>, and MR-Egger, Bowden et al. (2015) <doi:10.1093/ije/dyv080>, summary data models for Mendelian randomization analyses. |
Authors: | Okezie Uche-Ikonne [aut] , Frank Dondelinger [aut] , Tom Palmer [aut, cre] |
Maintainer: | Tom Palmer <[email protected]> |
License: | GPL-3 |
Version: | 0.5.2.9000 |
Built: | 2024-10-26 05:43:01 UTC |
Source: | https://github.com/okezie94/mrbayes |
Bayesian implementation of the IVW and MR-Egger models and their radial and multivariate versions for two-sample Mendelian randomization analyses.
Maintainer: Tom Palmer [email protected] (ORCID)
Authors:
Okezie Uche-Ikonne [email protected] (ORCID)
Frank Dondelinger [email protected] (ORCID)
Stan Development Team (2019). RStan: the R interface to Stan. R package version 2.19.2. https://mc-stan.org
Useful links:
Report bugs at https://github.com/okezie94/mrbayes/issues
A two-sample summary level dataset, Richmond et al. (2017) doi:10.1101/155739, containing 14 single nucleiodtide polymorphisms (SNPs) which have genotype-phenotype associations (BMI) and genotype-outcome associations (insulin) with their respective standard errors.
bmi_insulin
bmi_insulin
A data frame with 14 rows and 44 columns:
SNP RSID number
The genotype-BMI associations
The genotype-outcome associations
The standard errors of the genotype-phenotype associations
The standard errors of the genotype-outcome associations
bmi_insulin.
Richmond, R. et al., Investigating the role of insulin in increased adiposity: Bi-directional Mendelian randomization study. bioRxiv, 2017, doi:10.1101/155739.
A summary-level dataset, from Do et al. (2013) doi:10.1038/ng.2795, containing 185 single nucleodtide polymorphisms (SNPs) which have genotype-phenotype associations and standard errors for LDL-C, HDL-C, Triglycerides, and genotype-outcome associations for coronary heart disease with their respective standard errors.
dodata
dodata
A data frame with 185 rows and 21 columns with the following variables:
RSID number
Allele 1
Allele 2
Chromosome
Genomic position
The genotype-low-density lipoprotein cholestrol associations
The genotype-high-density lipoprotein cholestrol associations
The genotype-triglyceride associations
The genotype-coronary heart disease associations, on the log odds ratio scale
P-value for genotype-LDL-C associations
P-value for genotype-HDL-C associations
P-value for genotype-triglyceride associations
P-value for genotype-coronary heart disease associations
Z-score for genotype-LDL-C associations
The standard errors of the genotype-low-density lipoprotein cholestrol associations
Z-score for genotype-HDL-C associations
The standard errors of the genotype-high-density lipoprotein cholestrol associations
Z-score for genotype-triglyceride associations
The standard errors of the genotype-triglyceride cholestrol associations
Z-score for genotype-coronary heart disease associations
The standard errors of the genotype-coronary heart disease associations
dodata.
Do, R. et al., Common variants associated with plasma triglycerides and risk for coronary artery disease. Nature Genetics, 2013, 45, 1345-1352, doi:10.1038/ng.2795.
Bayesian implementation of the MR-Egger multivariate model with choice of prior distributions fitted using JAGS.
mr_egger_rjags( object, prior = "default", betaprior = "", sigmaprior = "", n.chains = 3, n.burn = 1000, n.iter = 5000, seed = NULL, rho = 0.5, ... )
mr_egger_rjags( object, prior = "default", betaprior = "", sigmaprior = "", n.chains = 3, n.burn = 1000, n.iter = 5000, seed = NULL, rho = 0.5, ... )
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. |
sigmaprior |
A character string in JAGS syntax to allow a user defined prior for the residual standard deviation. |
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. |
rho |
Numeric indicating the correlation coefficient input into the joint prior distribution. The default value is |
... |
Additional arguments passed through to |
An object of class eggerjags
containing the following components:
The mean of the simulated pleiotropic effect
The mean of the simulated causal effect
Standard deviation of the simulated causal effect
The value of the residual standard deviation
The credible interval for the causal effect, which includes the lower (2.5%), median (50%) and upper intervals (97.5%)
Output of the Bayesian MCMC samples
The specified priors
Bowden et. al., Mendelian randomization with invalid instruments: effect estimation and bias detection through Egger regression. International Journal of Epidemiology 2015. 44(2): p. 512-525. doi:10.1093/ije/dyv080
if (requireNamespace("rjags", quietly = TRUE)) { fit <- mr_egger_rjags(bmi_insulin) 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) }
if (requireNamespace("rjags", quietly = TRUE)) { fit <- mr_egger_rjags(bmi_insulin) 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) }
Bayesian inverse variance weighted model with a choice of prior distributions fitted using Stan.
mr_egger_stan( data, prior = 1, n.chains = 3, n.burn = 1000, n.iter = 5000, seed = 12345, rho = 0.5, ... )
mr_egger_stan( data, prior = 1, n.chains = 3, n.burn = 1000, n.iter = 5000, seed = 12345, rho = 0.5, ... )
data |
A data of class |
prior |
An integer for selecting the prior distributions;
|
n.chains |
Numeric indicating the number of chains used in the HMC estimation in rstan, the default is |
n.burn |
Numeric indicating the burn-in period of the Bayesian HMC estimation. The default is |
n.iter |
Numeric indicating the number of iterations in the Bayesian HMC estimation. The default is |
seed |
Numeric indicating the random number seed. The default is |
rho |
Numeric indicating the correlation coefficient input into the joint prior distribution. The default is |
... |
Additional arguments passed through to |
An object of class rstan::stanfit
.
Bowden J, Davey Smith G, Burgess S. Mendelian randomization with invalid instruments: effect estimation and bias detection through Egger regression. International Journal of Epidemiology, 2015, 44, 2, 512-525. doi:10.1093/ije/dyv080.
Stan Development Team (2020). "RStan: the R interface to Stan." R package version 2.19.3, https://mc-stan.org/.
if (requireNamespace("rstan", quietly = TRUE)) { # Note we recommend setting n.burn and n.iter to larger values suppressWarnings(egger_fit <- mr_egger_stan(bmi_insulin, n.burn = 500, n.iter = 1000, refresh = 0L)) print(egger_fit) }
if (requireNamespace("rstan", quietly = TRUE)) { # Note we recommend setting n.burn and n.iter to larger values suppressWarnings(egger_fit <- mr_egger_stan(bmi_insulin, n.burn = 500, n.iter = 1000, refresh = 0L)) print(egger_fit) }
Organises the summary level data for use in the Bayesian MR functions
mr_format(rsid, xbeta, ybeta, xse, yse)
mr_format(rsid, xbeta, ybeta, xse, yse)
rsid |
A vector of genetic variants used for analysis, if unspecified a vector is automatically generated. |
xbeta |
A numeric vector of the instrument-phenotype associations. |
ybeta |
A numeric vector of the instrument-outcome associations. |
xse |
The standard errors of the instrument-phenotype associations |
yse |
The standard errors of the instrument-outcome associations |
A formatted data frame for analysis of class mr_format
.
data(bmi_insulin) dat <- mr_format( rsid = bmi_insulin[,"rsid"], xbeta = bmi_insulin[,"beta.exposure"], ybeta = bmi_insulin[,"beta.outcome"], xse = bmi_insulin[,"se.exposure"], yse = bmi_insulin[,"se.outcome"] ) class(dat)
data(bmi_insulin) dat <- mr_format( rsid = bmi_insulin[,"rsid"], xbeta = bmi_insulin[,"beta.exposure"], ybeta = bmi_insulin[,"beta.outcome"], xse = bmi_insulin[,"se.exposure"], yse = bmi_insulin[,"se.outcome"] ) class(dat)
Bayesian inverse variance weighted model with a choice of prior distributions fitted using JAGS.
mr_ivw_rjags( object, prior = "default", betaprior = "", n.chains = 3, n.burn = 1000, n.iter = 5000, seed = NULL, ... )
mr_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 ivwjags
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 doi:10.1002/gepi.21758.
if (requireNamespace("rjags", quietly = TRUE)) { fit <- mr_ivw_rjags(bmi_insulin) print(fit) summary(fit) plot(fit$samples) # 90% credible interval fitdf <- do.call(rbind.data.frame, fit$samples) cri90 <- quantile(fitdf$Estimate, probs = c(0.05, 0.95)) print(cri90) }
if (requireNamespace("rjags", quietly = TRUE)) { fit <- mr_ivw_rjags(bmi_insulin) print(fit) summary(fit) plot(fit$samples) # 90% credible interval fitdf <- do.call(rbind.data.frame, fit$samples) cri90 <- quantile(fitdf$Estimate, probs = c(0.05, 0.95)) print(cri90) }
Bayesian inverse variance weighted model with a choice of prior distributions fitted using RStan.
mr_ivw_stan( data, prior = 1, n.chains = 3, n.burn = 1000, n.iter = 5000, seed = 12345, ... )
mr_ivw_stan( data, prior = 1, n.chains = 3, n.burn = 1000, n.iter = 5000, seed = 12345, ... )
data |
A data of class |
prior |
An integer for selecting the prior distributions;
|
n.chains |
Numeric indicating the number of chains used in the HMC estimation in rstan, the default is |
n.burn |
Numeric indicating the burn-in period of the Bayesian HMC 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 |
... |
Additional arguments passed through to |
An object of class rstan::stanfit
.
Burgess, S., Butterworth, A., Thompson S.G. Mendelian randomization analysis with multiple genetic variants using summarized data. Genetic Epidemiology, 2013, 37, 7, 658-665 doi:10.1002/gepi.21758.
Stan Development Team (2020). "RStan: the R interface to Stan." R package version 2.19.3, https://mc-stan.org/.
if (requireNamespace("rstan", quietly = TRUE)) { suppressWarnings(ivw_fit <- mr_ivw_stan(bmi_insulin, refresh = 0L)) print(ivw_fit) rstan::traceplot(ivw_fit) }
if (requireNamespace("rstan", quietly = TRUE)) { suppressWarnings(ivw_fit <- mr_ivw_stan(bmi_insulin, refresh = 0L)) print(ivw_fit) rstan::traceplot(ivw_fit) }
Bayesian radial MR-Egger model with a choice of prior distributions fitted using JAGS.
mr_radialegger_rjags( object, prior = "default", betaprior = "", sigmaprior = "", n.chains = 3, n.burn = 1000, n.iter = 5000, seed = NULL, rho = 0.5, ... )
mr_radialegger_rjags( object, prior = "default", betaprior = "", sigmaprior = "", n.chains = 3, n.burn = 1000, n.iter = 5000, seed = NULL, rho = 0.5, ... )
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. |
sigmaprior |
A character string in JAGS syntax to allow a user defined prior for the residual standard deviation. |
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. |
rho |
Numeric indicating the correlation coefficient input into the joint prior distribution. The default is |
... |
Additional arguments passed through to |
An object of class radialeggerjags
containing the following components:
The mean of the simulated pleiotropic effect
The mean of the simulated causal effect
Standard deviation of the simulated causal effect
The mean of the simaulted residual standard deviation
The credible interval for the causal effect, which includes the lower (2.5%), median (50%) and upper intervals (97.5%)
Output of the Bayesian MCMC samples
The specified priors
Bowden, J., et al., Improving the visualization, interpretation and analysis of two-sample summary data Mendelian randomization via the Radial plot and Radial regression. International Journal of Epidemiology, 2018. 47(4): p. 1264-1278. doi:10.1093/ije/dyy101.
if (requireNamespace("rjags", quietly = TRUE)) { fit <- mr_radialegger_rjags(bmi_insulin) summary(fit) plot(fit$samples) # 90% credible interval fitdf <- do.call(rbind.data.frame, fit$samples) cri90 <- quantile(fitdf$Estimate, probs = c(0.05, 0.95)) print(cri90) }
if (requireNamespace("rjags", quietly = TRUE)) { fit <- mr_radialegger_rjags(bmi_insulin) summary(fit) plot(fit$samples) # 90% credible interval fitdf <- do.call(rbind.data.frame, fit$samples) cri90 <- quantile(fitdf$Estimate, probs = c(0.05, 0.95)) print(cri90) }
Bayesian inverse variance weighted model with a choice of prior distributions fitted using RStan
mr_radialegger_stan( data, prior = 1, n.chains = 3, n.burn = 1000, n.iter = 5000, rho = 0.5, seed = 12345, ... )
mr_radialegger_stan( data, prior = 1, n.chains = 3, n.burn = 1000, n.iter = 5000, rho = 0.5, seed = 12345, ... )
data |
A data of class |
prior |
An integer for selecting the prior distributions;
|
n.chains |
Numeric indicating the number of chains used in the HMC estimation in rstan, the default is |
n.burn |
Numeric indicating the burn-in period of the Bayesian HMC estimation. The default is |
n.iter |
Numeric indicating the number of iterations in the Bayesian HMC estimation. The default is |
rho |
Numeric indicating the correlation coefficient input into the joint prior distribution. The default is |
seed |
Numeric indicating the random number seed. The default is |
... |
Additional arguments passed through to |
An object of class rstan::stanfit
.
Bowden, J., et al., Improving the visualization, interpretation and analysis of two-sample summary data Mendelian randomization via the Radial plot and Radial regression. International Journal of Epidemiology, 2018. 47(4): p. 1264-1278. doi:10.1093/ije/dyy101.
Stan Development Team (2020). "RStan: the R interface to Stan." R package version 2.19.3, https://mc-stan.org/.
if (requireNamespace("rstan", quietly = TRUE)) { # Note we recommend setting n.burn and n.iter to larger values suppressWarnings({ radegger_fit <- mr_radialegger_stan(bmi_insulin, n.burn = 500, n.iter = 1000, refresh = 0L) }) print(radegger_fit) }
if (requireNamespace("rstan", quietly = TRUE)) { # Note we recommend setting n.burn and n.iter to larger values suppressWarnings({ radegger_fit <- mr_radialegger_stan(bmi_insulin, n.burn = 500, n.iter = 1000, refresh = 0L) }) print(radegger_fit) }
Creates a data.frame with class mr_format
from an object of class MRInput
generated by MendelianRandomization::mr_input
.
mrinput_mr_format(dat)
mrinput_mr_format(dat)
dat |
Object from |
Object of class mr_format
, the mrbayes format
if (requireNamespace("MendelianRandomization", quietly = TRUE)) { dat <- MendelianRandomization::mr_input( bx = bmi_insulin$beta.exposure, bxse = bmi_insulin$se.exposure, by = bmi_insulin$beta.outcome, byse = bmi_insulin$se.outcome, snps = bmi_insulin$rsid ) dat <- mrinput_mr_format(dat) head(dat) class(dat) }
if (requireNamespace("MendelianRandomization", quietly = TRUE)) { dat <- MendelianRandomization::mr_input( bx = bmi_insulin$beta.exposure, bxse = bmi_insulin$se.exposure, by = bmi_insulin$beta.outcome, byse = bmi_insulin$se.outcome, snps = bmi_insulin$rsid ) dat <- mrinput_mr_format(dat) head(dat) class(dat) }
Bayesian implementation of the MVMR-Egger model with choice of prior distributions fitted using JAGS.
mvmr_egger_rjags( object, prior = "default", betaprior = "", sigmaprior = "", orientate = 1, n.chains = 3, n.burn = 1000, n.iter = 5000, seed = NULL, rho = 0.5, ... )
mvmr_egger_rjags( object, prior = "default", betaprior = "", sigmaprior = "", orientate = 1, n.chains = 3, n.burn = 1000, n.iter = 5000, seed = NULL, rho = 0.5, ... )
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. |
sigmaprior |
A character string in JAGS syntax to allow a user defined prior for the residual standard deviation. |
orientate |
Numeric value to indicate the oriented exposure |
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. |
rho |
Numeric indicating the correlation coefficient input into the joint prior distribution. The default value is |
... |
Additional arguments passed through to |
An object of class mveggerjags
containing the following components:
The mean of the simulated pleiotropic effect
The mean of the simulated causal effect
Standard deviation of the simulated causal effect
The value of the residual standard deviation
The credible interval for the causal effect, which includes the lower (2.5%), median (50%) and upper intervals (97.5%)
Output of the Bayesian MCMC samples
The specified priors
Bowden et. al., Mendelian randomization with invalid instruments: effect estimation and bias detection through Egger regression. International Journal of Epidemiology 2015. 44(2): p. 512-525. doi:10.1093/ije/dyv080
if (requireNamespace("rjags", quietly = TRUE)) { ## Not run: 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_egger_rjags(dat) 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) ## End(Not run) }
if (requireNamespace("rjags", quietly = TRUE)) { ## Not run: 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_egger_rjags(dat) 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) ## End(Not run) }
Bayesian implementation of the MVMR-Egger model with choice of prior distributions fitted using RStan.
mvmr_egger_stan( data, prior = 1, n.chains = 3, n.burn = 1000, n.iter = 5000, seed = 12345, rho = 0.5, orientate = 1, ... )
mvmr_egger_stan( data, prior = 1, n.chains = 3, n.burn = 1000, n.iter = 5000, seed = 12345, rho = 0.5, orientate = 1, ... )
data |
A data of class |
prior |
An integer for selecting the prior distributions;
|
n.chains |
Numeric indicating the number of chains used in the HMC estimation in rstan, the default is |
n.burn |
Numeric indicating the burn-in period of the Bayesian HMC estimation. The default is |
n.iter |
Numeric indicating the number of iterations in the Bayesian HMC estimation. The default is |
seed |
Numeric indicating the random number seed. The default is |
rho |
Numeric indicating the correlation coefficient input into the joint prior distribution. The default is |
orientate |
Numeric value to indicate the oriented exposure. |
... |
Additional arguments passed through to |
An object of class rstan::stanfit
.
Bowden J, Davey Smith G, Burgess S. Mendelian randomization with invalid instruments: effect estimation and bias detection through Egger regression. International Journal of Epidemiology, 2015, 44, 2, 512-525. doi:10.1093/ije/dyv080.
Stan Development Team (2020). "RStan: the R interface to Stan." R package version 2.19.3, https://mc-stan.org/.
if (requireNamespace("rstan", quietly = TRUE)) { # Note we recommend setting n.burn and n.iter to larger values 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 ) suppressWarnings(mvegger_fit <- mvmr_egger_stan(dat, n.burn = 500, n.iter = 1000, refresh = 0L)) print(mvegger_fit) }
if (requireNamespace("rstan", quietly = TRUE)) { # Note we recommend setting n.burn and n.iter to larger values 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 ) suppressWarnings(mvegger_fit <- mvmr_egger_stan(dat, n.burn = 500, n.iter = 1000, refresh = 0L)) print(mvegger_fit) }
Organises the summary level data for use in the Bayesian MR functions
mvmr_format(rsid, xbeta, ybeta, xse, yse)
mvmr_format(rsid, xbeta, ybeta, xse, yse)
rsid |
A vector of genetic variants used for analysis, if unspecified a vector is automatically generated. |
xbeta |
A matrix of multiple instrument-phenotypes associations. |
ybeta |
A numeric vector of the instrument-outcome associations. |
xse |
The matrix for corresponding standard errors of the instrument-phenotypes associations |
yse |
The standard errors of the instrument-outcome associations |
A formatted data frame for analysis of class mvmr_format
.
data(dodata) 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 ) class(dat)
data(dodata) 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 ) class(dat)
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, ... )
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 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) }
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) }
Bayesian multivariate inverse variance weighted model with a choice of prior distributions fitted using RStan.
mvmr_ivw_stan( data, prior = 1, n.chains = 3, n.burn = 1000, n.iter = 5000, seed = 12345, ... )
mvmr_ivw_stan( data, prior = 1, n.chains = 3, n.burn = 1000, n.iter = 5000, seed = 12345, ... )
data |
A data of class |
prior |
An integer for selecting the prior distributions;
|
n.chains |
Numeric indicating the number of chains used in the HMC estimation in rstan, the default is |
n.burn |
Numeric indicating the burn-in period of the Bayesian HMC 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 |
... |
Additional arguments passed through to |
An object of class rstan::stanfit
.
Burgess, S., Butterworth, A., Thompson S.G. Mendelian randomization analysis with multiple genetic variants using summarized data. Genetic Epidemiology, 2013, 37, 7, 658-665 doi:10.1002/gepi.21758.
Stan Development Team (2020). "RStan: the R interface to Stan." R package version 2.19.3, https://mc-stan.org/.
if (requireNamespace("rstan", 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 ) suppressWarnings(mvivw_fit <- mvmr_ivw_stan(dat, refresh = 0L)) print(mvivw_fit) rstan::traceplot(mvivw_fit) }
if (requireNamespace("rstan", 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 ) suppressWarnings(mvivw_fit <- mvmr_ivw_stan(dat, refresh = 0L)) print(mvivw_fit) rstan::traceplot(mvivw_fit) }