with.mids: Evaluate an expression in multiple imputed datasets

Description Usage Arguments Value Note Author(s) References See Also Examples

View source: R/with.R

Description

Performs a computation of each of imputed datasets in data.

Usage

1
2
## S3 method for class 'mids'
with(data, expr, ...)

Arguments

data

An object of type mids, which stands for 'multiply imputed data set', typically created by a call to function mice().

expr

An expression to evaluate for each imputed data set. Formula's containing a dot (notation for "all other variables") do not work.

...

Not used

Value

An object of S3 class mira

Note

Version 3.11.10 changed to tidy evaluation on a quosure. This change should not affect any code that worked on previous versions.

Author(s)

Karin Oudshoorn, Stef van Buuren 2009, 2012, 2020

References

van Buuren S and Groothuis-Oudshoorn K (2011). mice: Multivariate Imputation by Chained Equations in R. Journal of Statistical Software, 45(3), 1-67. https://www.jstatsoft.org/v45/i03/

See Also

mids, mira, pool, D1, D3, pool.r.squared

Examples

1
2
3
4
5
6
7
8
9
imp <- mice(nhanes2, m = 2, print = FALSE, seed = 14221)

# descriptive statistics
getfit(with(imp, table(hyp, age)))

# model fitting and testing
fit1 <- with(imp, lm(bmi ~ age + hyp + chl))
fit2 <- with(imp, glm(hyp ~ age + chl, family = binomial))
fit3 <- with(imp, anova(lm(bmi ~ age + chl)))

Example output

Loading required package: lattice

Attaching package: 'mice'

The following objects are masked from 'package:base':

    cbind, rbind

Component 1 :
     age
hyp   20-39 40-59 60-99
  no     12     5     4
  yes     0     2     2

Component 2 :
     age
hyp   20-39 40-59 60-99
  no     11     4     3
  yes     1     3     3

mice documentation built on Nov. 14, 2020, 5:07 p.m.

Related to with.mids in mice...