Learn R Programming

VIM (version 7.3.0)

with.vimmi: Evaluate an expression across all imputations

Description

Applies an expression (typically a model fit) to each completed dataset in a vimmi object. The return is a mice-compatible mira object (elements call, call1, nmis, analyses), so the standard mice pipeline runs unchanged: mice::pool(), summary(mice::pool(fits)), mice::getfit(fits). The mice package is not needed to create the object, only to pool it; for mitools::MIcombine() pass the fit list fits$analyses.

Usage

# S3 method for vimmi
with(data, expr, ...)

Value

An object of class mira: the m results are in $analyses (extract with mice::getfit())

Arguments

data

A vimmi object

expr

An expression to evaluate, e.g. lm(y ~ x)

...

Currently unused

Examples

Run this code
if (FALSE) {
result <- vimpute(sleep, method = "ranger", m = 5, boot = TRUE, uncert = "normalerror")
fits <- with(result, lm(Sleep ~ Dream + Span))
# Pool with mice:
# mice::pool(fits)
}

Run the code above in your browser using DataLab