getjagsdata: Prepares data for JAGS

View source: R/prepare.functions.R

getjagsdataR Documentation

Prepares data for JAGS

Description

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

Usage

getjagsdata(
  data.ab,
  fun = NULL,
  class = FALSE,
  rho = NULL,
  covstruct = "CS",
  link = "identity",
  sdscale = FALSE,
  cfb = NULL
)

Arguments

data.ab

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

  • studyID Study identifiers

  • time Numeric data indicating follow-up times

  • y Numeric data indicating the aggregate response for a given observation (e.g. mean)

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

  • treatment Treatment identifiers (can be numeric, factor or character)

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

  • n An optional column indicating the number of participants used to calculate the response at a given observation (required if modelling using Standardised Mean Differences)

  • standsd An optional column of numeric data indicating reference SDs used to standardise treatment effects when modelling using Standardised Mean Differences (SMD).

fun

An object of class "timefun" generated (see Details) using any of tloglin(), tpoly(), titp(), temax(), tfpoly(), tspline() or tuser()

class

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

rho

The correlation coefficient when modelling within-study correlation between time points. The default is a string representing a prior distribution in JAGS, indicating that it be estimated from the data (e.g. rho="dunif(0,1)"). rho also be assigned a numeric value (e.g. rho=0.7), which fixes rho in the model to this value (e.g. for use in a deterministic sensitivity analysis). If set to rho=0 (the default) then this implies modelling no correlation between time points.

covstruct

A character to indicate the covariance structure required for modelling correlation between time points (if any), since this determines some of the data. Can be either "CS" (compound symmetry), "AR1" (autoregressive AR1) or "varadj" (variance-adjustment).

link

Can take either "identity" (the default), "log" (for modelling Ratios of Means \insertCitefriedrich2011MBNMAtime) or "smd" (for modelling Standardised Mean Differences - although this also corresponds to an identity link function).

sdscale

Logical object to indicate whether to write a model that specifies a reference SD for standardising when modelling using Standardised Mean Differences. Specifying sdscale=TRUE will therefore only modify the model if link function is set to SMD (link="smd").

cfb

A logical vector whose length is equal to the unique number of studies in data.ab, where each element is TRUE if the study data reported is change-from-baseline and FALSE otherwise. If left as NULL (the default) then this will be identified from the data by assuming any study for which there is no data at time=0 reports change-from-baseline.

Value

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

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

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

  • time A matrix of follow-up times within each study

  • fups A numeric vector with the number of follow-up measurements per study

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

  • NS The total number of studies in the dataset

  • NT The total number of treatments in the dataset

  • treat A matrix of treatment codes within each study

  • 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 treatment codes. Same length as the number of treatment codes.

  • mat.triangle Optional. A matrix with number indicating how to fill covariance matrices within the JAGS code.

  • mat.order Optional. A matrix with number indicating what order to fill covariance matrices within the JAGS code.

  • timedif.0 Optional. A vector of the difference in times between the first and second follow-up time in each study.

Examples

# Using the alogliptin dataset
network <- mb.network(alog_pcfb)
jagsdat <- getjagsdata(network$data.ab)


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


# Get JAGS data that allows for modelling correlation between time points
painnet <- mb.network(osteopain)
jagsdat <- getjagsdata(painnet$data.ab, rho="dunif(0,1)", covstruct="AR1")


MBNMAtime documentation built on Oct. 14, 2023, 5:08 p.m.