gdist: Generalized Distance Matrix Computation In GMD: Generalized Minimum Distance of distributions

Description

gdist computes and returns the distance matrix computed by using user-defined distance measure.

Usage

 1 2 3 gdist(x,method="euclidean",MoreArgs=NULL,diag=FALSE,upper=FALSE) is.dist(d)

Arguments

 x a numeric matrix, data frame or ‘dist’ object. method the distance measure to be used. This can either be one of the methods used in dist (see help("dist", package="stats")) or "correlation", "correlation.of.observations" and "correlation.of.variables". In addition, user-defined distance measure are also allowed, which returns a dist object and should at least have attributes "Size" and "Labels". MoreArgs a list of other arguments to be passed to gdist. diag logical value indicating whether the diagonal of the distance matrix should be printed by print.dist. upper logical value indicating whether the upper triangle of the distance matrix should be printed by print.dist. d an R object.

Details

is.dist tests if its argument is a ‘dist’ object.

The distance (or dissimilarity) function (FUN) can be any distance measure applied to x. For instance, "euclidean", "maximum", "manhattan","canberra", "binary", "minkowski", "correlation.of.variables", "correlation.of.observations" or gmdm. "correlation.of.variables" computes the correlation distance of the variables (the columns); all the other compute the distances between the observations (the rows) of a data matrix.

Value

gdist returns an object of ‘dist’.
is.dist returns a logical value whether an object is ‘dist’.

Examples

 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 ## load library require("GMD") require(cluster) ## compute distance using Euclidean metric (default) data(ruspini) x <- gdist(ruspini) ## see a dendrogram result by hierarchical clustering dev.new(width=12, height=6) plot(hclust(x), main="Cluster Dendrogram of Ruspini data", xlab="Observations") ## convert to a distance matrix m <- as.matrix(x) ## convert from a distance matrix d <- as.dist(m) stopifnot(d == x) ## Use correlations between variables "as distance" data(USJudgeRatings) dd <- gdist(x=USJudgeRatings,method="correlation.of.variables") dev.new(width=12, height=6) plot(hclust(dd), main="Cluster Dendrogram of USJudgeRatings data", xlab="Variables")