Hello,
I am using mi impute pmm command and I have a question regarding nearest neighbor matching.
I want to fill in the missing data with the observation from one nearest neighbor, hence using the knn(1) option.
However I have noticed that my outcomes vary each time I run the code, and I don't quite understand why there is randomness to the imputed values when I am almost certain that there must be only one observation with the nearest predicted value.
Any help/advice would be very much appreciated.


Code:
foreach y in 2013 2014 2015 2016 2017 2018 2019{  
use "data.dta",clear
keep if year==`y'|year==`y'+1
mi set fl
mi register imputed lnhw
mi xtset pid year
mi impute pmm lnhw lnimphw age edudum1 edudum2 edudum3 marital_simp head i.jobhourt i.jobkind_simp i.jobarea_simp i.wsize regular sex region i.howwage if year==`y', replace knn(1) by(year) add(1) force
save "impute_`y'.dta",replace
}