Impute using a previously fitted model.
Impute one or more variables using a single R object representing a previously fitted model.
impute(dat, formula, predictor = foretell, ...) impute_(dat, variables, model, predictor = foretell, ...)
dat |
|
formula |
|
predictor |
|
... |
Extra arguments passed to |
variables |
|
model |
A model object. |
Formulas are of the form
IMPUTED_VARIABLES ~ MODEL_OBJECT
The left-hand-side of the formula object lists the variable or variables to
be imputed. The right-hand-side must be a model object for which an S3
predict
method is implemented. Alternatively, one can specify a custom
predicting function. This function must accept at least a model and a
dataset, and return one predicted value for each row in the dataset.
foretell
implements usefull predict
methods for cases
where by default the predicted output is not of the same type as the predicted
variable (e.g. when using certain link functions in glm
)
impute_
is an explicit version of impute
that works better in
programming contexts, especially in cases involving nonstandard evaluation.
Other imputation:
impute_cart()
,
impute_hotdeck
,
impute_lm()
irisNA <- iris iris[1:3,1] <- NA my_model <- lm(Sepal.Length ~ Sepal.Width + Species, data=iris) impute(irisNA, Sepal.Length ~ my_model)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.