|
NAG[g03eac] NAG[nag_mv_distance_mat] - Compute distance (dissimilarity) matrix
|
|
Calling Sequence
g03eac(update, dist, scale, x, isx, s, d, 'n'=n, 'm'=m, 'tdx'=tdx, 'fail'=fail)
nag_mv_distance_mat(. . .)
Parameters
|
update - String;
|
|
|
On entry: indicates whether or not an existing matrix is to be updated.
|
|
Constraint: "Nag_MatUp" or "Nag_NoMatUp". .
|
|
|
dist - String;
|
|
|
On entry: indicates which type of distances are computed.
|
|
Absolute distances.
|
|
Euclidean distances.
|
|
Euclidean squared distances.
|
|
Constraint: "Nag_DistAbs", "Nag_DistEuclid" or "Nag_DistSquared". .
|
|
|
scale - String;
|
|
|
On entry: indicates the standardization of the variables to be used.
|
|
Standard deviation.
|
|
Range.
|
|
Standardizations given in array .
|
|
Unscaled.
|
|
Constraint: "Nag_VarScaleStd", "Nag_VarScaleRange", "Nag_VarScaleUser" or "Nag_NoVarScale". .
|
|
|
x - Matrix(1..n, 1..tdx, datatype=float[8], order=C_order);
|
|
|
|
isx - Vector(1..m, datatype=integer[kernelopts('wordsize')/8]);
|
|
|
On entry: indicates whether or not the th variable in x is to be included in the distance computations.
|
|
|
s - Vector(1..m, datatype=float[8]);
|
|
|
|
d - Vector(1.., datatype=float[8]);
|
|
|
Note: the dimension, dim, of the array d must be at least .
|
|
|
'n'=n - integer; (optional)
|
|
|
Default value: the first dimension of the array x.
|
|
On entry: the number of observations, .
|
|
Constraint: . .
|
|
|
'm'=m - integer; (optional)
|
|
|
Default value: the first dimension of the arrays isx, s and the second dimension of the arrays isx, sthe array x.
|
|
On entry: the total number of variables in array x.
|
|
Constraint: . .
|
|
|
'tdx'=tdx - integer; (optional)
|
|
|
On entry: the second dimension of the array x as declared in the function from which nag_mv_distance_mat (g03eac) is called.
|
|
Constraint: . .
|
|
|
'fail'=fail - table; (optional)
|
|
|
The NAG error argument, see the documentation for NagError.
|
|
|
|
Description
|
|
|
Purpose
|
|
nag_mv_distance_mat (g03eac) computes a distance (dissimilarity) matrix.
|
|
Description
|
|
Given objects, a distance or dissimilarity matrix, is a symmetric matrix with zero diagonal elements such that the th element represents how far apart or how dissimilar the th and th objects are.
Let be an by data matrix of observations of variables on objects, then the distance between object and object , , can be defined as:
where and are the th and th elements of , is a standardization for the th variable and is a suitable function. Three functions are provided in nag_mv_distance_mat (g03eac):
|
a. Euclidean distance: and .
|
|
b. Euclidean squared distance: and .
|
|
c. Absolute distance (city block metric): and .
|
Three standardizations are available:
|
Standard deviation:
|
|
Range:
|
|
User supplied values of .
|
In addition to the above distances there are a large number of other dissimilarity measures, particularly for dichotomous variables (see Krzanowski (1990) and Everitt (1974)). For the dichotomous case these measures are simple to compute and can, if suitable scaling is used, be combined with the distances computed by nag_mv_distance_mat (g03eac) using the updating option.
Dissimilarity measures for variables can be based on the correlation coefficient for continuous variables and contingency table statistics for dichotomous data, see the g02 Chapter Introduction and the g11 Chapter Introduction respectively.
nag_mv_distance_mat (g03eac) returns the strictly lower triangle of the distance matrix.
|
|
Error Indicators and Warnings
|
|
"NE_BAD_PARAM"
On entry, argument dist had an illegal value.
"NE_IDEN_ELEM_COND"
On entry, or , and , for , for some with .
"NE_INT_ARG_LE"
On entry, m must not be less than or equal to 0: .
"NE_INT_ARG_LT"
On entry, n must not be less than 2: .
"NE_INTARR"
On entry, . Constraint: , for at least one .
"NE_INTERNAL_ERROR"
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please consult NAG for assistance.
"NE_REALARR"
On entry, . Constraint: , when .
|
|
Accuracy
|
|
The computations are believed to be stable.
|
|
|
Examples
|
|
>
|
update := "Nag_NoMatUp":
dist := "Nag_DistSquared":
scale := "Nag_NoVarScale":
n := 5:
m := 3:
tdx := 3:
x := Matrix([[1, 1, 1], [2, 1, 2], [3, 6, 3], [4, 8, 2], [5, 8, 0]], datatype=float[8], order='C_order'):
isx := Vector([0, 1, 1], datatype=integer[kernelopts('wordsize')/8]):
s := Vector([1, 1, 1], datatype=float[8]):
d := Vector([0, 0, 0, 0, 0, 0, 0, 0, 0, 0], datatype=float[8]):
NAG:-g03eac(update, dist, scale, x, isx, s, d, 'n' = n, 'm' = m, 'tdx' = tdx):
|
|
|