Prepares data for JAGS
getjagsdata.Rd
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 identifierstime
Numeric data indicating follow-up timesy
Numeric data indicating the aggregate response for a given observation (e.g. mean)se
Numeric data indicating the standard error for a given observationtreatment
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 oftloglin()
,tpoly()
,titp()
,temax()
,tfpoly()
,tspline()
ortuser()
- 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 fixesrho
in the model to this value (e.g. for use in a deterministic sensitivity analysis). If set torho=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 isTRUE
if the study data reported is change-from-baseline andFALSE
otherwise. If left asNULL
(the default) then this will be identified from the data by assuming any study for which there is no data attime=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 studyse
An array of standard errors for each observation in each arm within each studytime
A matrix of follow-up times within each studyfups
A numeric vector with the number of follow-up measurements per studynarm
A numeric vector with the number of arms per studyNS
The total number of studies in the datasetNT
The total number of treatments in the datasettreat
A matrix of treatment codes within each studyNclass
Optional. The total number of classes in the datasetclass
Optional. A matrix of class codes within each studyclasskey
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)
#> Reference treatment is `placebo`
#> Studies reporting change from baseline automatically identified from the data
jagsdat <- getjagsdata(network$data.ab)
# Get JAGS data with class
netclass <- mb.network(goutSUA_CFBcomb)
#> Reference treatment is `Plac`
#> Studies reporting change from baseline automatically identified from the data
jagsdat <- getjagsdata(netclass$data.ab, class=TRUE)
# Get JAGS data that allows for modelling correlation between time points
painnet <- mb.network(osteopain)
#> Reference treatment is `Pl_0`
#> Studies reporting change from baseline automatically identified from the data
jagsdat <- getjagsdata(painnet$data.ab, rho="dunif(0,1)", covstruct="AR1")