Learn R Programming

MBNMAdose (version 0.4.1)

getjagsdata: Prepares data for JAGS

Description

Converts MBNMA data frame to a list for use in JAGS model

Usage

getjagsdata(
  data.ab,
  class = FALSE,
  likelihood = check.likelink(data.ab)$likelihood,
  link = check.likelink(data.ab)$link,
  level = "agent",
  fun = NULL,
  nodesplit = NULL
)

Value

A named list of numbers, vector, matrices and arrays to be sent to JAGS. List elements are:

  • If likelihood="normal":

    • y An array of mean responses for each arm within each study

    • se An array of standard errors for each arm within each study

  • If likelihood="binomial":

    • r An array of the number of responses/count for each each arm within each study

    • n An array of the number of participants for each arm within each study

  • If likelihood="poisson":

    • r An array of the number of responses/count for each each arm within each study

    • E An array of the total exposure time for each arm within each study

  • dose A matrix of doses for each arm within each study (if level="agent")

  • narm A numeric vector with the number of arms per study

  • NS The total number of studies in the dataset

  • Nagent The total number of agents in the dataset (if level="agent")

  • agent A matrix of agent codes within each study (if level="agent")

  • NT The total number of treatment in the dataset (if level="treatment")

  • treatment A matrix of treatment codes within each study (if level="treatment")

  • Nclass Optional. The total number of classes in the dataset

  • class Optional. A matrix of class codes within each study

  • classkey Optional. A vector of class codes that correspond to agent codes. Same length as the number of agent codes.

  • split.ind Optional. A matrix indicating whether a specific arm contributes evidence to a nodesplit comparison.

Arguments

data.ab

A data frame of arm-level data in "long" format containing the columns:

  • studyID Study identifiers

  • dose Numeric data indicating the dose (must take positive values)

  • agent Agent identifiers (can be numeric, factor or character)

  • y Numeric data indicating the aggregate response for a continuous outcome. Required for continuous data.

  • se Numeric data indicating the standard error for a given observation. Required for continuous data.

  • r Numeric data indicating the number of responders within a study arm. Required for binomial or poisson data.

  • n Numeric data indicating the total number of participants within a study arm. Required for binomial data or when modelling Standardised Mean Differences

  • E Numeric data indicating the total exposure time for participants within a study arm. Required for poisson data.

  • class An optional column indicating a particular class code. Agents with the same identifier must also have the same class code.

class

A boolean object indicating whether or not data.ab contains information on different classes of treatments

likelihood

A string indicating the likelihood to use in the model. Can take either "binomial", "normal" or "poisson". If left as NULL the likelihood will be inferred from the data.

link

A string indicating the link function to use in the model. Can take any link function defined within JAGS (e.g. "logit", "log", "probit", "cloglog"), be assigned the value "identity" for an identity link function, or be assigned the value "smd" for modelling Standardised Mean Differences using an identity link function. If left as NULL the link function will be automatically assigned based on the likelihood.

level

Can take either "agent" to indicate that data should be at the agent- level (for MBNMA) or "treatment" to indicate that data should be at the treatment- level (for NMA)

fun

An object of class("dosefun") that specifies a functional form to be assigned to the dose-response. See Details.

nodesplit

A numeric vector of length 2 containing treatment codes on which to perform an MBNMA nodesplit (see mbnma.nodesplit).

Examples

Run this code
# Using the triptans headache dataset
network <- mbnma.network(triptans)
jagsdat <- getjagsdata(network$data.ab, likelihood="binomial", link="logit")


# Get JAGS data with class
netclass <- mbnma.network(osteopain)
jagsdat <- getjagsdata(netclass$data.ab, class=TRUE)


# Get JAGS data at the treatment level for split Network Meta-Analysis
network <- mbnma.network(triptans)
jagsdat <- getjagsdata(network$data.ab, level="treatment")

Run the code above in your browser using DataLab