*! mimix version 1.5 14Feb2021
help mimix (SJ16-2: st0440)

Title

mimix -- Reference-based multiple imputation, for sensitivity analysis of longitudinal trials with protocol deviation

Syntax

mimix depvar treatvar, id(varname) time(varname) [options]

mimix requires data in long format with one record per individual per
timepoint, where depvar identifies the numeric outcome variable with missing
data and treatvar identifies the treatment group variable in the existing
dataset. See reshape for help converting data from wide into long
form. treatvar may be either a numeric or a string variable.

* id(varname) variable identifying individuals in the existing dataset

* time(varname) variable identifying units of time in the existing dataset (must be numeric)

* clear clear the original dataset from memory and load the imputed dataset into memory

* saving(filename[, replace]) save the dataset of imputed values in filename.dta

covariates(varlist) existing fully observed numeric variable(s) identifying any additional baseline covariate(s) to be included in the multiple imputation model and analysis if either
the regress or the mixed option is specified; see Specifying the covariates

interim(string) specify that all interim missing values be imputed under missing at random (MAR); see Specifying the imputation method

iref(string) specify the level of treatvar chosen for the reference for all interim missing values

method(string) specify the imputation method for all individuals;
see Specifying the imputation method

methodvar(varname) existing variable identifying the individual-specific imputation method(s);
see Specifying the imputation method

mixed fit a linear mixed model using restricted maximum
likelihood and combine
results using Rubin's (1987) rules

refgroup(string) specify the level of treatvar chosen for the reference group for all individuals;
required with j2r, cir, and cr imputation; see Specifying the imputation method

refgroupvar(varname) specify the variable that identifies the level of treatvar chosen for the reference group for each individual in the existing dataset;
required with j2r, cir, and cr imputation;
see Specifying the imputation method

regress fit a linear regression of depvar at the final timepoint on treatvar,
and any included covariates(), to each of the imputed datasets and
combine results using Rubin's (1987) rules

