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]

Re: Re: st: Multiple imputation: conditional option using categorical variables


From   A Loumiotis <[email protected]>
To   [email protected]
Subject   Re: Re: st: Multiple imputation: conditional option using categorical variables
Date   Wed, 2 Oct 2013 12:17:05 +0300

Dear Martijn,

I understand your hesitation but besides the problem that you
mentioned there is another problem that arise from the setting that
you describe.  I don't see how you can force marstat_time1 to be
imputed to 1 or 2 (and not 3) if marstat_time1 is missing and
marstat_time2 is 2.     So even if -ice- did not produce the error
that you described you would like to make -ice- select ranges from
which it imputes the values of marsta_time1 to depend on the value of
marsta_time2.  I'm not sure if this is possible.  So I think you have
to tackle this complication first.

Best regards,
Antonis



On Tue, Oct 1, 2013 at 6:24 PM, Hogerbrugge, M.J.A. (Martijn)
<[email protected]> wrote:
> Dear Antonis,
>
> Thank you for your reply. Your code does work. However, it also requires deleting information. To use my example of marital status over time, the code would look like:
>
> .replace marstat_time2 = 0 if inlist(marstat_time1,2,3)
> .replace marstat_time2 = . if marstat_time1 == .
> .ice m.marstat_time1 m.marstat_time2 age gender education, cond(marstat_time2: inlist(marstat_time1,1,.))
>
> Thus, I have to delete information about the marital status at the later [in this case, second] moment of observation before running the ice command, whereas I actually want to retain this information.
>
> I hope you understand my hesitation for implementing your solution. Would you know of any ways how to use the conditional option, without the need to add additional missings to the data?
>
> Looking forward to your response.
> ~Martijn
>
>>Hi Martijn,
>>
>>No, it still works but as I noted in my previous message you have to
>>make sure that you set price to the pre-determined value whenever the
>>condition does not hold.  In this case you have to set price to zero
>>whenever inlist(rep78,2,3) before running -ice-.  Here is the modified
>>code:
>>
>>*** Example starts
>>sysuse auto, clear
>>set seed 12345678
>>replace rep78=. if runiform()<.1
>>replace price=. if runiform()<.1
>>replace price=0 if inlist(rep78,2,3)
>>replace price=. if rep78==.
>>ice m.rep78 price mpg, cond(price:inlist(rep78,1,4,5)) saving(catexam,replace)
>>use catexam, clear
>>sort _mi _mj
>>browse
>>*** Example ends
>>
>>Hope this helps,
>>Antonis
>>
>>On Mon, Sep 30, 2013 at 5:47 PM, Hogerbrugge, M.J.A. (Martijn)
>><[email protected]> wrote:
>>> Dear Antonis,
>>>
>>> The following error is returned by -ice-:
>>>
>>> Imputing Error: variable marstat_time2 has >1 value outside subgroup inlist(marstat_time1,1,.)
>>> r(499);
>>>
>>> In your example, the error would also show up if you change the condition from inlist(rep78,1,2,4,5) into inlist(rep78,1,4,5), for example.
>>> Do you have any idea how to work around this issue?
>>>
>>> Kind regards,
>>> Martijn
>>>
>>>
>>>>What exactly is the error that -ice- returns?  Could you please
>>>>specify the complete -ice- command that returns that error that you
>>>>mentioned?
>>>>
>>>>Here is a nonsensical example that works.  In this example price is
>>>>only answered if categorical variable rep78 is not equal to 3.  Not
>>>>that I set price to missing whenever rep78 is missing and equal to
>>>>zero (pre-determined value) whenever rep78 is equal to 3.
>>>>
>>>>*** Example starts
>>>>sysuse auto, clear
>>>>set seed 12345678
>>>>replace rep78=. if runiform()<.1
>>>>replace price=. if runiform()<.1
>>>>replace price=0 if rep78==3
>>>>replace price=. if rep78==.
>>>>ice m.rep78 price mpg, cond(price:inlist(rep78,1,2,4,5)) saving(catexam,replace)
>>>>use catexam, clear
>>>>sort _mi _mj
>>>>browse
>>>>*** Example ends
>>>>
>>>>As you can see whenever rep78 is imputed to 3, -ice- automatically
>>>>assigns to price the pre-determined value of 0.
>>>>
>>>>Going back to my November 2010 unanswered post about the conditional
>>>>option and categorical variables it is clear now to me that the first
>>>>specification is the appropriate one. Thanks for reminding me about
>>>>this post.  I will try to find it and bring a closure to it.
>>>>
>>>>-ice- is a user written program that can be found at
>>>>http://www.ucl.ac.uk/~ucakjpr/.
>>>>
>>>>Best,
>>>>Antonis
>>>>
>>>>On Sat, Sep 28, 2013 at 1:29 PM, Hogerbrugge, M.J.A. (Martijn)
>>>><[email protected]> wrote:
>>>>> Dear Stata users,
>>>>>
>>>>> Does anybody know how to use the "conditional"-option for categorical variables in multiple imputation using >ICE?
>>>>>
>>>>> The help file only provides an example using a dichotomous conditional variable ("female"). In that case, >imputation on a particular variable is >only performed if the condition is met (for instance "female == 1"). If the >condition is false, a pre-determined value is imputed. To work correctly, >the cases for which the condition is false >need to have only one value on the variable that needs to be imputed. If more than one value is >observed, ICE >returns an error.
>>>>>
>>>>> In some instances, however, it is perfectly sensible to have multiple values in the variable to be imputed (for the >observations for which the >condition is false). Let me provide a quick example using the variable marital status:
>>>>> - the categories for marital status are [1] "married", [2] "divorced", and [3] "widowed"
>>>>> - marital status is observed at multiple time points
>>>>> - once a person is divorced or widowed, he or she remains so for the remainder of the observation points
>>>>> - the ICE command will look like this:
>>>>>
>>>>> .conditional(marstat_time2: if inlist(marstat_time1,1,.))
>>>>> .conditional(marstat_time3: if inlist(marstat_time2,1,.))
>>>>> .conditional(marstat_time4: if inlist(marstat_time3,1,.))
>>>>>
>>>>> and so on.
>>>>>
>>>>> Thus, marital status at a later time point is not imputed if the case was either divorced or widowed at the >previous time point (i.e., not >married [1] or missing [.]).
>>>>>
>>>>> Unfortunately, ICE returns an error for the reason described earlier. Is there some way to be able to do this kind >of conditional imputation >nonetheless? I tried looking for previous posts on a similar issue, and found one >(http://www.stata.com/statalist/archive/2010->11/msg00708.html), but this post seems to be never been answered.
>>>>>
>>>>> BTW, I also looked into Stata's own imputation command (MI impute), but the conditional option is implimented >in a similar way, and >switching commands seems not to be a way to overcome this problem.
>>>>>
>>>>> Looking forward to your responses and help.
>>>>> ~Martijn Hogerbrugge
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/

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


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