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

RE: st: Regressing with variables with missing values


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: Regressing with variables with missing values
Date   Sun, 6 Nov 2005 23:41:26 -0000

I repeat my profession of ignorance and my 
advice to study the syntax more carefully. 

I'd also get hold of Patrick's articles. 

Nick 
n.j.cox@durham.ac.uk 

Ramani Gunatilaka
 
> Nick,
> Thanks, that worked. I should say, though, that I have several
> variables with missing values and I tried ice with all of them and it
> didn't work, so then I tried with just one.
> See, this is what happens:
> 
> . /*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
> 
> 
> Would you have any ideas about what's going wrong? I'd be 
> very grateful.
> Thanks so much,
> Ramani
> 
> On 07/11/05, Nick Cox <n.j.cox@durham.ac.uk> wrote:
> > I've not used -ice- myself: I just recommend it!
> >
> > However, a quick glance suggests that you
> > are misunderstanding the syntax. It may be
> > that what you want is something more like
> >
> > uvis regress happy ln_pcy02 r_health male divorced widowed,
> > gen(HAPPY)
> >
> > Nick
> > n.j.cox@durham.ac.uk
> >
> > Ramani Gunatilaka
> >
> > > I have been following up on all the useful comments I got and have
> > > been working on that ice thing to replace missing values.
> > > Unfortunately the programme goes through the motions but doesn't
> > > replace any missing values. I am at my wit's end. The dependent
> > > variable and the one that has missing values is happy 
> (which takes the
> > > values 1-5 depending on level of happiness (the data set 
> as a whole
> > > has 6805 observations), and my code runs like this.
> > >
> > > use uphvar02, clear
> > >
> > > . ice happy ln_pcy02 r_health male divorced widowed using 
> uricevar02,
> > > cmd(regress) eq(happy: ln_pcy02 r _health male divorced widowed)
> > > genmiss(M1) id(flag1) replace
> > >
> > > This is my output:
> > >
> > >     Variable | Command     | Prediction equation
> > > -------------+-------------+----------------------------------
> > > ----------------
> > >        happy | regress     | ln_pcy02 r_health male 
> divorced widowed
> > >     ln_pcy02 | regress     | [No missing data in 
> estimation sample]
> > >     r_health | regress     | [No missing data in 
> estimation sample]
> > >         male | regress     | [No missing data in 
> estimation sample]
> > >     divorced | regress     | [No missing data in 
> estimation sample]
> > >      widowed | regress     | [No missing data in 
> estimation sample]
> > >
> > > Imputing
> > > [Only 1 variable to be imputed, therefore no cycling needed.]
> > > 1..file uricevar02.dta saved
> > >
> > > . sort city province hhid
> > >
> > > . compress
> > >
> > > . save uricevar02, replace
> > > file uricevar02.dta saved.
> > > end of do-file
> > >
> > > But when I check - here's what I get. Missing values still there.
> > >
> > > . count if happy==.
> > >    65
> > >
> > > Does anybody have any ideas as to what might be going wrong?

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index