Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: twoway graph for imututed values against observed

From   Andrew Stoddart <>
Subject   Re: st: twoway graph for imututed values against observed
Date   Thu, 26 Jan 2012 15:39:34 +0000

Thanks Wesley,

A slightly adapted version of your code seems to have done the trick.

Thanks also to Maarten for his help.


Quoting "Wesley D. Eddings, StataCorp" <> on Wed, 25 Jan 2012 17:40:44 -0600:

Andy Stoddart ( asked about checking the imputations
created by -mi ice-:

Does anyone know of a way to graph the imputed values over the observed values
on the same graph?

For example I am at present using

mi set wide
mi ice ? , add(5) [options]

twoway (hist x1, [options]) (hist _1_x1 if missing(x1), [options]), ///
legend(label(1 "observed") label(2 "imputed"))

I then view each of the 5 imputations by swapping  _1_x1   for
_2_x1, _3_x1, _4_x1 and _5_x1 in turn to quickly check the imputed
values appear reasonable

Obviously it would be preferable to be able to plot all imputed values
against all observed directly rather than checking individual
imputations one at a time.

It is possible to use -mi xeq-, rather than repeatedly changing the name of the variable to be graphed. Here are the commands to make Andy's plots for all five

. generate byte miss_x1 = missing(x1)
. qui mi xeq 1/5: twoway (hist x1 if miss_x1==0) ||   ///
   (hist x1 if miss_x1==1),     ///
   legend(label(1 "observed") label(2 "imputed")); ///
   set more on; more; set more off

It's safe to -generate- the "miss_x1" variable because Andy is using the -wide-
-mi- style.  I took the commands from the note on multiple-imputation
diagnostics, which includes other plots Andy might find useful.  The note is
available at

It is usual to check each imputed dataset separately.  I do not know of any
research on comparing the aggregate of the observed data to the aggregate of the
imputed values.

*   For searches and help try:

Andy Stoddart
Health Economist
Edinburgh Health Services Research Unit (HSRU)

Edinburgh Clinical Trials Unit (ECTU)
Room D34, Level 2
Outpatients Building
Western General Hospital
Edinburgh, EH4 2XU

Tel:  +44 (0)131 537 3867 (except Tuesdays)
      +44 (0)131 650 3230 (Tuesdays only)

The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index