Create "miVariable" Object

DESCRIPTION:

Attach multiple imputations to an object to create an miVariable object.

USAGE:

miVariable(x, Imputations, whichNA = which.na(x), subset = F, 
           Names = 1:length(Imputations), row.names) 
as.miVariable(x) 

REQUIRED ARGUMENTS:

x
(for miVariable): atomic (non-list) variable.
x
(for as.miVariable): miList object whose imputations are atomic variables with the same length, mode, and attributes, or an miVariable object. More general mi objects are allowed, but the result will not be an miVariable object.
Imputations
list, with one element for each set of imputations; each element should have length equal to the number of missing values in x (or equal to the length of x, if subset=TRUE).

OPTIONAL ARGUMENTS:

whichNA
logical or numeric vector indicating which observations in x are missing.
subset
if TRUE, then each element of Imputations will be replaced with the subset indicated by whichNA.
Names
names for imputation sets, i.e. for column names of the Imputations data frame in the returned value. These are used if supplied explicitly, otherwise if the Imputations argument has names they are used, otherwise default names are used.
row.names
row names for the Imputations data frame in the returned value.

VALUE:

An object of class "miVariable", with slots:
Data
the original data (argument x to miVariable; this may have its own class),
whichNA
integer vector indicating which elements of the Data have multiple imputations (usually the elements which are missing),
Imputations
data frame, same number of rows as whichNA and as many columns as there are sets of multiple imputations.

In as.miVariable, if x cannot be converted to an miVariable object, then a more general mi object will be returned.

DETAILS:

The whichNA argument is typically equal to which.na(x) or is.na(x).

x may be a matrix or array.

REFERENCES:

Schafer, J. L. (1997), Analysis of Incomplete Multivariate Data , Chapman & Hall, London.

SEE ALSO:

, , , , .

EXAMPLES:

c3 <- miEval(crimeImpExample[[3]]) 
c3                # an miList object, 10 sets of imputations 
as.miVariable(c3) # same data, but stored as miVariable 
x <- miVariable(c(1,2,NA,NA),  
                list(Imp1 = c(3,4), Imp2 = c(4,2))) 
x 
# Use of the subset argument (otherwise like x just above): 
miVariable(c(1,2,NA,NA), subset = T, 
           list(Imp1 = c(99,99,3,4), Imp2 = c(99,99,4,2))) 
# as.miVariable does not always return an miVariable object 
y <- as.miList(x) 
as.miVariable(y)  # an miVariable 
y[[1]] <- 1:6     # Now first imputation is longer 
as.miVariable(y)  # miList (couldn't convert to miVariable)