minmaxBlock: Minimal or maximal 2 \times 2 (non-zero) matrix of missing...

View source: R/minmaxBlock.R

minmaxBlockR Documentation

Minimal or maximal 2 \times 2 (non-zero) matrix of missing values

Description

Finds 2 \times 2 (non-zero) block with the minimum or maximum amount of missing values within a general missing values matrix derived from satellite images.

Usage

minmaxBlock(sieve, type = c("min", "max"), rank)

Arguments

sieve

matrix

type

character. Default is "min".

rank

numeric. See Details.

Details

In what follows we describe the case type="min". This function searches for the minimal 2\times 2 (non-zero) sub-matrix within a general sieve matrix. blockMissingness is defined as \log( cumsum (a_{i,j}) ) for 1\leq i,j\leq 2. The minimal block is defined as that block with the minimum blockMissingness. The cumsum function is preferred rather than other quantities, such as cumprod or det, because sieve could have a large amount of zeros.

In the first stage of the search, a vector with the sorted non-zero values of sieve is calculated. Consider the i-th entry of this sorted vector. This value corresponds to some (maybe more than once) cell within sieve. Notice that, with the exception of the edges of the sieve, this cell belongs to four 2\times 2 matrices. The blockMissingness of each of these 4 matrices is calculated. The matrix with the smallest blockMissingness is called a localMinBlock.

The procedure just described is applied to each of the rank entries of the sorted vector; the globalMinBlock is that localMinBlock with the smallest blockMissingness.

The case type="max" is analogous to the one above but the searches is now for the cell with the largest blockMissingness and the search now runs (in descending order) over the last rank-th entries of the sorted vector.

The argument rank is defined as follows. Let sorted_vector be a numeric vector with the non-zero, ordered (in ascending order) values of sieve. When type="min", rank defines the first rank-th values of sorted_vector. When type="max", rank defines the last rank-th values of sorted_vector.

Value

A list containing:

rows

a numeric vector given the rows of sieve where the minimal 2\times 2 block is found.

cols

a numeric vector given the cols of sieve where the minimal 2\times 2 block is found.

block

a 2\times 2 sub-matrix of sieve, the actual minimal block.

blockMissingness

a numeric with the blockMissingness of the minimal block.

See Also

mvSieve


igapfill documentation built on June 8, 2025, 10:41 a.m.