*! version 4.03 David Fisher 12oct2022

Title

ipdover -- Generate data for forest plots outside of the context of meta-analysis

Syntax

Syntax 1: command-based syntax; "generic" effect measure

ipdover
[exp_list]
, over(over_varlist [, missing]) [ over(varname [, missing]) options] : command [if] [in] ...

Syntax 2: collapse-based syntax; "specific" effect measure

ipdover
input_varlist [if] [in]
, over(over_varlist [, missing]) [ over(varname [, missing]) options]

where input_varlist is one of the following:

var_outcome var_treat where var_outcome and var_treat are both binary 0, 1

var_outcome var_treat where var_outcome is continuous and var_treat is binary 0, 1

var_treat where var_treat is binary 0, 1 and the data have previously been stset.

Description

ipdover extends the functionality of ipdmetan outside the context of meta-analysis.
It does not perform any pooling or heterogeneity calculations;
rather, its intended use is creating forest plots of subgroup analyses within a single trial dataset.
Basic syntaxes are the same as for ipdmetan, but with over(varlist) replacing study(varname).
Where ipdmetan summarises data by study, ipdover summarises data within each level of each variable in varlist.
The optional second over(varname) allows stratification of results by a further single variable,
in a similar way to by(varname) with ipdmetan.

By default, forest plots produced by ipdover are weighted by sample size (rather than by the inverse of the variance),
and sample size appears as a column of data to the left of the plot.
However, if the option wgt() is supplied, weights will not be displayed unless explicitly requested via lcols()
(see ipdmetan for details of these options).

Saved datasets may include the following identifier variables:

_BY subset of data (c.f. by) as supplied to second over() option, if applicable

_OVER identifier of variable within over_varlist

_LEVEL level (category) of variable identified by _OVER.

This version of ipdmetan requires version 4.0+ of the package metan to be installed.
This package is available from the SSC archive; type ssc describe metan.

Options

Options specific to ipdover

over(varlist [, missing]) [ over(varname [, missing])] specifies the variable(s) whose levels command is to be fitted within.
The option may be repeated at most once, in which case the second option must contain a single varname defining
subsets of the data (c.f. by).

All variables must be either integer-valued or string.
Variable and value labels will appear in output where appropriate.

missing requests that missing values be treated as potential subgroups or subsets (the default is to exclude them).

plotid(_BY | _OVER | _LEVEL | _n [, list nograph]) functions in basically the same way as in ipdmetan,
but instead of a varname, it accepts one of the following values, corresponding to variables created in saved
datasets created by ipdover:

_BY group observations by levels of _BY

_OVER group observations by levels of _OVER

_LEVEL group observations by levels of _LEVEL

_n allow each observation to be its own group.

Most other options as described for ipdmetan, metan
or forestplot may also be supplied to ipdover,
with the exception of options concerning heterogeneity statistics or pooled results
such as model(), cumulative or influence.
(However, note that poolvar() is allowed (with Syntax 1), since it refers to the coefficient to be extracted
from each model fit rather than to the pooled result per se.)

Saved results

ipdover saves the following in r():

(in addition to any scalars saved by forestplot)

Scalars

r(k) Number of subgroups

r(n) Total number of included patients

Macros

r(citype) Method of constructing confidence intervals

r(command) Full estimation command-line

r(cmdname) Estimation command name

r(estexp) Name of coefficient representing effect size

Matrices

r(coeffs) Matrix of study and subgroup identifiers, effect coefficients, and numbers of participants

Variables

_rsample Observations included in the analysis (c.f. e(sample))

Examples

Using the Hosmer & Lemeshow low birthweight data from logistic,
look at the effect of maternal age on odds of LBW within various data subgroups:

. webuse lbw, clear

. ipdover, over(race smoke ht) or

forestplot(favours("Odds of LBW decrease" "as age increases" # "Odds of LBW increase" "as age increases"))

: logistic low age

(click to run)

With the same dataset, use Syntax 2 of ipdover to derive mean and SD of maternal age within birthweight categories,
and hence analyse the mean difference in maternal age between those whose babies were LBW vs those who were normal weight.
This example also demonstrates the use of group1(), group2():

. webuse lbw, clear

. ipdover age low, over(race ht) wmd

forestplot(favours(`"Mean maternal age higher"' `"among those with LBW infant"' #

`"Mean maternal age lower"' `"among those with LBW infant"'))

counts group1(`"Age of mothers"' `"of low BW infants"') group2(`"Age of mothers"' `"of normal BW infants"')

(click to run)

Note that, following other meta-analysis software such as the Cochrane Review Manager,
the standard error of the (unstandardised) mean difference is derived as sqrt(sd0^2/n0 + sd1^2/n1)
where sd0, sd1 are the SDs in the two treatment arms with respective sample sizes n0, n1.
Therefore, we could also perform this analysis using variance-weighted least-squares regression, albeit without the counts option:

. webuse lbw, clear

. ipdover, over(race ht) wmd : vwls age low

(click to run)

Finally, we apply ipdover to a set of clinical trials, showing the treatment effect by covariate subgroup by trial
(using the example IPD meta-analysis dataset from ipdmetan):

(Note the use of the option maxwidth(18). As stage contains only the extremely short labels "I", "II" and "III",
by default forestplot would underestimate the width needed to contain the column title. See help forestplot for more details.)

. use http://fmwww.bc.edu/repec/bocode/i/ipdmetan_example.dta, clear

. stset tcens, fail(fail)

. ipdover, over(stage) over(trialid) hr nosubgroup nooverall

forestplot(favours(Favours treatment # Favours control) maxwidth(18)) : stcox trt

(click to run)

Author

David Fisher, MRC Clinical Trials Unit at UCL, London, UK.

Email d.fisher@ucl.ac.uk

Acknowledgments

Thanks to Phil Jones at UWO, Canada for suggesting improvements in functionality.

The "click to run" element of the examples in this document is handled using an idea originally developed by Robert Picard.

References

Review Manager (RevMan) [Computer program]. Version 5.3.
Copenhagen: The Nordic Cochrane Centre, The Cochrane Collaboration, 2014.