Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Thanks - Ice and variables with missing values


From   Ramani Gunatilaka <[email protected]>
To   [email protected]
Subject   st: Thanks - Ice and variables with missing values
Date   Mon, 14 Nov 2005 09:46:35 +1100

Hi all,
This is to end this thread on a postive note. After nearly a week of
struggle and reading up more about MICE,  I discovered the stupid
mistake I had made.
This was my code:

***************************
. /*MICE to impute missing values*/
. use uphvar02, clear

. ice incdisCh incdisCity indy02 workhrs happy r_health edyrs ln_pcy02
ln_avcityy city province male di
> vorced widowed finassets hhdebt using uricevar02, eq(incdisCh: indy02 ln_pcy02 ln_avcityy city provin
> ce finassets hhdebt, incdisCity: indy02 ln_pcy02 ln_avcityy city province finassets hhdebt, happy: ln
> _pcy02 r_health male divorced widowed) genmiss(M1) id(flag1) replace

   Variable | Command     | Prediction equation
-------------+-------------+--------------------------------------------------
   incdisCh | mlogit      | indy02 ln_pcy02 ln_avcityy city province
            |             | finassets hhdebt
 incdisCity | mlogit      | indy02 ln_pcy02 ln_avcityy city province
            |             | finassets hhdebt
     indy02 | regress     | incdisCh incdisCity workhrs happy r_health edyrs
            |             | ln_pcy02 ln_avcityy city province male divorced
            |             | widowed finassets hhdebt
    workhrs | regress     | incdisCh incdisCity indy02 happy r_health edyrs
            |             | ln_pcy02 ln_avcityy city province male divorced
            |             | widowed finassets hhdebt
      happy | mlogit      | ln_pcy02 r_health male divorced widowed
   r_health |             | [No missing data in estimation sample]
      edyrs |             | [No missing data in estimation sample]
   ln_pcy02 |             | [No missing data in estimation sample]
 ln_avcityy |             | [No missing data in estimation sample]
       city |             | [No missing data in estimation sample]
   province |             | [No missing data in estimation sample]
       male |             | [No missing data in estimation sample]
   divorced |             | [No missing data in estimation sample]
    widowed |             | [No missing data in estimation sample]
  finassets |             | [No missing data in estimation sample]
     hhdebt |             | [No missing data in estimation sample]

Imputing 1..file uricevar02.dta saved

. sort city province hhid

. compress

. save uricevar02, replace
file uricevar02.dta saved

.
.
end of do-file

. count if happy==.
  65

****************************
Now happy should not have had missing values if all had gone well.
The problem occured here -
Imputing 1..file uricevar02.dta saved

. sort city province hhid

. compress

. save uricevar02, replace
file uricevar02.dta saved


What Stata did was save the old file with missing values which was in
memory, as uricevar02, thereby overwriting the new dataset with the
values that Stata had painstakingly created!
How stupid can one be!
I should have added a line,
use urivevar02, clear

before the sort command.

Nice to have the problem solved at last, and a very big thank you to
all who helped me upgrade my Stata skills with ice!
Ramani

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index