impute {simputation} | R Documentation |
Impute using a previously fitted model.
Description
Impute one or more variables using a single R object representing a previously fitted model.
Usage
impute(dat, formula, predictor = foretell, ...)
impute_(dat, variables, model, predictor = foretell, ...)
Arguments
dat |
|
formula |
|
predictor |
|
... |
Extra arguments passed to |
variables |
|
model |
A model object. |
Model specification
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
)
Details
impute_
is an explicit version of impute
that works better in
programming contexts, especially in cases involving nonstandard evaluation.
See Also
Other imputation:
impute_cart()
,
impute_hotdeck
,
impute_lm()
Examples
irisNA <- iris
iris[1:3,1] <- NA
my_model <- lm(Sepal.Length ~ Sepal.Width + Species, data=iris)
impute(irisNA, Sepal.Length ~ my_model)