Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

rbind.mids

Combine mids objects by rows


Description

This function combines two mids objects rowwise into a single mids object, or combines a mids object with a vector, matrix, factor or dataframe rowwise into a mids object.

Usage

rbind.mids(x, y = NULL, ...)

Arguments

x

A mids object.

y

A mids object, or a data.frame, matrix, factor or vector.

...

Additional data.frame, matrix, vector or factor. These can be given as named arguments.

Details

If y is a mids object, then rbind requires that the number of multiple imputations in x and y is identical. Also, columns of x$data and y$data should match.

If y is not a mids object, the columns of x$data and y should match. The where matrix for y is set to FALSE, signaling that any missing values in y were not imputed. The ignore vector for y is set to FALSE, elements of y will therefore influence the parameters of the imputation model in future iterations.

Value

An S3 object of class mids

Note

The function construct the elements of the new mids object as follows:

data Rowwise combination of the (incomplete) data in x and y
imp Equals rbind(x$imp[[j]], y$imp[[j]]) if y is mids object; otherwise the data of y will be copied
m Equals x$m
where Rowwise combination of where arguments
blocks Equals x$blocks
call Vector, call[1] creates x, call[2] is call to rbind.mids
nmis x$nmis + y$nmis
method Taken from x$method
predictorMatrix Taken from x$predictorMatrix
visitSequence Taken from x$visitSequence
formulas Taken from x$formulas
post Taken from x$post
blots Taken from x$blots
ignore Concatenate x$ignore and y$ignore
seed Taken from x$seed
iteration Taken from x$iteration
lastSeedValue Taken from x$lastSeedValue
chainMean Set to NA
chainVar Set to NA
loggedEvents Taken from x$loggedEvents
version Taken from x$version
date Taken from x$date

Author(s)

Karin Groothuis-Oudshoorn, Stef van Buuren

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

Examples

imp1 <- mice(nhanes[1:13, ], m = 2, maxit = 1, print = FALSE)
imp5 <- mice(nhanes[1:13, ], m = 2, maxit = 2, print = FALSE)
mylist <- list(age = NA, bmi = NA, hyp = NA, chl = NA)

nrow(complete(rbind(imp1, imp5)))
nrow(complete(rbind(imp1, mylist)))

nrow(complete(rbind(imp1, data.frame(mylist))))
nrow(complete(rbind(imp1, complete(imp5))))

mice

Multivariate Imputation by Chained Equations

v3.13.0
GPL-2 | GPL-3
Authors
Stef van Buuren [aut, cre], Karin Groothuis-Oudshoorn [aut], Gerko Vink [ctb], Rianne Schouten [ctb], Alexander Robitzsch [ctb], Patrick Rockenschaub [ctb], Lisa Doove [ctb], Shahab Jolani [ctb], Margarita Moreno-Betancur [ctb], Ian White [ctb], Philipp Gaffert [ctb], Florian Meinfelder [ctb], Bernie Gray [ctb], Vincent Arel-Bundock [ctb]
Initial release
2021-01-26

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.