cbind.mids {mice}R Documentation

Columnwise combination of a mids object.

Description

This function combines two mids objects columnwise into a single object of class mids, or combines a mids object with a vector, matrix, factor or data.frame columnwise into an object of class mids. The number of rows in the (incomplete) data x$data and y (or y$data if y is a mids object) should be equal. If y is a mids object then the number of imputations in x and y should be equal. Note: If y is a vector or factor its original name is lost and it will be denoted with y in the mids object.

Usage

cbind.mids(x, y, ...)

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.

Value

An S3 object of class mids

Note

Component call is a vector, with first argument the mice() statement that created x and second argument the call to cbind.mids(). Component data is the codecbind of the (incomplete) data in x$data and y$data. Component m is the number of imputations. Component nmis is an array containing the number of missing observations per column. Component imp is a list of nvar components with the generated multiple imputations. Each part of the list is a nmis[j] by m matrix of imputed values for variable j. The original data of y will be copied into this list, including the missing values of y then y is not imputed. Component method is a vector of strings of length(nvar) specifying the elementary imputation method per column. If y is a mids object this vector is a combination of x$method and y$method, otherwise this vector is x$method and for the columns of y the method is set to ''. Component predictorMatrix is a square matrix of size ncol(data) containing integer data specifying the predictor set. If x and y are mids objects then the predictor matrices of x and y are combined with zero matrices on the off-diagonal blocks. Otherwise the variables in y are included in the predictor matrix of x such that y is not used as predictor(s) and not imputed as well. Component visitSequence is the sequence in which columns are visited. The same as x$visitSequence. Component seed is the seed value of the solution, x$seed. Component iteration is the last Gibbs sampling iteration number, x$iteration. Component lastSeedValue is the most recent seed value, x$lastSeedValue Component chainMean is the combination of x$chainMean and y$chainMean. If y$chainMean does not exist this element equals x$chainMean. Component chainVar is the combination of x$chainVar and y$chainVar. If y$chainVar does not exist this element equals x$chainVar. Component pad is a list containing various settings of the padded imputation model, i.e. the imputation model after creating dummy variables. This list is defined by combining x$pad and y$pad if y is a mids object. Otherwise, it is defined by the settings of x and the combination of the data x$data and y. Component loggedEvents is set to x$loggedEvents. If a column of y is categorical this is ignored in the padded model since that column is not used as predictor for another column.

Author(s)

Karin Groothuis-Oudshoorn, Stef van Buuren, 2009

See Also

rbind.mids, ibind, mids

Examples

# append 'forgotten' variable bmi to imp
temp <- boys[,c(1:3,5:9)]
imp  <- mice(temp,maxit=1,m=2)
imp2 <- cbind.mids(imp, data.frame(bmi=boys$bmi))

# append maturation score to imp (numerical)
mat  <- (as.integer(temp$gen) + as.integer(temp$phb)
+ as.integer(cut(temp$tv,breaks=c(0,3,6,10,15,20,25))))
imp2 <- cbind.mids(imp, as.data.frame(mat))

# append maturation score to imp (factor)
# known issue: new column name is 'y', not 'mat'
mat  <- as.factor(mat)
imp2 <- cbind.mids(imp, mat)

# append data frame with two columns to imp
temp2 <- data.frame(bmi=boys$bmi,mat=as.factor(mat))
imp2  <- cbind.mids(imp, temp2)

# combine two mids objects
impa <- mice(temp, maxit=1, m=2)
impb <- mice(temp2, maxit=2, m=2)

# first a then b
impab <- cbind.mids(impa, impb)

# first b then a
impba <- cbind.mids(impb, impa)

[Package mice version 2.22 Index]