gowdis {FD} | R Documentation |
Gower Dissimilarity
Description
gowdis
measures the Gower (1971) dissimilarity for mixed variables, including asymmetric binary variables. Variable weights can be specified. gowdis
implements Podani's (1999) extension to ordinal variables.
Usage
gowdis(x, w, asym.bin = NULL, ord = c("podani", "metric", "classic"))
Arguments
x |
matrix or data frame containing the variables. Variables can be |
w |
vector listing the weights for the variables in |
asym.bin |
vector listing the asymmetric binary variables in |
ord |
character string specifying the method to be used for ordinal variables (i.e. |
Details
gowdis
computes the Gower (1971) similarity coefficient exactly as described by Podani (1999), then converts it to a dissimilarity coefficient by using . It integrates variable weights as described by Legendre and Legendre (1998).
Let be a matrix containing
objects (rows) and
columns (variables). The similarity
between objects
and
is computed as
,
where is the weight of variable
for the
-
pair, and
is the partial similarity of variable
for the
-
pair,
and where if objects
and
cannot be compared because
or
is unknown (i.e.
NA
).
For binary variables, if
, and
if
or if
.
For asymmetric binary variables, same as above except that if
.
For nominal variables, if
and
if
.
For continuous variables,
where and
are the maximum and minimum values of variable
, respectively.
For ordinal variables, when ord = "podani"
or ord = "metric"
, all are replaced by their ranks
determined over all objects (such that ties are also considered), and then
if ord = "podani"
if
, otherwise
where is the number of objects which have the same rank score for variable
as object
(including
itself),
is the number of objects which have the same rank score for variable
as object
(including
itself),
and
are the maximum and minimum ranks for variable
, respectively,
is the number of objects with the maximum rank, and
is the number of objects with the minimum rank.
if ord = "metric"
When ord = "classic"
, ordinal variables are simply treated as continuous variables.
Value
an object of class dist
with the following attributes: Labels
, Types
(the variable types, where 'C' is continuous/numeric, 'O' is ordinal, 'B' is symmetric binary, 'A' is asymmetric binary, and 'N' is nominal), Size
, Metric
.
Author(s)
Etienne Laliberté etiennelaliberte@gmail.com https://www.elaliberte.info/, with some help from Philippe Casgrain for the C interface.
References
Gower, J. C. (1971) A general coefficient of similarity and some of its properties. Biometrics 27:857-871.
Legendre, P. and L. Legendre (1998) Numerical Ecology. 2nd English edition. Amsterdam: Elsevier.
Podani, J. (1999) Extending Gower's general coefficient of similarity to ordinal characters. Taxon 48:331-340.
See Also
daisy
is similar but less flexible, since it does not include variable weights and does not treat ordinal variables as described by Podani (1999). Using ord = "classic"
reproduces the behaviour of daisy
.
Examples
ex1 <- gowdis(dummy$trait)
ex1
# check attributes
attributes(ex1)
# to include weights
w <- c(4,3,5,1,2,8,3,6)
ex2 <- gowdis(dummy$trait, w)
ex2
# variable 7 as asymmetric binary
ex3 <- gowdis(dummy$trait, asym.bin = 7)
ex3
# example with trait data from New Zealand vascular plant species
ex4 <- gowdis(tussock$trait)