# Re: st: RE: st: RE: st: correction of some data by age group and for years:

 From Maarten buis To statalist@hsphsun2.harvard.edu Subject Re: st: RE: st: RE: st: correction of some data by age group and for years: Date Mon, 4 Aug 2008 20:55:23 +0100 (BST)

```--- carmen gamarra <carmengamarra@hotmail.com> wrote:
> Now I wonder: could you help me in relation to commands in STATA to
> make a sensible multiple imputation models? I did the corrections
> using excel, but I'd like to use the STATA? I actually I just like to
> know the commands that I use in STATA.

Below is an example that will create a multiply imputed dataset that
can be used by -mim-, see -findit mim-. I use -bsample- to make sure
that the proportions I use are sampled from the sampling distribution
of the proportions, in order to create what Rubin termed `proper'
imputations. The use of -uniform()- is discussed in M.L. Buis (2007),
"Stata tip 48: Discrete uses for uniform()", The Stata Journal, 7(3),
pp. 434-435. http://home.fsw.vu.nl/m.buis/wp/discrete.html

Notice that -ice- is easier to use, and more general, so I would use

-- Maarten

*------------------ begin example --------------------
tempfile imp base
sysuse nlsw88, clear
replace married = 2 if uniform() < .25
label define marlbl 2 "unknown", add
label value married marlbl
gen long _mi = _n
gen byte _mj = 0
save `imp'
save `base'

forvalues i = 1/5 {
use `base', clear
bsample
drop if married == 2
gen pr1 = married == 1
collapse (mean) pr1, by(age)
sort age
tempfile pr
save `pr'

use `base', clear
sort age
merge age using `pr'
replace married = uniform() < pr1 if married == 2
replace _mj = `i'
drop pr1 _merge
append using `imp'
save `imp', replace
}
use `imp', clear
sort _mj _mi
*------------------------ end example ---------------------
(For more on how to use examples I sent to the Statalist, see
http://home.fsw.vu.nl/m.buis/stata/exampleFAQ.html )

-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------

__________________________________________________________