Prepares data for JAGS
getjagsdata.RdConverts 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:
studyIDStudy identifierstimeNumeric data indicating follow-up timesyNumeric data indicating the aggregate response for a given observation (e.g. mean)seNumeric data indicating the standard error for a given observationtreatmentTreatment identifiers (can be numeric, factor or character)classAn optional column indicating a particular class identifier. Observations with the same treatment identifier must also have the same class identifier.nAn optional column indicating the number of participants used to calculate the response at a given observation (required if modelling using Standardised Mean Differences)standsdAn 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.abcontains 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)").rhoalso be assigned a numeric value (e.g.rho=0.7), which fixesrhoin 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 friedrich2011MBNMAtime) 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=TRUEwill 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 isTRUEif the study data reported is change-from-baseline andFALSEotherwise. If left asNULL(the default) then this will be identified from the data by assuming any study for which there is no data attime=0reports change-from-baseline.
Value
A named list of numbers, vector, matrices and arrays to be sent to JAGS. List elements are:
yAn array of mean responses for each observation in each arm within each studyseAn array of standard errors for each observation in each arm within each studytimeA matrix of follow-up times within each studyfupsA numeric vector with the number of follow-up measurements per studynarmA numeric vector with the number of arms per studyNSThe total number of studies in the datasetNTThe total number of treatments in the datasettreatA matrix of treatment codes within each studyNclassOptional. The total number of classes in the datasetclassOptional. A matrix of class codes within each studyclasskeyOptional. A vector of class codes that correspond to treatment codes. Same length as the number of treatment codes.mat.triangleOptional. A matrix with number indicating how to fill covariance matrices within the JAGS code.mat.orderOptional. A matrix with number indicating what order to fill covariance matrices within the JAGS code.timedif.0Optional. 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")