Simple Imputation (simputation)
https://cran.r-project.org/web/packages/simputation/simputation.pdf
# https://cran.r-project.org/web/packages/simputation/simputation.pdf dd <- as.data.table(iris) irisNA <- copy(dd) irisNA[1:3, 'Sepal.Length'] <- NA my_model <- lm(Sepal.Length ~ Sepal.Width + Species, data=dd) irisNA %>% impute(Sepal.Length ~ my_model)
# https://cran.r-project.org/web/packages/simputation/simputation.pdf data(iris) dd <- as.data.table(iris) irisNA <- copy(as.data.table(iris)) irisNA[1:4, "Sepal.Length"] <- NA irisNA[3:7, "Sepal.Width"] <- NA irisNA %>% head(10) irisNA %>% impute_lm(Sepal.Length ~ Sepal.Width + Species) # impute a single variable (Sepal.Length) irisNA %>% impute_rlm(Sepal.Length + Sepal.Width ~ Species + Petal.Length) # impute both Sepal.Length and Sepal.Width, using robust linear regression irisNA %>% impute_rlm(Sepal.Length + Sepal.Width ~ Species + Petal.Length + Petal.Width) irisNA %>% impute_median(Sepal.Length ~ Species) irisNA %>% impute_median(.-Species ~ Species) irisNA %>% impute_median(Sepal.Length+Sepal.Width+Petal.Length+Petal.Width ~ Species) # same above irisNA %>% impute_knn(Sepal.Length ~ Species, \t\t\t\t\t\tpool = c("complete", "univariate", "multivariate"), \t\t\t\t\t\tk = 5, \t\t\t\t\t\tbackend = getOption("simputation.hdbackend", default = c("simputation", "VIM"))) irisNA %>% impute_knn(Sepal.Length + Sepal.Width ~ Species, \t\t\t\t\t\tpool = c("complete", "univariate", "multivariate"), \t\t\t\t\t\tk = 5, \t\t\t\t\t\tbackend = getOption("simputation.hdbackend", default = c("simputation", "VIM")))