# NOT RUN {
## Smoking cessation
# Set up network of smoking cessation data
head(smoking)
smk_net <- set_agd_arm(smoking,
study = studyn,
trt = trtc,
r = r,
n = n,
trt_ref = "No intervention")
# Print details
smk_net
# }
# NOT RUN {
# Fitting a fixed effect model
smk_fit_FE <- nma(smk_net,
trt_effects = "fixed",
prior_intercept = normal(scale = 100),
prior_trt = normal(scale = 100))
smk_fit_FE
# }
# NOT RUN {
# }
# NOT RUN {
# Fitting a random effects model
smk_fit_RE <- nma(smk_net,
trt_effects = "random",
prior_intercept = normal(scale = 100),
prior_trt = normal(scale = 100),
prior_het = normal(scale = 5))
smk_fit_RE
# }
# NOT RUN {
# }
# NOT RUN {
# Compare DIC of FE and RE models
(smk_dic_FE <- dic(smk_fit_FE))
(smk_dic_RE <- dic(smk_fit_RE)) # substantially better fit
# Plot residual deviance contributions under RE model
plot(smk_dic_RE)
# Changing the plot stat used
plot(smk_dic_RE, stat = "interval", orientation = "horizontal")
# Further customisation is possible using ggplot commands
# For example, highlighting data points with residual deviance above a certain threshold
plot(smk_dic_RE) +
ggplot2::aes(colour = ifelse(..y.. > 1.5, "darkorange", "black")) +
ggplot2::scale_colour_identity()
# Or by posterior probability, for example here a central probability of 0.6
# corresponds to a lower tail probability of (1 - 0.6)/2 = 0.2
plot(smk_dic_RE, .width = c(0.6, 0.95)) +
ggplot2::aes(colour = ifelse(..ymin.. > 1, "darkorange", "black")) +
ggplot2::scale_colour_identity()
# Check for inconsistency using UME model
# }
# NOT RUN {
# Fitting an unrelated mean effects (inconsistency) model
smk_fit_RE_UME <- nma(smk_net,
consistency = "ume",
trt_effects = "random",
prior_intercept = normal(scale = 100),
prior_trt = normal(scale = 100),
prior_het = normal(scale = 5))
smk_fit_RE_UME
# }
# NOT RUN {
# }
# NOT RUN {
# Compare DIC
smk_dic_RE
(smk_dic_RE_UME <- dic(smk_fit_RE_UME)) # no difference in fit
# Compare residual deviance contributions with a "dev-dev" plot
plot(smk_dic_RE, smk_dic_RE_UME)
# By default the dev-dev plot can be a little cluttered
# Hiding the credible intervals
plot(smk_dic_RE, smk_dic_RE_UME, show_uncertainty = FALSE)
# Changing transparency
plot(smk_dic_RE, smk_dic_RE_UME, point_alpha = 0.5, interval_alpha = 0.1)
# }
Run the code above in your browser using DataLab