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

# Re: st: twoway graph for imututed values against observed

 From Andrew Stoddart To statalist@hsphsun2.harvard.edu 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.

Andy

```
Quoting "Wesley D. Eddings, StataCorp" <weddings@stata.com> on Wed, 25 Jan 2012 17:40:44 -0600:
```
```
```Andy Stoddart (andrew.stoddart@ed.ac.uk) 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
```imputations:

. 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

http://www.stata.com/users/ymarchenko/midiagnote.pdf

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.

--Wes
weddings@stata.com
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

```
```

Andy Stoddart
Health Economist
Edinburgh Health Services Research Unit (HSRU)
www.hsru.ed.ac.uk

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:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```