Skip to content
Prev 278746 / 398502 Next

md.pattern ('mice') failure with more than 31 variables

On Tue, Nov 29, 2011 at 1:58 AM, <saschaview at gmail.com> wrote:
Because 2^31 is too large of a value to be represented as an integer.
The 15th line of md.pattern has the code:

 mdp <- as.integer((r %*% (2^((1:ncol(x)) - 1))) + 1)

when ncol(x) > 31, 32+ - 1 = 31+, and

as.integer(2^31)

returns NA and gives the warning you see.  Technically, the warning
does not occur at the 2^... part, it is when the results are converted
to integer, so if there were no missing values, r (a 0/1 matrix
indicating whether a particular cell is missing) would be all zeros,
and thus r %*% potentially larger value than 2^30 = 0, and you do not
get any warnings.

Aside from some storage inefficiency for < 31 columns, I do not see
any harm from from simply removing the conversion to integer.  For <
31 columns, the function appears to give equal results with or without
the conversion, but for > 31 columns, some patterns are not included
when as.integer is used.

Cheers,

Josh