stress | R Documentation |
Compute different types of conciseness of presentation measures.
stress(x, rows = NULL, cols = NULL, type = "moore")
stress.dist(x, rows = NULL, cols = NULL, bycol = FALSE,
type = "moore")
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. |
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.
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.
Christian Buchta
dist
for general distance computation.
##
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")
## Not run:
##
(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")))))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.