with.vimmi: Evaluate an expression across all imputations

View source: R/vimmi.R

with.vimmiR Documentation

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 class 'vimmi'
with(data, expr, ...)

Arguments

data

A vimmi object

expr

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

...

Currently unused

Value

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

Examples

## Not run: 
result <- vimpute(sleep, method = "ranger", m = 5, boot = TRUE, uncert = "normalerror")
fits <- with(result, lm(Sleep ~ Dream + Span))
# Pool with mice:
# mice::pool(fits)

## End(Not run)

VIM documentation built on Sept. 2, 2026, 5:07 p.m.