Compress or uncompress a matrix of resampling indices

DESCRIPTION:

Compress or uncompress a matrix of resampling indices

USAGE:

compressIndices(indices, n=nrow(indices)) 
uncompressIndices(x) 

REQUIRED ARGUMENTS:

indices
matrix with dimensions m by B, vector of indices for resampling, containing values from 1 to n (or 0 to n); usually m = n;
x
matrix of class "compressIndices".

OPTIONAL ARGUMENTS:

n
maximum possible value of indices; by default this is the number of rows, which is appropriate for ordinary bootstrap sampling. If you use the size argument to bootstrap samplers then the number of rows of indices does not match the number of original observations, and you should specify n as the latter.

VALUE:

matrix of class "compressIndices", with additional components
originalDim
vector of length 2, dimension of the original indices matrix.
n
integer, value of n.


uncompressIndices returns an ordinary matrix of indices (the original indices, except sorted by column, with any zeroes at the end).

DETAILS:

All information about the order of the indices is lost in compression.

Each column of indices is converted to frequencies, and the information about frequencies is stored in m+n bits, where m is the number of rows of indices, with frequencies represented by the number of 1s between 0's. The information is then stored in 32-bit unsigned integers. If m==n the compressed indices require about 1/16 the space of the original indices.

There are subscript, print, and cbind methods for "compressIndices" objects. Subscripting columns returns another "compressIndices" object; subscripting rows returns an ordinary matrix or vector.

The compressed indices may be stored as a "compressedIndices" component of a "bootstrap" object, by setting save.indices=2 when calling .

extracts indices from a "bootstrap" object, first looking for the original indices, then for compressed indices (which it uncompresses).

SEE ALSO:

, .

EXAMPLES:

indices <- samp.bootstrap(n = 100, B = 1000) 
cindices <- compressIndices(indices) 
indices2 <- uncompressIndices(cindices) 
all.equal(indices2, apply(indices, 2, sort))  # The same 
object.size(indices)  # 400184 
object.size(cindices) #  28386