[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

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

From   Maarten buis <>
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 <> 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. 

Notice that -ice- is easier to use, and more general, so I would use
-ice- instead of trying to adapt this code to your problem.

-- 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
	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 )

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

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

Not happy with your email address?.
Get the one you really want - millions of new email addresses available now at Yahoo!
*   For searches and help try:

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