getjagsdata {MBNMAtime}R 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 (Friedrich et al. 2011)) 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:

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")


[Package MBNMAtime version 0.2.4 Index]