2
$\begingroup$

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.

$\endgroup$
0
$\begingroup$

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
install.packages("mice")
library("mice")

# 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")
$\endgroup$

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.