knitr::opts_chunk$set(echo = TRUE)
library(tidyverse) library(targets) library(multinma)
# set up data dat <- tar_read(mod_dat) %>% filter(outcome == "mood", timepoint == "change_score", study != "creed 2003") %>% select( study, intervention, arm, mean, sd, se, n, type ) %>% mutate( intervention = fct_relevel(intervention, "placebo", "cbt", "cbt and milnacipran") ) %>% arrange(study, intervention) %>% group_by(study) %>% # Does it matter which is designated the treatment reference? mutate(ref = first(arm)) write_rds(dat, "example-smd-dat.rds")
# import example dat dat <- read_rds("example-smd-dat.rds")
dat <- dat %>% mutate(arm = 1:n(), mi = sum(n) - n(), cmi = exp(lgamma(mi/2) - log(sqrt(mi/2)) - lgamma((mi - 1)/2)), sdpool = sqrt(weighted.mean(sd^2, n - 1)), smd = if_else(arm == 1, NA_real_, (mean - first(mean)) / sdpool * cmi), se_smd = if_else(arm == 1, se / sdpool * cmi, sqrt((n + first(n))/(n * first(n)) + smd^2 / (2 * (n + first(n))))))
# set network net <- set_agd_contrast( data = dat, study = study, trt = intervention, y = smd, se = se_smd, sample_size = n, trt_ref = "placebo", trt_class = type ) # network plots fine! plot(net, weight_nodes = TRUE, weight_edges = TRUE, show_trt_class = TRUE) + ggplot2::theme(legend.position = "bottom", legend.box = "vertical") # model is empty? mod <- nma( net, trt_effects = "random" ) mod
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.