Bookmark and Share

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


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

st: ICE and two conditions


From   Morten Frydenberg <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: ICE and two conditions
Date   Tue, 29 Nov 2011 14:40:17 +0100

Dear all
I am using ICE  (SJ9-3:st0067_4) and Stata 12 to impute misisng values.
Some of my subjects die during the study.
 I do not want to impute values for these subject after they have died.

In ICE the option "conditon" such help me to do this.
But when I include two conditions then ICE 
1. impute values that should not be imputed.
2. and these values are identical to other imputed values
The program below ilustratesmy problem.
Hope you can help
Morten

*****************program start**************************
clear
* generate data set with 6 non-complete 
* and 94 complete observations

set obs 100
set seed 20111110
generate id=_n
generate y =rnormal()
generate x1=rnormal()
generate x2=rnormal()

generate dead_at=2
replace  dead_at=0 if id==1
replace  dead_at=1 if id==2|id==3

replace x1=. if inlist(id,1,2  ,4,5  )
replace x2=. if inlist(id,1,2,3,4,5,6)

* list of the six non-complete observations and one complete
list  if id <=7
misstable patterns,freq

* imputing 
* x1 only imputed if dead_at>=1
ice x1 x2 y ,m(3) clear seed(1234) ///
          condition(   x1: dead_at>=1 ) 
mi import ice,clear auto
sort id _mi_m 
* checking everything ok
list  if id <=7,sepby(id)
* it is!

mi unset
keep if mi_m==0
drop m*
* imputing 
* x1 only imputed if dead_at>=1
* x2 only imputed if dead_at>=2

ice x1 x2 y ,m(3) clear seed(1234) ///
     condition(   x1: dead_at>=1 \  x2: dead_at>=2  )  
mi import ice,clear auto
sort id _mi_m 
* checking everything ok
list  if id <=7,sepby(id)
* Why is x1 imputed id==1?
* Why are these imputed values identical to 
* those of id==2?
*********************Program end*************************

---------------------------------------------------------- 
Morten Frydenberg              Department of Biostatistics 
Associate professor            Aarhus University 
[email protected]           Bartholins Allé 2 
Phone +45 871  67992           8000 Aarhus 
Fax   +45 871  67305           Denmark 
 
 

*
*   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/


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