I have data similar too the simplified example below:

RecID| Speed | Accuracy | Weight |
1    |  25   |   10     |  NA   
2    |  30   |    8     |  NA
3    |  15   |   10     |  NA
4    |  16   |   10     |  165
5    |  87   |    4     |  120
6    |  10   |   10     |  200

Basically, I want to fill in missing values for the Weight feature, which is a feature we didn't start collecting until after Rec 3. What are good ways to go back and fill in or handle missing data on features that weren't collected in the beginning? It's not time series data and a missing value for Weight isn't indicative of anything; all those records should have some value for Weight it just wasn't collected.

My approach right now is to either use some interpolation methods to fill in the missing values (if I do that are there any ways to check how good the interpolated values are?) or only do analysis on data I have the complete set for (which would significantly cut down on the size of the data set).

I understand that every data set is different but just wanted to get an idea of what other people think or have done for similar problems.


2 Answers 2


Imputation is one of the standard approaches to deal with missing values. In the following, you can find an example how to perform imputation in R.

# Example data
RecID <- 1:6
Speed <- c(25, 30, 15, 16, 87, 10)
Accuracy <- c(10, 8, 10, 10, 4, 10)
Weight <- c(NA, NA, NA, 165, 120, 200)
data <- data.frame(RecID, Speed, Accuracy, Weight)

# Install and load mice package

# Single imputation
imp <- mice(data, m = 1)
data_imp <- complete(imp)

Single imputation replaces your missing values once. However, it is usually preferable to use multiple imputation, since multiple imputation accounts for the uncertainty of imputed values and therefore provides better variance estimates.

# Multiple imputation
imp_multi <- mice(data)
data_imp_multi <- complete(imp_multi, action = "repeated")

Broadly, there are three types of method for dealing with missing data: model-based imputation, donor imputation, and scalar imputation.

Scalar imputation is the simplest method, but doesn't always make sense. It involves replacing the missing values with a single value, such as zero or the mean/median of the column.

Donor imputation involves replacing missing values with values from other "donor" rows. There are different methods for selecting the donor - e.g. k nearest neighbours is often used to select donors with similar characteristics.

In model-based imputation we assume a relationship between the missing variable and other variables in the data, and try to model the missing variable using prediction methods - e.g. regression or random forest.

The R package simputation contains various different methods and implementations of all three broad approaches.

Note that some machine learning algorithms can manage missing values without needing to impute e.g. gradient boosted trees.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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