-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Bayesian meta-analysis model #9
Labels
v2
On hold until first version is done
Comments
Thanks @LukasRoeseler for providing some initial code to integrate this. However, at present, the calculation is too slow to include it in the model ensemble ... so parking this for now. It might be substantially faster with weakly informative rather than uniform priors ... but I am too unfamiliar with bayesian analysis to propose that. # Bayesian Meta-Analyses --------------------------------------------------
## Installing packages
# install.packages("bayesmeta")
# install.packages("psymetadata")
# install.packages("RoBMA")
# devtools::install_github("fbartos/RoBMA")
library(psymetadata)
library(RoBMA)
library(bayesmeta)
## NOTES
# JAGS is required: https://sourceforge.net/projects/mcmc-jags/
# both analyses currently work for simple structures, only (1 effect per study)
ds <- psymetadata::aksayli2019
ds <- ds[1:50, ]
# Fitting the standard RoBMA model ----------------------------------------
t0 <- Sys.time()
fit <- RoBMA::RoBMA(d = ds$yi
, se = sqrt(ds$vi)
, study_names = ds$test
, seed = 1
, effect_direction = "positive" # this is the default direction and would need to be adapted similarly to the effect size sign p-curve
, silent = FALSE) # Effect size is Hedges's g here
t1 <- Sys.time()
t1-t0 # I stopped this after it had fited 14 models, which took 1.12 hours on my machine
# Fitting standard bayesian model -----------------------------------------
t0 <- Sys.time()
bm <- bayesmeta::bayesmeta(y = ds$yi
, sigma = sqrt(ds$vi)
, label = ds$test
, tau.prior = "uniform", mu.prior = c("mean" = NA, "sd" = NA) # options to modify priors (more available)
)
t1 <- Sys.time()
t1-t0 # this took >11 minutes (cancelled for whole dataset with k = 637) and 1.23 for only 50 effects
# Values for plotting
# model, es, lcl, ucl, k
bm
forestplot::forestplot(bm)
print(bm)
## Code to facilitate integration in the App
estimates_explo_agg <- data.frame("Model" = as.character(), "g" = as.numeric(), "LCL" = as.numeric(), "UCL" = as.numeric(), "k" = as.numeric()
, stringsAsFactors = FALSE)
estimates_explo_agg[nrow(estimates_explo_agg)+1,] <- c("Bayesian Random-Effects"
, bm$summary["mean", "mu"]
, bm$summary["95% lower", "mu"]
, bm$summary["95% upper", "mu"]
, bm$k)
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can take inspiration - but not code directly from https://github.com/neuromadlab/taVNSHRVmeta
The text was updated successfully, but these errors were encountered: