### Build and Install GeMTC R Package Source: https://github.com/gertvv/gemtc/blob/develop/README.md Builds and installs the GeMTC R package using the Makefile. This is a convenience target for the build process. ```Shell make install ``` -------------------------------- ### Bayesian Model Specification Examples Source: https://github.com/gertvv/gemtc/wiki/R-Wishlist Illustrative syntax for specifying Bayesian models, particularly for handling random effects in meta-analysis. These examples show how parameters are defined and related, often used in software like JAGS or WinBUGS. ```JAGS/BUGS delta[i,2:3] ~ dmnorm(c(dAB, dAB), ...) # This implies a *within*-study* random effect, which is not appropriate for the normal interpretation of the random effect. delta.t[i,2] ~ dnorm(dAB, ...) # This suggests an additional level to deal with duplicated arms. ``` -------------------------------- ### Create R Data Frame Source: https://github.com/gertvv/gemtc/blob/develop/gemtc/tests/data/studyrow/tsd2-2.out.txt This snippet shows how to define and create a data frame in R. It uses the structure function to build a data frame with columns for study, treatment, responders, and exposure. This is a common way to initialize datasets for analysis. ```R structure(list(study = c("DART", "DART", "London Corn/Olive", "London Corn/Olive", "London Corn/Olive", "London Low Fat", "London Low Fat", "Minnesota Coronary", "Minnesota Coronary", "MRC Soya", "MRC Soya", "Oslo Diet-Heart", "Oslo Diet-Heart", "STARS", "STARS", "Sydney Diet-Heart", "Sydney Diet-Heart", "Veterans Administration", "Veterans Administration", "Veterans Diet & Skin CA", "Veterans Diet & Skin CA"), treatment = c("control", "diet", "control", "diet", "diet", "control", "diet", "control", "diet", "control", "diet", "control", "diet", "control", "diet", "control", "diet", "control", "diet", "control", "diet"), responders = c(113L, 111L, 1L, 5L, 3L, 24L, 20L, 248L, 269L, 31L, 28L, 65L, 48L, 3L, 1L, 28L, 39L, 177L, 174L, 2L, 1L), exposure = c(1917, 1925, 43.6, 41.3, 38, 393.5, 373.9, 4715, 4823, 715, 751, 885, 895, 87.8, 91, 1011, 939, 1544, 1588, 125, 123)), row.names = c(NA, -21L ), class = "data.frame") ``` -------------------------------- ### Create R Data Frame Source: https://github.com/gertvv/gemtc/blob/develop/gemtc/tests/data/studyrow/tsd2-7.out.txt This R code snippet defines and creates a data frame named 'df' using the `structure()` function. It includes columns for study, variable, treatment, difference, and standard error, with sample data. ```R structure(list(study = c("1", "1", "2", "2", "3", "3", "4", "4", "5", "5", "6", "6", "7", "7", "7"), var = c(0.253518519, 0.253518519, 0.079593023, 0.079593023, 0.0703125, 0.0703125, 0.1125, 0.1125, 0.038949635, 0.038949635, 0.039937662, 0.039937662, 0.254736842, 0.254736842, 0.254736842), treatment = c("1", "3", "1", "2", "3", "4", "3", "4", "4", "5", "4", "5", "1", "2", "4"), diff = c(NA, -0.31, NA, -1.7, NA, -0.35, NA, 0.55, NA, -0.3, NA, -0.3, NA, -2.3, -0.9), std.err = c(NA, 0.668089651, NA, 0.382640605, NA, 0.441941738, NA, 0.555114559, NA, 0.274276316, NA, 0.320087245, NA, 0.71774604, 0.694988091)), row.names = c(NA, -15L), class = "data.frame") ``` -------------------------------- ### Create R Data Frame with Study Data Source: https://github.com/gertvv/gemtc/blob/develop/gemtc/tests/data/studyrow/tsd2-8.out1.txt This R code snippet demonstrates creating a data frame using the `structure()` function. It initializes vectors for study, treatment, mean, and standard error, then combines them into a data frame. This is a fundamental operation for data handling in R. ```R structure(list(study = c("1", "1", "2", "2", "3", "3", "3"), treatment = c("1", "3", "1", "2", "1", "2", "4"), mean = c(-1.22, -1.53, -0.7, -2.4, -0.3, -2.6, -1.2), std.err = c(0.504, 0.439, 0.282, 0.258, 0.505, 0.51, 0.478))), row.names = c(NA, -7L), class = "data.frame") ``` -------------------------------- ### Create R Data Frame with Study and Treatment Data Source: https://github.com/gertvv/gemtc/blob/develop/gemtc/tests/data/studyrow/tsd2-5.out.txt This R code defines a data frame containing experimental data, including study identifiers, treatment groups, mean values, and standard errors. It demonstrates a common pattern for organizing tabular data in R for analysis. ```R structure(list(study = c("1", "1", "2", "2", "3", "3", "3", "4", "4", "5", "5", "6", "6", "7", "7"), treatment = c("1", "3", "1", "2", "1", "2", "4", "3", "4", "3", "4", "4", "5", "4", "5"), mean = c(-1.22, -1.53, -0.7, -2.4, -0.3, -2.6, -1.2, -0.24, -0.59, -0.73, -0.18, -2.2, -2.5, -1.8, -2.1), std.err = c(0.504, 0.439, 0.282, 0.258, 0.505, 0.51, 0.478, 0.265, 0.354, 0.335, 0.442, 0.197, 0.19, 0.2, 0.25)), row.names = c(NA, -15L), class = "data.frame") ``` -------------------------------- ### R Data Structure with Summary Statistics Source: https://github.com/gertvv/gemtc/blob/develop/gemtc/tests/data/smoking-ume.summaries.txt Defines a complex R list object containing effective sizes, detailed statistical summaries (mean, SD, SE, quantiles), and a covariance matrix. The summary component includes parameters like start, end, thin, and nchain, suggesting it might originate from an MCMC analysis. ```R structure(list(effectiveSize = structure(c(40678.3887325717, 15833.0792839309, 33311.7697175392, 19299.7145068589, 28158.6103226059, 6471.61933667915), .Names = c("d.A.B", "d.A.C", "d.B.C", "d.B.D", "d.C.D", "sd.d")), summary = structure(list(statistics = structure(c(0.336365312238535, 0.833765623573284, -0.0803913786818312, 1.08031153644781, 0.216526085807077, 0.83948242948833, 0.533058750194505, 0.252207326725614, 0.687693671974806, 0.973577269993074, 0.725982947709848, 0.202248694059633, 0.0018846472851668, 0.000891687554963064, 0.00243136429416231, 0.00344211544810595, 0.00256673732675716, 0.00071505711527845, 0.00264753310869987, 0.00202264420687058, 0.00376855039624721, 0.00702156102374052, 0.00433630997972007, 0.00252233974560594), .Dim = c(6L, 4L), .Dimnames = list( c("d.A.B", "d.A.C", "d.B.C", "d.B.D", "d.C.D", "sd.d"), c("Mean", "SD", "Naive SE", "Time-series SE"))), quantiles = structure(c(-0.710591577355186, 0.35349363615015, -1.4459301944132, -0.840135245107086, -1.23083872322239, 0.529196289733208, -0.00564462769044614, 0.665742932183605, -0.524830998669572, 0.448883887948418, -0.24975027088693, 0.69620008035736, 0.333399430714947, 0.825334998369572, -0.0794605286828713, 1.07393725396434, 0.221202078759538, 0.811589590921506, 0.675290040130688, 0.992219887984337, 0.364678787229087, 1.71037756088689, 0.69011663279255, 0.949292829033654, 1.40102217589302, 1.3568061649767, 1.27806414220814, 3.01354151874289, 1.6409550652184, 1.31598470784675), .Dim = c(6L, 5L), .Dimnames = list(c("d.A.B", "d.A.C", "d.B.C", "d.B.D", "d.C.D", "sd.d"), c("2.5%", "25%", "50%", "75%", "97.5%"))), start = 5001, end = 25000, thin = 1, nchain = 4L), .Names = c("statistics", "quantiles", "start", "end", "thin", "nchain"), class = "summary.mcmc"), cov = structure(c(0.284151631158927, -0.00100924064376064, 0.00108834969612548, 0.000295100487924394, 0.00236931588045582, -0.00100924064376064, 0.0636085356540805, -0.000129240655780235, -0.000142862694673348, -0.00135195013663183, 0.00108834969612548, -0.000129240655780235, 0.472922586474192, 0.0058821312155195, -0.000261236470192804, 0.000295100487924394, -0.000142862694673348, 0.0058821312155195, 0.947852700647167, -0.00169917905663473, 0.00236931588045582, -0.00135195013663183, -0.000261236470192804, -0.00169917905663473, 0.52705124036548 ), .Dim = c(5L, 5L), .Dimnames = list(c("d.A.B", "d.A.C", "d.B.C", "d.B.D", "d.C.D"), c("d.A.B", "d.A.C", "d.B.C", "d.B.D", "d.C.D" )))), .Names = c("effectiveSize", "summary", "cov")) ``` -------------------------------- ### R Package Pluggable Model Architecture Source: https://github.com/gertvv/gemtc/wiki/R-Wishlist Describes a design pattern for the R package that allows users to define custom likelihood functions. This enhances flexibility by enabling the integration of user-written R functions for novel statistical models. ```R Pluggable Model Design: - Allows users to write R functions (or sets of functions) to describe custom likelihoods. - Enhances extensibility for new statistical models not covered by default implementations. ``` -------------------------------- ### Build GeMTC R Package Source: https://github.com/gertvv/gemtc/blob/develop/README.md Builds the GeMTC R package using the R CMD build command. The Makefile offers convenience targets for this process. ```Shell R CMD build gemtc ``` -------------------------------- ### R Package Likelihood and Link Function Implementations Source: https://github.com/gertvv/gemtc/wiki/R-Wishlist This section details specific implementations of likelihood and link function pairs within the R package for network meta-analysis. These are core components for defining statistical models. ```R Likelihood/Link Function Pairs: - normal/identity (since 0.1) - binom/logit (since 0.1) - binom/cloglog (since 0.3) - poisson/log (since 0.4) ``` -------------------------------- ### MCMC Convergence and Model Fit Diagnostics Source: https://github.com/gertvv/gemtc/blob/develop/gemtc/tests/data/dietfat.fe.summaries.txt This documentation covers diagnostics related to MCMC convergence and model fit, including effective sample size and Deviance Information Criterion (DIC). These metrics are vital for assessing the quality of the MCMC output and the overall model fit. ```APIDOC MCMC_Convergence_and_Fit_Diagnostics: Purpose: Assesses the quality of MCMC sampling and the fit of the statistical model. Components: effectiveSize: Description: The effective number of independent samples, adjusted for autocorrelation. Interpretation: A higher effective sample size indicates more precise estimates and better convergence. Values below 100-200 might suggest poor mixing or insufficient sampling. dic: Dbar: The average deviance over the posterior distribution. pD: The effective number of parameters, penalizing model complexity. DIC: Deviance Information Criterion (Dbar + pD). A measure of model fit that penalizes complexity. data points: The number of data points used in the model. Interpretation: Lower DIC values generally indicate a better-fitting model. DIC is useful for comparing hierarchical models, but should be used with caution, especially with complex models or small datasets. ``` -------------------------------- ### MCMC Analysis Output Structure Source: https://github.com/gertvv/gemtc/blob/develop/gemtc/tests/data/dietfat.fe.summaries.txt This snippet represents the typical output structure from MCMC analysis in R, often generated by packages for Bayesian inference. It includes key diagnostic and summary measures for evaluating model convergence and parameter estimates. ```R structure(list(effectiveSize = structure(16781.0195714451, .Names = "d.control.diet"), summary = structure(list(statistics = structure(c(-0.00770627169745623, 0.0534341165393374, 0.000188918130758389, 0.000412525487172919 ), .Names = c("Mean", "SD", "Naive SE", "Time-series SE")), quantiles = structure(c(-0.112410489145885, -0.0437610487614927, -0.00783282534735827, 0.0284324055826491, 0.0971751154902131 ), .Names = c("2.5%", "25%", "50%", "75%", "97.5%"))), start = 5001, end = 25000, thin = 1, nchain = 4L), .Names = c("statistics", "quantiles", "start", "end", "thin", "nchain"), class = "summary.mcmc"), cov = structure(0.00285520481033949, .Dim = c(1L, 1L)), ranks = structure(c(0.5584875, 0.4415125, 0.4415125, 0.5584875), .Dim = c(2L, 2L), .Dimnames = list( c("control", "diet"), NULL), class = "mtc.rank.probability", direction = 1), dic = structure(list(Dbar = 21.9634749556293, pD = 11.080658995388, DIC = 33.0441339510173, `data points` = 20L), .Names = c("Dbar", "pD", "DIC", "data points"))), .Names = c("effectiveSize", "summary", "cov", "ranks", "dic")) ``` -------------------------------- ### Run GeMTC Unit Tests Source: https://github.com/gertvv/gemtc/blob/develop/README.md Executes unit tests for the GeMTC R package. These tests check relatively isolated pieces of functionality and are typically fast. ```Shell make test ``` -------------------------------- ### R MCMC Summary Statistics and Quantiles Source: https://github.com/gertvv/gemtc/blob/develop/gemtc/tests/data/riskratio.summaries.txt This documentation describes the structure of a summary output from an MCMC (Markov Chain Monte Carlo) analysis in R. It details key metrics like effective sample size, central tendency, dispersion, and distributional quantiles, typically derived from Bayesian statistical models. ```R structure(list(effectiveSize = structure(17353.7151177326, .Names = "d.A.B"), summary = structure(list(statistics = structure(c(-0.0905785901265748, 0.0275019781587034, 9.72341762603175e-05, 0.000208889376331796 ), .Names = c("Mean", "SD", "Naive SE", "Time-series SE")), quantiles = structure(c(-0.144369725686598, -0.109146058702042, -0.0906741416473852, -0.0720521541534026, -0.0366082503487515 ), .Names = c("2.5%", "25%", "50%", "75%", "97.5%"))), start = 5001, end = 25000, thin = 1, nchain = 4L), .Names = c("statistics", "quantiles", "start", "end", "thin", "nchain"), class = "summary.mcmc"), cov = structure(numeric(0), .Dim = c(0L, 0L))), .Names = c("effectiveSize", "summary", "cov")) ``` -------------------------------- ### MCMC Covariance and Rank Probabilities Source: https://github.com/gertvv/gemtc/blob/develop/gemtc/tests/data/dietfat.fe.summaries.txt This section explains the covariance matrix and rank probability matrices generated from MCMC analysis. These outputs are used to understand parameter correlations and the relative ranking of model specifications. ```APIDOC MCMC_Covariance_and_Ranks: Purpose: Provides insights into parameter correlations and model ranking. Components: cov: Description: The covariance matrix of the sampled parameters. Off-diagonal elements indicate the degree of linear relationship between pairs of parameters. Interpretation: High positive or negative covariances suggest strong linear dependencies, which can impact parameter estimation and model interpretation. ranks: Description: A matrix representing rank probabilities, often used in model comparison or to assess the probability of a specific parameter ranking. Interpretation: Used to evaluate the relative performance or importance of different model components or parameters based on their posterior ranks. ``` -------------------------------- ### MCMC Summary Statistics Interpretation Source: https://github.com/gertvv/gemtc/blob/develop/gemtc/tests/data/dietfat.fe.summaries.txt This section details the interpretation of key summary statistics derived from MCMC output. It includes measures of central tendency, dispersion, and convergence diagnostics crucial for Bayesian model evaluation. ```APIDOC MCMC_Summary_Statistics: Purpose: Provides a summary of parameter estimates from MCMC chains. Components: statistics: Mean: The average value of the parameter across MCMC samples. SD: The standard deviation of the parameter across MCMC samples, indicating variability. Naive SE: Standard error calculated naively, often less reliable for MCMC. Time-series SE: Standard error adjusted for autocorrelation in MCMC chains, a more robust measure. quantiles: 2.5%: The 2.5th percentile of the parameter distribution. 25%: The 25th percentile (first quartile). 50%: The median of the parameter distribution. 75%: The 75th percentile (third quartile). 97.5%: The 97.5th percentile. Interpretation: The range between 2.5% and 97.5% quantiles typically forms a 95% credible interval. Mean and median provide measures of central tendency, while SD and SEs indicate precision and variability. ``` -------------------------------- ### Run GeMTC Validation Tests Source: https://github.com/gertvv/gemtc/blob/develop/README.md Executes validation tests for the GeMTC R package. These tests verify posterior summaries against published literature results and can take a long time to run. ```Shell make validate ``` -------------------------------- ### Run GeMTC Regression Tests Source: https://github.com/gertvv/gemtc/blob/develop/README.md Executes regression tests for the GeMTC R package. These tests exercise full code paths and aim to catch bugs in existing functionality. ```Shell make regress ``` -------------------------------- ### NMA Inconsistency Models Source: https://github.com/gertvv/gemtc/wiki/R-Wishlist Lists models required for assessing inconsistency in network meta-analysis. These are advanced statistical techniques used to evaluate the coherence of evidence within a network. ```APIDOC Network Meta-Analysis Inconsistency Models: - Node-splitting models - Design-by-treatment interaction models - Independent mean effects models ``` -------------------------------- ### gemtc Model Definition Source: https://github.com/gertvv/gemtc/blob/develop/gemtc/inst/gemtc.model.use.template.txt Defines the structure and parameters for a statistical model within the gemtc project. It includes placeholders for likelihood functions, prior specifications, and iterative definitions for study-specific parameters like delta. ```gemtc-model model { # Likelihood for arm-based data $armeffect$ # Likelihood for contrast-based data (univariate for 2-arm trials) $releffect.r2$ # Likelihood for contrast-based data (multivariate for multi-arm trials) $releffect.rm$ prior.prec <- pow(15 * om.scale, -2) # Study baseline priors $studyBaselinePriors$ for (i in studies) { delta[i, 1] <- 0 for (k in 2:na[i]) { delta[i, k] ~ dnorm(0, prior.prec) } } } ``` -------------------------------- ### R Code for Random Effects Model Source: https://github.com/gertvv/gemtc/blob/develop/gemtc/inst/gemtc.randomeffects.txt This snippet implements a random effects model in R. It iterates through studies, parameterizing multi-arm trials using a trick to avoid dmnorm, and defines prior distributions for the random effects variance. It includes calculations for study-level relative effects and conditional means. ```R # Random effects model for (i in studies) { # Study-level relative effects w[i, 1] <- 0 delta[i, 1] <- 0 for (k in 2:na[i]) { # parameterize multi-arm trials using a trick to avoid dmnorm delta[i, k] ~ dnorm(md[i, k], taud[i, k]) md[i, k] <- d[t[i, 1], t[i, k]] + sw[i, k] taud[i, k] <- tau.d * 2 * (k - 1) / k w[i, k] <- delta[i, k] - (d[t[i, 1], t[i, k]]) sw[i, k] <- sum(w[i, 1:(k-1)]) / (k - 1) } } # Random effects variance prior $hy.prior$ ```