Below is my code for running multiple imputation on a longitudinal dataset in the wide format (I first created 'missing_' variables to indicate the proportion missing each variable for some analysis post imputation comparing un-imputed with imputed data):
Code:
gen missing = missing(peducation, incomeq3, sclass, birthwt, ethnic8cat, sex, bmi3, bmi5, bmi7, bmi11, bmi14, bmi17, sdqemo3, sdqemo5, sdqemo7, sdqemo11, sdqemo14, sdqemo17)
// Missingness indicators for individual variables
foreach var of varlist mcsid2 peducation incomeq3 sclass birthwt ethnic8cat sex bmi3 bmi5 bmi7 bmi11 bmi14 bmi17 sdqemo3 sdqemo5 sdqemo7 sdqemo11 sdqemo14 sdqemo17 {
gen missing_`var' = missing(`var')
}
mi set wide
mi misstable summarize mcsid2 peducation incomeq3 sclass birthwt ethnic8cat sex bmi3 bmi5 bmi7 bmi11 bmi14 bmi17 sdqemo3 sdqemo5 sdqemo7 sdqemo11 sdqemo14 sdqemo17
pwcorr mcsid2 peducation incomeq3 sclass birthwt ethnic8cat sex bmi3 bmi5 bmi7 bmi11 bmi14 bmi17 sdqemo3 sdqemo5 sdqemo7 sdqemo11 sdqemo14 sdqemo17
mi register imputed peducation sclass incomeq3 birthwt bmi3 bmi5 bmi7 bmi11 bmi14 bmi17 sdqemo3 sdqemo5 sdqemo7 sdqemo11 sdqemo14 sdqemo17
mi impute chained (mlogit) peducation sclass (ologit) incomeq3 (regress) bmi3 bmi5 bmi7 bmi11 bmi14 bmi17 sdqemo3 sdqemo5 sdqemo7 sdqemo11 sdqemo14 sdqemo17 birthwt = ethnic8cat sex, add(30) rseed (53421) augment dots
save "dataset_waves 2-7_2020 Imputed.dta", replaceThe imputation ran well, and I'm happy with the results. I get 30 sets of imputed variables (with the numerical prefix _1_ _5_ _25_ and so on). However, I assume Stata should always generate 3 variables associated with imputation: _mi_m, _mi_id & _mi_miss. Of these 3, only _mi_miss was generated but not the other two. Is it because of something in my code?
I find the _mi_m variable useful if I want to restrict regression to just one imputed set for example when running margins.
Many Thanks
/Amal
0 Response to _mi_m & _mi_id not generated
Post a Comment