daisy(x, metric = "euclidean", stand = FALSE, type = list())
x
. Columns of mode numeric
will
be recognized as interval scaled variables, columns of class
factor
will be recognized as n"euclidean"
(the default)
and "manhattan"
.
Euclidean distances are root sum-of-squares of differences, and
manhattan distances arex
are standardized before calculating the
dissimilarities. Measurements are standardized for each variable
(column), by subtracting the variable's mean value and dividing by
thex
. The list may contain the following
components: "ordratio"
(ratio scaled variables to be treated as
ordinal variables), "logratio"
"dissimilarity"
containing the dissimilarities among
the rows of x. This is typically the input for the functions pam
,
fanny
, agnes
or diana
. See
dissimilarity.object
for details.daisy
is fully described in chapter 1 of Kaufman and Rousseeuw (1990).
Compared to dist
whose input must be numeric
variables, the main feature of daisy
is its ability to handle
other variable types as well (e.g. nominal, ordinal, asymmetric
binary) even when different types occur in the same dataset.
In the daisy
algorithm, missing values in a row of x are not
included in the dissimilarities involving that row. There are two
main cases,
The contribution of a nominal or binary variable to the total dissimilarity is 0 if both values are different, 1 otherwise. The contribution of other variables is the absolute difference of both values, divided by the total range of that variable. Ordinal variables are first converted to ranks.
Ifnok
is the number of nonzero weights, the dissimilarity is
multiplied by the factor1/nok
and thus ranges between 0 and 1.
Ifnok = 0
, the dissimilarity is set toNA
.
dissimilarity.object
, dist
,
pam
, fanny
, clara
,
agnes
, diana
.data(agriculture)
## Example 1 in ref:
## Dissimilarities using Euclidean metric and without standardization
d.agr <- daisy(agriculture, metric = "euclidean", stand = FALSE)
d.agr
as.matrix(d.agr)[,"DK"] # via as.matrix.dist(.)
data(flower)
## Example 2 in ref
summary(dfl1 <- daisy(flower, type = list(asymm = 3)))
summary(dfl2 <- daisy(flower, type = list(asymm = c(1, 3), ordratio = 7)))
Run the code above in your browser using DataLab