Extract or assign a single multiple imputation set

DESCRIPTION:

Extract/assign a single set of imputations from/to an object containing multiple imputations.

USAGE:

miSubscript(x, k) 
miSubscript(x, k) <- value 

REQUIRED ARGUMENTS:

x
an object containing multiple imputations (class miList or miVariable, or a list containing one of these).
k
integer, indicating which set of multiple imputations to extract/assign.

VALUE:

for extraction, a complete data object corresponding to x.

Extraction details:

If x is an miList object, then miSubscript(x,2) is equivalent to x[[2]].

If x is an miVariable object, the missing values in x@Data (indicated by x@whichNA) are replaced by the kth set of imputations ( x@Imputations[[k]]), and the modified version of x@Data is returned (which is now a complete data object).

If x is an object containing miList or miVariable components or slots, the above rules are applied to those components to obtain complete data objects to replace the components, and the resulting list is returned.

Assignment details:

If x contains imputations but is not of class miList, it is first converted to an equivalent miList object (equivalent in that the result of miSubscript(x,j) is unchanged). After conversion, the kth component of x is replaced with value.

NOTE:

For miSubscript(x,k) <- something to work, x must exist and be an mi object.

SEE ALSO:

, , .

EXAMPLES:

# an miList object (same as using [[]]) 
miSubscript(crimeImpExample, 2) 
# an miVariable object 
miSubscript(cholesterolImpExample, 2) 
# ordinary object -- returns the object 
miSubscript(1:5, 2) 
# list containing any miObject 
miSubscript(list(1, crimeImpExample), 2) 
miSubscript(list(1, cholesterolImpExample), 2) 
# Assignment.  Result is always an miList 
x <- crimeImpExample 
miSubscript(x, 2) <- 0 
x 
x <- cholesterolImpExample 
miSubscript(x, 2) <- 0  # result is an miList 
x 
x <- 1:5 
# miSubscript(x, 2) <- 0  # Should fail, x is not an mi object