Answers "is my imputation model well calibrated?" without ground truth
(the analogue of Amelia::overimpute(), model-agnostic): the
observed cells of one variable are treated as missing -- fold by
fold, so every observed cell is overimputed exactly once -- and imputed
with draws multiple imputations via vimpute(). For each cell the
observed value is compared with the mean and a level interval of
its draws; a well-calibrated model covers roughly level of the
observed values. Any genuinely missing cells stay missing and are imputed
as part of the model, exactly as they would be in a real run.
overimpute(data, variable, ..., draws = 5, folds = 5, level = 0.9, seed = NULL)# S3 method for vimpute_overimpute
print(x, ...)
# S3 method for vimpute_overimpute
plot(x, ...)
A data.frame of class vimpute_overimpute with one row per
observed cell: row (row index in data), observed,
mean, lower, upper (quantiles of the draws at
level), and covered. Attributes: variable,
level, draws, folds. print() reports the
empirical coverage; plot() draws the observed-vs-imputed
calibration plot with intervals and the 45-degree line.
Dataset with (possibly) missing values.
Single column name: the numeric variable whose observed cells are overimputed.
Passed on to vimpute() (e.g. method, spec, uncert,
sequential). m is controlled via draws and cannot be supplied.
Number of multiple-imputation draws per cell (>= 2).
Number of folds the observed cells are split into (each fold
is set missing and overimputed in one vimpute() run; capped at the
number of observed cells).
Coverage level of the reported interval (default 0.9).
Optional single number: applied via set.seed() before
the fold split and the imputation runs.
A vimpute_overimpute object
Matthias Templ
The ... arguments are passed on to vimpute(), so the diagnostic runs
for any method, spec, or grammar configuration -- e.g.
overimpute(dat, "y", method = "robust") or
overimpute(dat, "y", spec = list(y = vs_ranger(num.trees = 300))).
Note the cost: folds x draws imputation runs; lower folds and
draws (the defaults are modest) or use a fast method for large data.
For a stochastic spread of the draws keep an uncertainty source switched
on (the default uncert = "pmm", or boot/uncert); with purely
deterministic settings all draws coincide and the intervals collapse.
vimpute(), makeMissing(), evaluation()
if (FALSE) {
data(sleep)
ov <- overimpute(sleep, "Sleep", method = "robust", sequential = FALSE,
draws = 5, folds = 5, seed = 1)
print(ov) # empirical coverage of the 90% intervals
plot(ov)
}
Run the code above in your browser using DataLab