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: st: Subgroup mean imputation
From
Barbara Romano <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: Subgroup mean imputation
Date
Sun, 17 Nov 2013 12:13:01 +0100
Thank you very much!.
It works.
Barbara
>
>
>
>
> Il giorno 16/nov/2013, alle ore 10:52, Nick Cox <[email protected]> ha scritto:
>
>> Given
>>
>> egen classmean = mean(score), by(CODICE_CLASSE)
>>
>> then (1)
>>
>> clonevar score2 = score
>> replace score2 = classmean if missing(score)
>>
>> or (2)
>>
>> gen score2 = cond(missing(score), classmean, score)
>>
>> It's good practice to keep your original variable unchanged. In (2)
>> use -double- or -long- if -score- is -double- or -long-.
>>
>> Nick
>> [email protected]
>>
>> Barbara Romano
>>
>>> Thanks Fernando,
>>> unfortunately it’s not working. I’m stuck with my missing .
>>> I never used looping, but do you think a loop could be a solution?
>>> Something that says stata for each missing in the variable classmean impute the value of classmean of another observation with the same classroom_id…
>>
>> Fernando Rios Avila
>>
>>>> What I usually do is to add the following command to what you already have:
>>>> egen classmean_imputed = max(classmean), by(CODICE_CLASSE)
>>
>> Barbara Romano
>>
>>>>> I’d like to contrast the results I get the mi imputation and the old fashioned mean imputation.
>>>>> I’ve a huge dataset of student test scores with a variable for classroom id.
>>>>>
>>>>> I used the egen command to create the subgroup mean for each classroom
>>>>> egen classmean = mean(score), by(CODICE_CLASSE)
>>>>>
>>>>> this create for each student with the same classroom code, BUT for the the students with a missing value for the score.
>>>>> I’d like to impute that classroom subgroup mean for the “missing students”.
>>
>> *
>> * 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/