mids | R Documentation |
mids
)The mids
object is an S3 class that represents a multiply imputed
data set. The mids()
function is the S3 constructor.
The following functions produce a mids
object:
mids()
, mice()
, mice.mids()
,
cbind()
, rbind()
, ibind()
,
as.mids()
and filter()
.
mids(
data = data.frame(),
imp = list(),
m = integer(),
where = matrix,
blocks = list(),
call = match.call(),
nmis = integer(),
method = character(),
predictorMatrix = matrix(),
visitSequence = character(),
formulas = list(),
post = character(),
blots = list(),
ignore = logical(),
seed = integer(),
iteration = integer(),
lastSeedValue = tryCatch(get(".Random.seed", envir = globalenv(), mode = "integer",
inherits = FALSE), error = function(e) NULL),
chainMean = list(),
chainVar = list(),
loggedEvents = data.frame(),
version = packageVersion("mice"),
date = Sys.Date()
)
## S3 method for class 'mids'
plot(
x,
y = NULL,
theme = mice.theme(),
layout = c(2, 3),
type = "l",
col = 1:10,
lty = 1,
...
)
## S3 method for class 'mids'
print(x, ...)
## S3 method for class 'mids'
summary(object, ...)
data |
A data frame or a matrix containing the incomplete data. Missing
values are coded as |
imp |
Calculated field |
m |
Number of multiple imputations. The default is |
where |
A data frame or matrix with logicals of the same dimensions
as |
blocks |
List of vectors with variable names per block. List elements
may be named to identify blocks. Variables within a block are
imputed by a multivariate imputation method
(see |
call |
Calculated field |
nmis |
Calculated field |
method |
Can be either a single string, or a vector of strings with
length |
predictorMatrix |
A numeric matrix of |
visitSequence |
A vector of block names of arbitrary length, specifying the
sequence of blocks that are imputed during one iteration of the Gibbs
sampler. A block is a collection of variables. All variables that are
members of the same block are imputed
when the block is visited. A variable that is a member of multiple blocks
is re-imputed within the same iteration.
The default |
formulas |
A named list of formula's, or expressions that
can be converted into formula's by |
post |
A vector of strings with length |
blots |
A named |
ignore |
A logical vector of |
seed |
An integer that is used as argument by the |
iteration |
Calculated field |
lastSeedValue |
Calculated field |
chainMean |
Calculated field |
chainVar |
Calculated field |
loggedEvents |
Calculated field |
version |
Calculated field |
date |
Calculated field |
x |
An object of class |
y |
A formula that specifies which variables, stream and iterations are plotted. If omitted, all streams, variables and iterations are plotted. |
theme |
The trellis theme to applied to the graphs. The default is |
layout |
A vector of length 2 given the number of columns and rows in the plot.
The default is |
type |
Parameter |
col |
Parameter |
lty |
Parameter |
... |
Others arguments |
object |
Object of class |
The S3 class mids
has the following methods:
bwplot()
, complete()
,
densityplot()
, plot()
,
print()
, stripplot()
, summary()
,
with()
and xyplot()
.
mids()
returns a mids
object.
plot()
returns a xyplot
object.
print()
returns the input object invisibly.
summary()
returns the input object invisibly.
Objects of class "mids"
are lists with the following elements:
data
:Original (incomplete) data set.
imp
:A list of ncol(data)
components with
the generated multiple imputations. Each list component is a
data.frame
(nmis[j]
by m
) of imputed values
for variable j
. A NULL
component is used for
variables for which not imputations are generated.
m
:Number of imputations.
where
:The where
argument of the
mice()
function.
blocks
:The blocks
argument of the
mice()
function.
call
:Call that created the object.
nmis
:An Named vector with counts of missing values per variable
method
:A vector of strings of length(blocks
specifying the imputation method per block.
predictorMatrix
:A numerical matrix of containing integers specifying the predictor set.
visitSequence
:A vector of variable and block names that specifies how variables and blocks are visited in one iteration throuh the data.
formulas
:A named list of formula's, or expressions that
can be converted into formula's by as.formula
. List elements
correspond to blocks. The block to which the list element applies is
identified by its name, so list names must correspond to block names.
post
:A vector of strings of length length(blocks)
with commands for post-processing.
blots
:"Block dots". The blots
argument to the mice()
function.
ignore
:A logical vector of length nrow(data)
indicating
the rows in data
used to build the imputation model. (new in mice 3.12.0
)
seed
:The seed value of the solution.
iteration
:Last Gibbs sampling iteration number.
lastSeedValue
:Random number generator state.
chainMean
:An array of dimensions ncol
by
maxit
by m
elements containing the mean of
the generated multiple imputations.
The array can be used for monitoring convergence.
Note that observed data are not present in this mean.
chainVar
:An array with similar structure as
chainMean
, containing the variance of the imputed values.
loggedEvents
:A data.frame
with five columns
containing warnings, corrective actions, and other inside info.
version
:Version number of mice
package that
created the object.
date
:Date at which the object was created.
The loggedEvents
entry is a matrix with five columns containing a
record of automatic removal actions. It is NULL
is no action was
made. At initialization the program removes constant variables, and
removes variables to cause collinearity.
During iteration, the program does the following actions:
One or more variables that are linearly dependent are removed (for categorical data, a 'variable' corresponds to a dummy variable)
Proportional odds regression imputation that does not converge
and is replaced by polyreg
.
Explanation of elements in loggedEvents
:
it
iteration number at which the record was added,
im
imputation number,
dep
name of the dependent variable,
meth
imputation method used,
out
a (possibly long) character vector with the names of the altered or removed predictors.
The mids
class of objects has methods for the following
generic functions: print
, summary
, plot
.
The plot()
metho plots the trace lines of the MICE algorithm.
The plot
method for a mids
object plots the mean imputed
value per imputation and the mean standard deviation of the imputed
values against the iteration number for each of the $m$ replications.
By default, the function creates a plot for each incomplete
variable. On convergence, the streams should intermingle and be free
of any trend.
Stef van Buuren, Karin Groothuis-Oudshoorn
van Buuren S and Groothuis-Oudshoorn K (2011). mice
:
Multivariate Imputation by Chained Equations in R
. Journal of
Statistical Software, 45(3), 1-67.
\Sexpr[results=rd]{tools:::Rd_expr_doi("10.18637/jss.v045.i03")}
mice
, mira
,
mipo
, xyplot
data <- data.frame(a = c(1, NA, 3), b = c(NA, 2, 3))
q <- list(
a = structure(
list(`1` = 3, `2` = 3, `3` = 3, `4` = 3, `5` = 3),
row.names = "2", class = "data.frame"),
b = structure(
list(`1` = 3, `2` = 3, `3` = 2, `4` = 2, `5` = 3),
row.names = "1", class = "data.frame"))
imp <- mids(
data = data,
imp = q,
m = 5,
where = is.na(data),
blocks = list(a = "a", b = "b"),
nmis = colSums(is.na(data)),
method = c(a = "mean", b = "norm"),
predictorMatrix = matrix(1, nrow = 2, ncol = 2, dimnames = list(c("a", "b"), c("a", "b"))),
visitSequence = c("a", "b"),
formulas = list(a = a ~ b, b = b ~ a),
post = NULL,
blots = NULL,
ignore = logical(nrow(data)),
seed = 123,
iteration = 1,
chainMean = list(a = c(1, 2, 3), b = c(3, 2, 1)),
chainVar = list(a = c(1.1, 1.2, 1.3), b = c(0.9, 1.0, 1.1)),
loggedEvents = NULL)
print(imp)
imp <- mice(nhanes, print = FALSE)
plot(imp, bmi + chl ~ .it | .ms, layout = c(2, 1))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.