R/mvmr_egger_stan.R
mvmr_egger_stan.Rd
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, ... )
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 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/.
# \donttest{ 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) mvegger_fit <- mvmr_egger_stan(dat, n.burn = 500, n.iter = 1000) print(mvegger_fit) }#> Inference for Stan model: mvmregger. #> 3 chains, each with iter=1000; warmup=500; thin=1; #> post-warmup draws per chain=500, total post-warmup draws=1500. #> #> mean se_mean sd 2.5% 25% 50% 75% 97.5% n_eff #> intercept -0.01 0.00 0.00 -0.01 -0.01 -0.01 0.00 0.00 1212 #> estimate[1] 0.53 0.00 0.07 0.38 0.48 0.53 0.58 0.66 825 #> estimate[2] -0.10 0.00 0.06 -0.23 -0.15 -0.10 -0.06 0.02 974 #> estimate[3] 0.33 0.00 0.08 0.16 0.27 0.33 0.38 0.49 936 #> sigma 1.46 0.00 0.08 1.32 1.41 1.46 1.51 1.62 1001 #> lp__ -161.75 0.07 1.61 -165.83 -162.62 -161.42 -160.52 -159.58 558 #> Rhat #> intercept 1.00 #> estimate[1] 1.01 #> estimate[2] 1.00 #> estimate[3] 1.00 #> sigma 1.01 #> lp__ 1.00 #> #> Samples were drawn using NUTS(diag_e) at Thu Oct 7 10:00:39 2021. #> For each parameter, n_eff is a crude measure of effective sample size, #> and Rhat is the potential scale reduction factor on split chains (at #> convergence, Rhat=1).# }