1
$\begingroup$

How would one imputing missing values (without using the mode) for a discrete variable, e.g. a variable corresponding to a count.

$\endgroup$

2 Answers 2

1
$\begingroup$

Apart from the methods @Media mentioned, here are some more:

Imputing with info from other variables

This method is to create a (multi-class) model based on target variable. So that missing values would be predicted.

The steps are likely to be:

  • Subset data without missing value in the variable you want to impute
  • Machine learning on the data with predict model
  • Predict on data with the missing value from model created

Clustering

Whether missing values are mainly related to a combination of variables? Unsupervised methods may help here.

An example using randomForest: https://stats.stackexchange.com/questions/107530/using-cluster-information-in-multiple-imputation

Domain Knowledge

If we known that the reason for missing value, we can assign the missing value to a proper level. For example, a survey data are collected from web where given choices are not applicable for some cases, hence leave blank. In this case, it would be better to leave as a separate value.

Implementation

There are some R package can impute the data for you;

  • MICE
  • Amelia
  • missForest
  • Hmisc
  • mi

https://www.analyticsvidhya.com/blog/2016/03/tutorial-powerful-packages-imputing-missing-values/

$\endgroup$
2
  • $\begingroup$ This method is to create a (multi-class) model based on target variable. So that missing values would be predicted. Could you elaborate on this further ? Whether missing values are mainly related to a combination of variables? Unsupervised methods may help here. could you give an example of an unsupervised method, and the way to which it would be used to impute values ? Thanks. $\endgroup$
    – Gale
    Mar 1, 2018 at 11:18
  • $\begingroup$ @Gala, answer edited per comment. $\endgroup$
    – Sixiang.Hu
    Mar 1, 2018 at 15:14
1
$\begingroup$

It depends, if you have the distribution of that feature, you can take the marginal distribution over that feature which its interpretation is to use the expected value of that feature. If you don't have the distribution you can take the mean of the sample in hand of those samples which have value for that feature and add the mean for those which don't have. Another solution is to separate the data of each class and find the mean of the feature of those data samples having the value and putting the mean for each entry of the corresponding class which does not have value in that entry.

$\endgroup$
4
  • $\begingroup$ ` If you don't have the distribution you can take the mean of the sample in hand of those samples which have value for that feature and add the mean for those which don't have.` Sorry, not quit following on what you mean by this. Can you reiterate ? Also, since it is a discrete variable, would imputing using the mean be a valid approach, given the values of the feature are integers ? Thanks $\endgroup$
    – Gale
    Mar 1, 2018 at 11:53
  • $\begingroup$ @Gale I've seen your comment late. Do you still have problem? $\endgroup$ Mar 2, 2018 at 13:30
  • $\begingroup$ Just wanted to have a better understanding of your response :-) $\endgroup$
    – Gale
    Mar 2, 2018 at 14:14
  • $\begingroup$ The problem of discrete value can be solved by just finding the nearest integer value. When you are speaking about a sample, you can find the statics of the sample. Mean and expected value are different. Whenever you have the distribution, you can find the exact value of the mean of the population. But in real world you just have sample. For sample you take the average of the features that can be measured and by using some methods you extend them to the entire population. Tell me if you need more explanation. $\endgroup$ Mar 2, 2018 at 14:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.