Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

regressionImp

Regression Imputation


Description

Impute missing values based on a regression model.

Usage

regressionImp(
  formula,
  data,
  family = "AUTO",
  robust = FALSE,
  imp_var = TRUE,
  imp_suffix = "imp",
  mod_cat = FALSE
)

Arguments

formula

model formula to impute one variable

data

A data.frame containing the data

family

family argument for glm(). "AUTO" (the default) tries to choose automatically and is the only really tested option!!!

robust

TRUE/FALSE if robust regression should be used. See details.

imp_var

TRUE/FALSE if a TRUE/FALSE variables for each imputed variable should be created show the imputation status

imp_suffix

suffix used for TF imputation variables

mod_cat

TRUE/FALSE if TRUE for categorical variables the level with the highest prediction probability is selected, otherwise it is sampled according to the probabilities.

Details

lm() is used for family "normal" and glm() for all other families. (robust=TRUE: lmrob(), glmrob())

Value

the imputed data set.

Author(s)

Alexander Kowarik

References

A. Kowarik, M. Templ (2016) Imputation with R package VIM. Journal of Statistical Software, 74(7), 1-16.

See Also

Other imputation methods: hotdeck(), irmi(), kNN(), matchImpute(), rangerImpute()

Examples

data(sleep)
sleepImp1 <- regressionImp(Dream+NonD~BodyWgt+BrainWgt,data=sleep)
sleepImp2 <- regressionImp(Sleep+Gest+Span+Dream+NonD~BodyWgt+BrainWgt,data=sleep)

data(testdata)
imp_testdata1 <- regressionImp(b1+b2~x1+x2,data=testdata$wna)
imp_testdata3 <- regressionImp(x1~x2,data=testdata$wna,robust=TRUE)

VIM

Visualization and Imputation of Missing Values

v6.1.0
GPL (>= 2)
Authors
Matthias Templ [aut, cre], Alexander Kowarik [aut] (<https://orcid.org/0000-0001-8598-4130>), Andreas Alfons [aut], Gregor de Cillia [aut], Bernd Prantner [ctb], Wolfgang Rannetbauer [aut]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.