Distance Matrix | R Documentation |
Utilities for working with distance matrices.
is.dmatrix
is a utility that checks whether the argument is a distance or dissimilarity matrix; is it square symmetric, non-negative, with zero diagonal? calc_dist
computes a distance matrix directly from a data matrix.
is.dmatrix(x, tol = 100 * .Machine$double.eps)
calc_dist(x)
x |
numeric matrix |
tol |
tolerance for checking required conditions |
Energy functions work with the distance matrices of samples. The is.dmatrix
function is used internally when converting arguments to distance matrices. The default tol
is the same as default tolerance of isSymmetric
.
calc_dist
is an exported Rcpp function that returns a Euclidean distance matrix from the input data matrix.
is.dmatrix
returns TRUE if (within tolerance) x
is a distance/dissimilarity matrix; otherwise FALSE. It will return FALSE if x
is a class dist
object.
calc_dist
returns the Euclidean distance matrix for the data matrix x
, which has observations in rows.
In practice, if dist(x)
is not yet computed, calc_dist(x)
will be faster than as.matrix(dist(x))
.
On working with non-Euclidean dissimilarities, see the references.
Maria L. Rizzo mrizzo@bgsu.edu
Szekely, G.J. and Rizzo, M.L. (2014), Partial Distance Correlation with Methods for Dissimilarities. Annals of Statistics, Vol. 42 No. 6, 2382-2412.
x <- matrix(rnorm(20), 10, 2)
D <- calc_dist(x)
is.dmatrix(D)
is.dmatrix(cov(x))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.