clear
// Generate data
set obs 10000
generate e = rnormal()
drawnorm x1 x2, ///
corr(1, .4, 1) cstorage(lower)
generate y = 1 + 1 * x1 + 1 * x2 + 25 * e
drop e
// Model with data-generating process
eststo clear
eststo: regress y x1 x2
// Drop cases conditional on other covariate
replace x1 = . if rnormal() > .1 & x2 > -1
// Model with missing data
eststo: regress y x1 x2
// Impute data
mi set mlong // Declare data format
mi register imputed x1 // Declare variable to be imputed
mi impute chained (regress) x1 = y x2, add(10) // Declare imputation model
// Model with imputed data
eststo: mi estimate, post: regress y x1 x2 // post option is important for -esttab-
// Table
esttab, r2 se mtitles("DGP" "Missing data" "Imputed")
Aug 22, 2017
Multiple imputation in Stata
Labels:
esttab,
mi,
Multiple imputation,
Simulation