burnbetween(#) specify the number of iterations between imputations in the Markov chain Monte Carlo (MCMC) procedure; default is burnbetween(100)

burnin(#) specify the number of iterations for the burn-in period in the MCMC procedure; default is burnin(100)

m(#) specify the number of imputations to be created; default is m(5)

seed(#) set the random-number seed; default is seed(0)

* id(), time(), and clear or saving() are
required.

Description

mimix imputes missing numerical outcomes for a longitudinal trial with
protocol deviation under distinct treatment arm-based assumptions for the
unobserved data, following the general algorithm of
Carpenter, Roger, and Kenward (2013). See
Implementing the imputation procedure
for a summary of the general algorithm.

The imputation methods, which each correspond to an underlying accessible
assumption for the missing data, are as follows:

Method name Name to specify
in method()
or methodvar()

Randomized-arm missing at random mar
Jump to reference j2r
Last mean carried forward lmcf
Copy increments in reference cir or ciir
Copy reference cr

Each method constructs appropriate joint distributions for the observed and
unobserved data for deviating individuals, based on an underlying assumption
for the missing data. These joint distributions imply conditional
distributions for the missing data, given that observed, from which
imputations can be drawn. The underlying assumptions for the missing data of
each method follow.

'Randomized-arm MAR' assumes that the joint distribution of an individual's
observed and missing outcome data is multivariate normal (MVN) with a mean and
covariance matrix from the individual's randomized treatment group.

'Jump to reference' assumes that the joint distribution of an individual's
observed and missing outcome data is MVN with a mean vector from the
individual's randomized group up to his or her last observed time.
Postdeviation, the mean follows that observed for a specified reference group
(typically the control). The covariance matrix matches that from the
randomized arm for the predeviation measurements and the reference arm for the
conditional components for the postdeviation given the predeviation
measurements. Missing data for individuals in the reference group are imputed
under on-treatment group MAR. This option is particularly appropriate when
the postdeviation individuals ceased their randomized treatment and started
treatment similar to that available in one of the other trial arms (the
reference arm).

'Last mean carried forward' assumes that the joint distribution of an
individual's observed and missing outcome data is MVN with a mean vector from
their randomized group up to his or her last observed time. Postdeviation,
the mean vector is set equal to the value of the marginal mean for the
individual's randomized treatment group at his or her last observed time. The
covariance matrix remains that from the individual's randomized treatment
group. This option is particularly appropriate when it is assumed that the
individuals' unobserved responses will remain constant, on average.

'Copy increments in reference' assumes that the joint distribution of an
individual's observed and missing outcome data is MVN with a mean vector from
the individual's randomized group up to his or her last observed time before
deviating. Postdeviation, the individual's mean increments follow those from
a specified reference group (typically the control). The covariance matrix is
the same as for jump to reference. Missing data for individuals in the
reference group are imputed under on-treatment group MAR.

'Copy reference' assumes that the joint distribution of an individual's
observed and missing outcome data is MVN with a mean vector and covariance
matrix from a specified reference group (typically the control), regardless of
deviation time. Missing data for individuals in the reference group are
imputed under on-treatment group MAR.

For full technical details, see
Carpenter, Roger, and Kenward (2013).

A missing value is termed interim whenever a response is later observed for
that individual. If the interim() option is specified, then any interim
missing-data values will be imputed under MAR. This is often a reasonable
assumption for interim missing data. If interim() is not used, then any
interim missing-data values will be imputed under the method specified by
method() or methodvar().

The imputed data are mi set ready to analyze using mi estimate.
In addition, they are ready to output in memory if clear is
specified and to be saved in filename.dta if saving() is
specified.

The substantive model of interest used in the primary analysis of the trial,
which defines the treatment group by randomization, should be retained in the
sensitivity analysis to assess the impact of alternative treatment profiles
for deviating individuals on the treatment effect of interest. Two
substantive model options are built into mimix. If regress is
specified, a linear regression of depvar at the final timepoint on
treatvar, and any included covariates(), is performed on each
imputed dataset, and results are combined according to the combination rules
by Rubin (1987). If mixed is specified, a linear
mixed model (with a separate mean for each treatment and time, full
covariate-time interactions for any included covariates(), and a
separate unstructured variance matrix for each arm) is fit to each of the
imputed datasets using restricted maximum likelihood, and results are combined
using Rubin's rules.

Options

id(varname) specifies the variable identifying individuals in the
existing dataset. id() is required and may be either a numeric or a
string variable.

time(varname) specifies the variable identifying units of time in the
original dataset. time() is required and must be a numeric variable.

clear specifies that the original data in memory be cleared and replaced
by the imputed dataset. The imputed dataset must be saved manually if
required. One of clear or saving() is required.

saving(filename[, replace]) saves the imputed
datasets. A new filename is required unless replace is also specified.
replace allows the filename to be overwritten with new data. One
of clear or saving() is required.

covariates(varlist) specifies any additional baseline covariates to be
included in the multiple-imputation model and analysis if either the
regress or mixed option is specified. Any specified
covariates must be fully observed numerical variables. Dummy variables must
be generated for any factor covariates. See
Specifying the covariates.

interim(string) specifies an alternative imputation method for all
interim missing values (where the individual has data observed later).
string may be mar, j2r, lmcf, cir, or
cr (not case sensitive). See
Specifying the imputation method.

iref(string) specifies the level of treatvar chosen for the
reference for all interim missing values (where the individual has data
observed later). iref() is required when using the j2r,
cir, or cr imputation method. See
Specifying the imputation method.

method(string) defines the imputation method for all individuals.
string may be mar, j2r, lmcf, cir (or
ciir), or cr (not case sensitive). method() and
methodvar() are mutually exclusive; specifying both will return an
error message. See
Specifying the imputation method.

methodvar(varname) specifies the variable in the original dataset that
contains the individual-specific imputation method(s). This option should be
used if different imputation methods are required for different individuals.
methodvar() must be a string variable containing one of mar,
j2r, lmcf, cir, or cr (not case sensitive) for each
individual. methodvar() and method() are mutually exclusive;
specifying both will return an error message. See
Specifying the imputation method.

mixed uses mi estimate with Stata's default options to fit a
saturated repeated-measures model using restricted maximum likelihood -- with
a separate mean for each treatment and time, full covariate-time interactions
for any included covariates(), and a separate unstructured covariance
matrix for each arm -- to each of the imputed datasets. mixed combines
results using Rubin's (1987) rules for inference. This
option may add substantially to the postimputation computation time if a large
number of imputations have been specified.

refgroup(string) specifies the level of treatvar chosen for the
reference group for all individuals. This option is required when using the
j2r, cir, or cr imputation method. refgroup() and
refgroupvar() are mutually exclusive; specifying both will return an
error message. See
Specifying the imputation method.

refgroupvar(varname) specifies the variable in the original dataset that
identifies the level of treatvar chosen for the reference for each
individual. This option is required when using the j2r, cir, or
cr imputation method. refgroupvar() and refgroup() are
mutually exclusive; specifying both will return an error message. See
Specifying the imputation method.

regress uses mi estimate with Stata's default options to fit a
linear regression of depvar at the final timepoint on treatvar, and
any included covariates(), to each of the imputed datasets. It combines
results using Rubin's (1987) rules for inference.

burnbetween(#) specifies the number of iterations between pulls for the
posterior in the MCMC. The default is burnbetween(100).

burnin(#) specifies the number of iterations in the MCMC burn-in. The
default is burnin(100).

m(#) specifies the number of imputations required. The default is
m(5). If regress or mixed used, m<1001.

seed(#) specifies the seed for the random-number generator. The default
is seed(0), meaning that no seed is specified by the user and so the
current value of Stata's random-number seed will be used; this will result in
different sets of imputations for multiple program runs. To reproduce a set
of imputations, the same random-number seed should be used with the original
data sorted in exactly the same order. If the covariates option is used then
covariates must be specified in the same order to obtain replicable results.
This is due to an internal command which re-orders the data to correspond
with the order of the covariate specification; MI is a Monte-Carlo (i.e. stochastic)
method which will produce different results depending on the order specificed for included variables.

Remarks

Remarks are presented under the following headings:

General remarks

Specifying the imputation method

Implementing the imputation procedure

Specifying the covariates

General remarks

Data are required in long format with one record per individual per timepoint.
See reshape for help converting data from wide into long form. The
imputed dataset is produced in long format, with one record per individual per
timepoint per imputation and is mi set ready to analyze using
mi estimate. The imputed dataset is output in memory if clear
is specified and is saved in filename.dta if saving() is
specified.

Because of extensive data manipulation, mimix uses the preserve
and restore commands. While mimix can be successfully run on
data that are already preserved, we recommend that users cancel any previous
data preserve by using restore, not to ensure the clear and
saving() options of mimix work as intended.

Specifying the imputation method

The five imputation options of mimix are randomized-arm MAR, jump to
reference, last mean carried forward, copy increments in reference, and copy
reference. Each method constructs appropriate joint distributions for the
observed and unobserved data for deviating individuals based on an underlying
assumption for the missing data. These joint distributions imply conditional
distributions for the missing data, given that observed, from which
imputations can be drawn.

The mimix command must contain either the method() option to
indicate which imputation method should be employed for all individuals or the
methodvar() option to indicate which imputation method should be
employed for each individual.

Values must be one of mar (randomized-arm MAR), j2r (jump to
reference), lmcf (last mean carried forward), cir or ciir
(copy increments in reference), or cr (copy reference). Values are not
case sensitive.

If the j2r, cir, or cr imputation method is used, then
either the refgroup() option must also be used to specify the reference
level of the treatvar for all individuals or the refgroupvar()
option must also be used to indicate the reference level of the treatvar
for each individual. Together, these variables fully specify the required
imputation method. If one of the imputation methods that includes a reference
group is specified for all individuals (or for specific individuals via
methodvar()), then missing data for individuals in that reference group
(with the reference-imputation specification) are imputed under randomized-arm
MAR.

Different postdeviation assumptions can be made for different individuals as
specified by the required methodvar() variable. However, the
specification cannot vary within an individual over time.

The interim() option specifies the imputation method for all interim
missing values, defined as missing values with responses observed later for
that individual. If this option is not used, any interim missing values will
be imputed under the specified imputation method, in the same way as missing
postdeviation data.

Implementing the imputation procedure

The general algorithm of
Carpenter, Roger, and Kenward (2013) that is implemented
by the mimix command can be summarized as follows:

1. Separately for each treatment arm, take all the observed data, assume MAR,
and fit an MVN distribution with an unstructured mean (that is, a separate
mean for each of the baseline and the postrandomization observation times) and
a variance-covariance matrix using a Bayesian approach with an improper prior
for the mean and an uninformative Jeffreys prior for the covariance matrix.

2. Draw a mean vector and covariance matrix from the posterior distribution
for each treatment arm. Specifically, we use the MCMC method to draw from the
appropriate Bayesian posterior, with a sufficient burn-in, and we update the
chain sufficiently in between to ensure that subsequent draws are independent.
The sampler is initiated using the expectation-maximization (EM) algorithm.

3. Use the draws in step 2 to form the joint distribution for each deviating
individual's observed and missing outcome data as required, depending on the
assumption for the missing data. See Description
for the available imputation options.

4. Construct the conditional distribution of missing given observed outcome
data for each individual who deviated from the joint distribution formed in
step 3. Sample missing data from the conditional distributions to create a
completed dataset.

5. Repeat steps 2-4 m times, resulting in m imputed datasets.

To complete steps 1 and 2 of the general procedure, mimix uses Stata's
mi impute mvn command with the mcmconly option. If the response
variable of interest is measured at an occasion with only a very few complete
cases, then mi impute mvn may terminate with an error messageif there is
not enough information in the observed data to reliably estimate aspects of
the covariance structure in the required MVN model. If this is the case, we
advise the user to explore an alternative viable MVN model for the data by
using the mi impute mvn command. See mi impute mvn. The
response at the occasion with few observed outcomes may potentially need to be
excluded from the analysis and mimix rerun.

Specifying the covariates

Any additional baseline covariates that are to be included in the imputation
model (and the analysis if regress or mixed is specified) must be
fully observed and numeric. At the imputation step, they are formally treated
as continuous in the MVN imputation. Binary variables can be included,
provided they have a numeric coding. Dummy variables must be generated for
any factor covariates, that is, c-level categorical variables must be included
as (c-1) numeric dummy indicator variables.

Covariates must also be constant over time for each individual. If not, the
first value across all timepoints will be used.

Individuals with missing covariates will be dropped from the multiple
imputation and noted in the output.

Examples

Analyzing the asthma trial data

. use asthma

Multiple imputation assuming the response variable fev is MAR

. mimix fev treat, id(id) time(time) method(mar) covariates(base) clear m(50) seed(101)

Multiple imputation and regression analysis assuming last mean carried forward
for the response variable fev

. use asthma, clear

. mimix fev treat, id(id) time(time) method(lmcf) covariates(base) clear m(50) regress seed(101)

Multiple imputation and regression analysis assuming jump to reference for the
response variable fev, with placebo=2 as the reference

. use asthma, clear

. mimix fev treat, id(id) time(time) method(j2r) refgroup(2) covariates(base) clear m(50) regress seed(101)

Saving the imputed dataset with filename mimix_example, assuming
copy increments in reference for the response variable fev, with
placebo=2 as the reference

. use asthma, clear

. mimix fev treat, id(id) time(time) method(cir) refgroup(2) covariates(base) saving(mimix_example, replace) m(50) seed(101)

Stored results

mimix stores the following in r():

Scalars

r(N) total sample size

r(Nmiss) total number of individuals with incomplete data

r(Ncomp) total number of individuals with complete data

r(M) number of imputations

r(burnin) number of MCMC burn-in iterations

r(bbetween) number of MCMC burn-between iterations

Macros

r(depvar) name of dependent variable

r(treatvar) name of treatment group variable

r(covariates) names of covariates

r(method) imputation method (with method() only)

r(methodvar) imputation method variable (with methodvar() only)

r(rgroup) name of reference group (with refgroup() only)

r(rgroupvar) name of reference group variable (with refgroupvar() only)

r(rseed) random-number seed

Matrices

r(Ntreat) sample size in each treatment group

r(Ntreat_mis) number of individuals with incomplete data in each treatment group

r(Ntreat_comp) number of individuals with complete data in each treatment group

r(Ntreat_pat) number of unique missing-value patterns in each treatment group

r(niter_em) number of iterations EM takes to converge in each treatment group

r(lpobs_em) observed log posterior in EM in each treatment group

r(conv_em) convergence flag for EM in each treatment group

Acknowledgments

This Stata program is an adaptation of the SAS macro, miwithd, written by James Roger available at www.missingdata.org.uk.
I also thank Tim Morris (MRC CTU at UCL, UK) and Baptiste Leurent (London School of
Hygiene and Tropical Medicine, UK) for their helpful comments on the program.

References

Carpenter, J. R., J. H. Roger, and M. G. Kenward. 2013. Analysis of longitudinal trials with protocol deviation: A framework for relevant, accessible assumptions, and inference via multiple imputation.
Journal of Biopharmaceutical Statistics 23: 1352-1371.

Rubin, D. B. 1987. Multiple Imputation for Nonresponse in Surveys. New
York: Wiley.

Author

Suzie Cro

Imperial College London, UK

s.cro@imperial.ac.uk

Also see

Article: Stata Journal, volume 16, number 2: st0440