Learn R Programming

cba (version 0.2-25)

stress: Conciseness of Presentation Measures

Description

Compute different types of conciseness of presentation measures.

Usage

stress(x, rows = NULL, cols = NULL, type = "moore")

stress.dist(x, rows = NULL, cols = NULL, bycol = FALSE, type = "moore")

Value

stress returns a scalar real, i.e. half of the global stress measure.

stress.dist returns an object of class dist, i.e. a lower triangular matrix in column format.

Arguments

x

a matrix object.

rows

a subscript vector indexing the rows.

cols

a subscript vector indexing the columns.

bycol

logical for computation over the columns.

type

the type of neighborhood to use.

Author

Christian Buchta

Details

Function stress computes the sum of squared distances of each matrix entry from its adjacent entries. The following types of neighborhoods are available:

moore:

comprises the eight adjacent entries (five at the margins and three at the corners).

neumann:

comprises the four adjacent entries (three at the margins and two at the corners).

Function stress.dist computes the auto-distance matrix for each pair of rows (or columns) given one of the above stress measures. Note that the result depends on the ordering of the unused dimension.

As the computation can be reduced to summing the edge distances between any two neighboring points, only half of the value of the proposed measures is reported.

Row and/or column indexes (or labels) can be supplied to test specific orderings, as well as subsets of indexes (labels).

Note that the matrix should be normalized so that the distance computation is meaningful.

See Also

dist for general distance computation.

Examples

Run this code
##
x1 <- matrix(sample(c(FALSE,TRUE),25,rep=TRUE),ncol=5)
stress(x1)
stress(x1, type="neumann")
##
x2 <- cbind(rbind(matrix(1,4,4),matrix(0,4,4)), 
	    rbind(matrix(0,4,4),matrix(1,4,4)))
stress.dist(x2)
stress.dist(x2, bycol=TRUE)
stress.dist(x2, type="neumann")
if (FALSE) {
##
(res <- stress(x2, rows=c(1,8)))
rownames(x2) <- c(letters[1:7], "ä")
stopifnot(identical(res, stress(x2, rows=c("a","ä"))))
stopifnot(identical(res, stress(x2, rows=c("a",iconv("ä", to="latin1")))))
}

Run the code above in your browser using DataLab