Learn R Programming

seriation (version 1.1-3)

Robinson: Create and Recognize Robinson and Pre-Robinson Matrices

Description

Provides functions to create and recognize (anti) Robinson and pre-Robinson matrices. A (anti) Robinson matrix has strictly decreasing (increasing) values when moving away from the main diagonal. A pre-Robinson matrix is a matrix which can be transformed into a perfect Robinson matrix using simultaneous permutations of rows and columns.

Usage

is.robinson(x, anti = TRUE, pre = FALSE)
random.robinson(n, anti = TRUE, pre = FALSE, noise = 0)

Arguments

x
a symmetric, positive matrix or a dissimilarity matrix (a dist object).
anti
logical; check for anti Robinson structure? Note that for distances, anti Robinson structure is appropriate.
pre
logical; recognize/create pre-Robinson matrices.
n
number of objects.
noise
zero means no noise. Noise more than zero results in non-Robinson matrices.

Value

  • A single logical value.

Details

Note that the default matrices are anti Robinson matrices. This is done because distance matrices (the default in R) are typically anti Robinson matrices with values increasing when moving away from the diagonal.

Robinson matrices are recognized using the fact that they have zero anti Robinson events. For pre-Robinson matrices we use spectral seriation first since spectral seriation is guaranteed to perfectly reorder pre-Robinson matrices.

Random pre-Robinson matrices are generated using $dist(x)$ where $x$ is a vector of n values drawn from a random uniform distribution with range $[0,1]$. For Robinson matrices, $x$ is sorted.

For noise, randomly chosen $y$ coordinates are added. The coordinates are chosen from a normal distribution with a mean of zero and a standard deviation given by the desired noise level. Reasonable levels are close to zero.

Examples

Run this code
## create a perfect anti Robinson structure  
m <- random.robinson(10)
pimage(m)

is.robinson(m)

## permute the structure to make it not Robinsonian. However,
## it is still pre-Robinson.
o <- sample(10)
m2 <- permute(m, ser_permutation(o,o))
pimage(m2)

is.robinson(m2)
is.robinson(m2, pre = TRUE)

## create a binary random Robinson matrix (not anti Robinson)
m3 <- random.robinson(10, anti = FALSE) > .7 
pimage(m3)
is.robinson(m3, anti = FALSE)

Run the code above in your browser using DataLab