Type: | Package |
Title: | Bayesian Summary Data Models for Mendelian Randomization Studies |
Version: | 0.5.2 |
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. |
License: | GPL-3 |
URL: | https://github.com/okezie94/mrbayes, https://okezie94.github.io/mrbayes/, https://mrcieu.r-universe.dev/mrbayes |
BugReports: | https://github.com/okezie94/mrbayes/issues |
Depends: | R (≥ 3.6.0) |
Imports: | DescTools, methods, Rcpp (≥ 0.12.0), RcppParallel (≥ 5.0.1), rstan (≥ 2.18.1), rstantools (≥ 2.4.0) |
Suggests: | MendelianRandomization, rjags (≥ 4-9), testthat |
LinkingTo: | BH (≥ 1.66.0), Rcpp (≥ 0.12.0), RcppEigen (≥ 0.3.3.3.0), RcppParallel (≥ 5.0.1), rstan (≥ 2.18.1), StanHeaders (≥ 2.18.0) |
Biarch: | true |
Encoding: | UTF-8 |
LazyData: | true |
RoxygenNote: | 7.3.2 |
SystemRequirements: | GNU make |
NeedsCompilation: | yes |
Packaged: | 2024-08-19 09:51:21 UTC; eptmp |
Author: | Okezie Uche-Ikonne
|
Maintainer: | Tom Palmer <remlapmot@hotmail.com> |
Repository: | CRAN |
Date/Publication: | 2024-08-19 11:50:02 UTC |
mrbayes: Bayesian implementation of the IVW and MR-Egger models for two-sample Mendelian randomization analyses
Description
Bayesian implementation of the IVW and MR-Egger models and their radial and multivariate versions for two-sample Mendelian randomization analyses.
Author(s)
Maintainer: Tom Palmer remlapmot@hotmail.com (ORCID)
Authors:
Okezie Uche-Ikonne okezieikonne@gmail.com (ORCID)
Frank Dondelinger f.dondelinger@lancaster.ac.uk (ORCID)
References
Stan Development Team (2019). RStan: the R interface to Stan. R package version 2.19.2. https://mc-stan.org
See Also
Useful links:
Report bugs at https://github.com/okezie94/mrbayes/issues
Dataset from Richmond et. al 2017 investigating the association of BMI on insulin resistance
Description
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.
Usage
bmi_insulin
Format
A data frame with 14 rows and 44 columns:
- rsid
SNP RSID number
- beta.exposure
The genotype-BMI associations
- beta.outcome
The genotype-outcome associations
- se.exposure
The standard errors of the genotype-phenotype associations
- se.outcome
The standard errors of the genotype-outcome associations
Details
bmi_insulin.
References
Richmond, R. et al., Investigating the role of insulin in increased adiposity: Bi-directional Mendelian randomization study. bioRxiv, 2017, doi:10.1101/155739.
Dataset from Do et al., Nat Gen, 2013 containing summary level data on associations of genotypes with lipid traits and the risk of coronary heart diseases
Description
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.
Usage
dodata
Format
A data frame with 185 rows and 21 columns with the following variables:
- rsid
RSID number
- a1
Allele 1
- a2
Allele 2
- chr
Chromosome
- pos
Genomic position
- ldlcbeta
The genotype-low-density lipoprotein cholestrol associations
- hdlcbeta
The genotype-high-density lipoprotein cholestrol associations
- tgbeta
The genotype-triglyceride associations
- chdbeta
The genotype-coronary heart disease associations, on the log odds ratio scale
- ldlcp2
P-value for genotype-LDL-C associations
- hdlcp2
P-value for genotype-HDL-C associations
- tgp2
P-value for genotype-triglyceride associations
- chdp2
P-value for genotype-coronary heart disease associations
- ldlcz
Z-score for genotype-LDL-C associations
- ldlcse
The standard errors of the genotype-low-density lipoprotein cholestrol associations
- hdlcz
Z-score for genotype-HDL-C associations
- hdlcse
The standard errors of the genotype-high-density lipoprotein cholestrol associations
- tgz
Z-score for genotype-triglyceride associations
- tgse
The standard errors of the genotype-triglyceride cholestrol associations
- chdz
Z-score for genotype-coronary heart disease associations
- chdse
The standard errors of the genotype-coronary heart disease associations
Details
dodata.
References
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.
Description
Bayesian implementation of the MR-Egger multivariate model with choice of prior distributions fitted using JAGS.
Usage
mr_egger_rjags(
object,
prior = "default",
betaprior = "",
sigmaprior = "",
n.chains = 3,
n.burn = 1000,
n.iter = 5000,
seed = NULL,
rho = 0.5,
...
)
Arguments
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 |
Value
An object of class eggerjags
containing the following components:
- AvgPleio
The mean of the simulated pleiotropic effect
- CausalEffect
The mean of the simulated causal effect
- StandardError
Standard deviation of the simulated causal effect
- sigma
The value of the residual standard deviation
- CredibleInterval
The credible interval for the causal effect, which includes the lower (2.5%), median (50%) and upper intervals (97.5%)
- samples
Output of the Bayesian MCMC samples
- Priors
The specified priors
References
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
Examples
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
Description
Bayesian inverse variance weighted model with a choice of prior distributions fitted using Stan.
Usage
mr_egger_stan(
data,
prior = 1,
n.chains = 3,
n.burn = 1000,
n.iter = 5000,
seed = 12345,
rho = 0.5,
...
)
Arguments
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 |
Value
An object of class rstan::stanfit
.
References
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/.
Examples
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
Description
Organises the summary level data for use in the Bayesian MR functions
Usage
mr_format(rsid, xbeta, ybeta, xse, yse)
Arguments
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 |
Value
A formatted data frame for analysis of class mr_format
.
Examples
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.
Description
Bayesian inverse variance weighted model with a choice of prior distributions fitted using JAGS.
Usage
mr_ivw_rjags(
object,
prior = "default",
betaprior = "",
n.chains = 3,
n.burn = 1000,
n.iter = 5000,
seed = NULL,
...
)
Arguments
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 |
Value
An object of class ivwjags
containing the following components:
- CausalEffect
The mean of the simulated causal effects
- StandardError
Standard deviation of the simulated causal effects
- CredibleInterval
The credible interval for the causal effect, which indicates the lower (2.5%), median (50%) and upper intervals (97.5%)
- samples
Output of the Bayesian MCMC samples with the different chains
- Priors
The specified priors
References
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.
Examples
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.
Description
Bayesian inverse variance weighted model with a choice of prior distributions fitted using RStan.
Usage
mr_ivw_stan(
data,
prior = 1,
n.chains = 3,
n.burn = 1000,
n.iter = 5000,
seed = 12345,
...
)
Arguments
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 |
Value
An object of class rstan::stanfit
.
References
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/.
Examples
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.
Description
Bayesian radial MR-Egger model with a choice of prior distributions fitted using JAGS.
Usage
mr_radialegger_rjags(
object,
prior = "default",
betaprior = "",
sigmaprior = "",
n.chains = 3,
n.burn = 1000,
n.iter = 5000,
seed = NULL,
rho = 0.5,
...
)
Arguments
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 |
Value
An object of class radialeggerjags
containing the following components:
- AvgPleio
The mean of the simulated pleiotropic effect
- CausalEffect
The mean of the simulated causal effect
- StandardError
Standard deviation of the simulated causal effect
- sigma
The mean of the simaulted residual standard deviation
- CredibleInterval
The credible interval for the causal effect, which includes the lower (2.5%), median (50%) and upper intervals (97.5%)
- samples
Output of the Bayesian MCMC samples
- Prior
The specified priors
References
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.
Examples
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.
Description
Bayesian inverse variance weighted model with a choice of prior distributions fitted using RStan
Usage
mr_radialegger_stan(
data,
prior = 1,
n.chains = 3,
n.burn = 1000,
n.iter = 5000,
rho = 0.5,
seed = 12345,
...
)
Arguments
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 |
Value
An object of class rstan::stanfit
.
References
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/.
Examples
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)
}
Convert an object of class MRInput from the MendelianRandomization package to the mrbayes mr_format class
Description
Creates a data.frame with class mr_format
from an object of class MRInput
generated by MendelianRandomization::mr_input
.
Usage
mrinput_mr_format(dat)
Arguments
dat |
Object from |
Value
Object of class mr_format
, the mrbayes format
Examples
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.
Description
Bayesian implementation of the MVMR-Egger model with choice of prior distributions fitted using JAGS.
Usage
mvmr_egger_rjags(
object,
prior = "default",
betaprior = "",
sigmaprior = "",
orientate = 1,
n.chains = 3,
n.burn = 1000,
n.iter = 5000,
seed = NULL,
rho = 0.5,
...
)
Arguments
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 |
Value
An object of class mveggerjags
containing the following components:
- AvgPleio
The mean of the simulated pleiotropic effect
- CausalEffect
The mean of the simulated causal effect
- StandardError
Standard deviation of the simulated causal effect
- sigma
The value of the residual standard deviation
- CredibleInterval
The credible interval for the causal effect, which includes the lower (2.5%), median (50%) and upper intervals (97.5%)
- samples
Output of the Bayesian MCMC samples
- Priors
The specified priors
References
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
Examples
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.
Description
Bayesian implementation of the MVMR-Egger model with choice of prior distributions fitted using RStan.
Usage
mvmr_egger_stan(
data,
prior = 1,
n.chains = 3,
n.burn = 1000,
n.iter = 5000,
seed = 12345,
rho = 0.5,
orientate = 1,
...
)
Arguments
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 |
Value
An object of class rstan::stanfit
.
References
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/.
Examples
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
Description
Organises the summary level data for use in the Bayesian MR functions
Usage
mvmr_format(rsid, xbeta, ybeta, xse, yse)
Arguments
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 |
Value
A formatted data frame for analysis of class mvmr_format
.
Examples
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.
Description
Bayesian multivariate inverse variance weighted model with a choice of prior distributions fitted using JAGS.
Usage
mvmr_ivw_rjags(
object,
prior = "default",
betaprior = "",
n.chains = 3,
n.burn = 1000,
n.iter = 5000,
seed = NULL,
...
)
Arguments
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 |
Value
An object of class mvivwjags
containing the following components:
- CausalEffect
The mean of the simulated causal effects
- StandardError
Standard deviation of the simulated causal effects
- CredibleInterval
The credible interval for the causal effect, which indicates the lower (2.5%), median (50%) and upper intervals (97.5%)
- samples
Output of the Bayesian MCMC samples with the different chains
- Priors
The specified priors
References
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.
Examples
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.
Description
Bayesian multivariate inverse variance weighted model with a choice of prior distributions fitted using RStan.
Usage
mvmr_ivw_stan(
data,
prior = 1,
n.chains = 3,
n.burn = 1000,
n.iter = 5000,
seed = 12345,
...
)
Arguments
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 |
Value
An object of class rstan::stanfit
.
References
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/.
Examples
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)
}