# Logic of keeping the missing data there but adding a new variable indicates if an entry of the previous column is a missing value

When dealing with real world data, we often see some of the columns have missing values. I frequently see that people using the following way to deal with missing values.

Assume column Z has 50% of NaNs, then they just leave those NaNs there and add a new column denoted by Z_indicator which contains only 0 and 1 such that for the entry in column Z with NaN, then the corresponding entry in Z_indicator is 1 and if the entry in column Z is not NaN, then the corresponding entry in Z_indicator is 0.

I don't understand why this way of dealing with missing value is "better" than other ways? Is there any theoretically justification for that?

• Schafer, J. L. (1999). Multiple imputation: a primer. Statistical Methods in Medical Research, 8:3–15. – Alexis Apr 15 '17 at 4:46
• @KevinKim You have to clarify how this data matrix is used. I presume the columns are your predictors that feed into a model to explain some response, correct? – horaceT Apr 15 '17 at 19:18
• @horaceT That's right. – KevinKim Apr 15 '17 at 22:13

data$variablename[is.na(data$variable)]<-mean(data\$variablename,na.rm=T)