*! 6apr018 - limit on treatment name length

*! version 1.4.1 4apr018 - more on maxvar

*! version 1.2.5 13mar2017

Title

network setup -- Prepare data for network meta-analysis

Syntax

Count data:

network setup
eventvar nvar
[if] [in]
,
studyvar(varname)
[or|rr|rd|hr
zeroadd(#)
common_options]

Quantitative data:

network setup
meanvar sdvar nvar
[if] [in]i
,
studyvar(varname)
[md|smd
common_options]

Describe data
studyvar(varname) Study identifier (required)

trtvar(varname) Treatment identifier
(implies long input data format)

armvars(drop | keep [varlist]) (only with long input data format)
Specifies how extra arm-level variables
(that is, variables other than those required in the syntax)
should be handled: whether they should all be dropped, all kept, or specified ones kept and the others dropped.
Otherwise, extra arm-level variables cause an error.

How treatments are coded
trtlist(string) List of names of treatments to be used
- useful if you want to omit some treatments e.g. for a sensitivity analysis.
Also useful to specify how the treatments will be coded (first treatment will be A, etc.).
The default is to use all treatments found in alphabetical order
(but in numerical order when trtvar is numeric).

alpha Forces treatments to be coded in alphabetical order.
This is the default except with long input data format when trtvar is numeric with value labels.

numcodes
Codes treatments as numbers 1, 2, 3 ... or (if more than 9 treatments) 01, 02, 03...
The default is to code treatments as letters A, B, C...

nocodes
Uses current treatment names as treatment codes.
Treatment names are modified only if this is needed to make them valid Stata names.
This option becomes increasingly awkward as treatment names become longer.

How to set up
format(augmented|standard|pairs) The (output) data format required.
See Data formats.

or The treatment effect is measured by the log odds ratio.

rr The treatment effect is measured by the log risk ratio.

rd The treatment effect is measured by the risk difference.

hr The treatment effect is measured by the log hazard ratio.
In this case nvar must be the total person-time at risk, not the number of individuals.
(This treatment effect is usually called the log rate ratio;
the term hazard ratio is used to avoid confusion with the risk ratio,
and because the rate ratio equals the hazard ratio under an exponential model.)

zeroadd(#) With count data, the number of successes and
(except with the hr option) failures added
to all arms of any study which contains a zero cell in any arm. Default is 0.5.

md The treatment effect is measured by the mean difference.
The variances are calculated using the pooled standard deviation across all trial arms.

smd The treatment effect is measured by the standardised mean difference.
For details see standardised mean difference below.

sdpool(on|off) With quantitative data, this specifies whether the standard deviation
is pooled across arms in computing variances.
The default, which follows metan, is
sdpool(off) with md
and
sdpool(on) with smd.
For multi-arm studies, sdpool(on) pools across all arms.

Augment options
ref(string) Name of reference treatment.
Different choices should give the same results, but numerical stability may be greater
when the reference treatment is fairly central in the network
(e.g. it is one of the better connected treatments).

augment(exp) Number of individuals to use to augment missing reference treatment arms.
Default is 0.00001.
If errors occur, it may be worth increasing this parameter.
If discrepancies occur, for example between different formats,
then it may be worth decreasing this parameter.

augmean(exp) Mean outcome to use to augment missing reference treatment arms.
Default is for each augmented study to use the weighted average of its
arm-specific means.

augsd(exp) (only for quantitative data) Standard deviation
to use to augment missing reference treatment arms.
Default is for each augmented study to use the weighted average of its
arm-specific standard deviations.

augoverall Changes default behaviour for augmean and augsd
to use the overall mean and SD across all studies.

Naming the output variables
genprefix(string) Prefix to be used before default variable names (e.g. y for treatment contrasts)

gensuffix(string) Suffix to be used after default variable names

Description

network setup prepares data from a set of studies reporting
count data (events, total number)
or
quantitative data (mean, sd, total number)
for two or more treatments.
The data may be in long input format (one record per treatment per study)
or in wide input format (one record per study) - see Input data formats below.

network uses a code and a name for each variable.
The treatments are coded A, B, C etc.,
unless the numcodes option is used, when the codes are 1, 2, 3,...
Handling of large numbers of treatments is described below in Networks with large numbers of treatments.

Treatment codes are usually assigned in alphabetical order of the treatment names.
The exceptions are
(1) if trtlist() is specified, then this order is followed;
(2) if the data are in long input format, and trtvar is a numeric variable,
and the alpha option is not specified, then
the numerical order of trtvar is followed even if trtvar has value labels.

The data are returned sorted by the study identifier.

network setup performs a check that the network is connected:
see Network connectedness.

Input data formats

For data in long input format, events total or mean sd total are variable names.
trtvar() may be a string variable or a numeric variable.
The treatment names are the levels of this variable (or their value labels, if any).
For example, the first 4 studies of the smoking data might be stored in long input format as follows:

study trt d n
1 No contact 9 140
1 Individual counselling 23 140
1 Group counselling 10 138
2 Self help 11 78
2 Individual counselling 12 85
2 Group counselling 29 170
3 No contact 79 702
3 Self help 77 694
4 No contact 18 671
4 Self help 21 535

and would be loaded by network setup d n, studyvar(study) trtvar(trt).

For data in wide input format, events total or mean sd total are variable stubs:
that is, the variable names comprise these variable stubs followed by a suffix which is a treatment name.
The treatment names are these suffixes.
For example, the same studies of the smoking data might be stored in wide input format as follows:

study dA nA dB nB dC nC dD nD
1 9 140 . . 23 140 10 138
2 . . 11 78 12 85 29 170
3 79 702 77 694 . . . .
4 18 671 21 535 . . . .

and would be loaded by network setup d n, studyvar(study).

You might have the same data in a more compact wide input format,
in which the variables refer to the 1st, 2nd etc. study arms, as follows:

study d1 n1 trt1 d2 n2 trt2 d3 n3 trt3
1 9 140 A 23 140 C 10 138 D
2 11 78 B 12 85 C 29 170 D
3 79 702 A 77 694 B . .
4 18 671 A 21 535 B . .

You would load these data by first converting to long input format:

reshape long d n trt, i(study) j(arm)
drop if missing(trt)
drop arm
network setup d n, studyvar(study) trtvar(trt)

Treatment names may not exceed 32 characters in length in any format.

Networks with large numbers of treatments

network setup can accommodate networks with large numbers of treatments.
When treatments are coded alphabetically, up to 26 treatments are coded A, B, C,... and more than 26 treatments are coded AA, AB, AC, ...
When treatments are coded numerically, up to 9 treatments are coded 1, 2, 3,...
and more than 9 treatments are coded 01, 02, 03, ... (or 001, 002, 003, ... if necessary).

With large numbers of treatments, however, the number of variables required by the augmented format may exceed Stata's permitted numbers of variables.
If you are running Stata/IC, then this limit is about 45 treatments, and cannot be changed.
If you are running Stata/MP or Stata/SE, then the default limit is about 70 treatments,
and can be increased by increasing maxvar to at least the square of the number of treatments;
you may also need to increase matsize.

Technical note: it is not possible at present to circumvent these restrictions by using other formats, because the augmented format is always used as an intermediary.

Standardised mean difference

The formulae for Hedges' g in White and Thomas (2005) are used.
These are unbiased estimators and involve corrections for small numbers of degrees of freedom.

In detail, equation (9) is used for the point estimate and (14) is used for the estimated variance.
The covariance between SMD1 and SMD2 is taken as 1/N0 + SMD1*SMD2*K(nu)
where nu is the degrees of freedom used to estimate the pooled standard deviation, N0 is the sample size
in the common reference group, and K(nu) is defined in
White and Thomas (2005).
If sdpool(off) is specified then 1/N1+1/N2 in these formulae is replaced by
(sigma1^2/N1+sigma2^2/N2)/sigma^2 where sigma is the pooled SD.

Network connectedness

network setup performs a check that the network is connected, and prints a warning if it is not.
It also computes four useful matrices which describe the geometry of the network of T treatments:

network_adjacency is a T x T matrix, the "adjacency matrix",
which is 1 if the two treatments are directly compared and 0 otherwise.
Diagonal values are 0 by convention.

network_indirect_connection is a T x T matrix, the "indirect connection matrix",
which is 1 if there is a "walk" in the graph between the two treatments (that is, if they can be indirectly compared)
and 0 otherwise.
Diagonal values are 1 by convention.

network_distance is a T x T matrix, the "distance matrix",
which is the length of the shortest walk through the network between the two treatments.
For example, in a network consisting only of AB trials, BC trials and CD trials,
the distance from A to B is 1 but the distance from A to D is 3.
The distance between unconnected treatments is 0 by convention.
Diagonal values are also 0 by convention.

network_components is a T x C matrix which identifies which treatments lie in which components,
where C is the number of components.
For a connected network, it is a T x 1 matrix of 1s.

You can view the geometry of the network using network map
and you can see the above matrices using matrix list network_components etc.

Examples

Starting with the smoking data in long input format.
study and trt are the identifiers,
d containing number of events, and n contains the total number of individuals.
The following command produces a data set ready for mvmeta:

. use smoking, clear

. network setup d n, studyvar(study) trtvar(trt)

If instead we wanted to use the risk difference:

. network setup d n, studyvar(study) trtvar(trt) rd

Coding treatments as 1-4:

. network setup d n, studyvar(study) trtvar(trt) numcodes

The same starting with data in wide input format.
Variables dA-dD contain numbers of events and nA-nD contain total numbers of individuals:

. network setup d n, studyvar(study)

Return to main help page for network