bwplot produces box-and-whisker plots. The function
automatically separates the observed and imputed data. The
functions extend the usual features of ## S3 method for class 'mids':
bwplot(x, data, na.groups = NULL, groups = NULL,
as.table = TRUE, theme = mice.theme(), mayreplicate = TRUE,
allow.multiple = TRUE, outer = TRUE,
drop.unused.levels = lattice.getOption("drop.unused.levels"), ...,
subscripts = TRUE, subset = TRUE)mids object, typically created by
mice() or mice.mids().is.na(x$data).
groups arguments
in na.groups
because it evaluates in the completed data
data.frame(complete(x, "long", inc=TRUE)) (as
usual), whereas na.groupsmice.theme
produces a short list of default colors, line width, and
so on. The extensive list may be obtained from
trellis.par.get(). Global graphicalxyplot.xyplot.xyplot.xyplot.xyplot.xyplot."trellis". The
update method can be
used to subsequently update components of the object, and
the print method
(usually called by default) will plot it on an appropriate
plotting device.na.groups may be used to specify
(combinations of) missingness in any of the variables. The
argument groups can be used to specify groups based
on the variable values themselves. Only one of both may be
active at the same time. When both are specified,
na.groups takes precedence over groups.Use the subset and na.groups together to
plots parts of the data. For example, select the first
imputed data set by by subset=.imp==1.
Graphical paramaters like col, pch and
cex can be specified in the arguments list to alter
the plotting symbols. If length(col)==2, the color
specification to define the observed and missing groups.
col[1] is the color of the 'observed' data,
col[2] is the color of the missing or imputed data.
A convenient color choice is col=mdc(1:2), a
transparent blue color for the observed data, and a
transparent red color for the imputed data. A good choice
is col=mdc(1:2), pch=20, cex=1.5. These choices can
be set for the duration of the session by running
mice.theme().
van Buuren S and Groothuis-Oudshoorn K (2011). mice:
Multivariate Imputation by Chained Equations in R.
Journal of Statistical Software, 45(3), 1-67.
mice, xyplot,
densityplot, stripplot,
Lattice for an overview of the package, as
well as bwplot,
panel.bwplot,
print.trellis,
trellis.par.setrequire(lattice)
imp <- mice(boys, maxit=1)
### box-and-whisker plot per imputation of all numerical variables
bwplot(imp)
### tv (testicular volume), conditional on region
bwplot(imp, tv~.imp|reg)
### same data, organized in a different way
bwplot(imp, tv~reg|.imp, theme=list())Run the code above in your browser using DataLab