
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.
gowdis(x, w, asym.bin = NULL, ord = c("podani", "metric", "classic"))
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
.
matrix or data frame containing the variables. Variables can be numeric
, ordered
, or factor
. Symmetric or asymmetric binary variables should be numeric
and only contain 0 and 1. character
variables will be converted to factor
. NA
s are tolerated.
vector listing the weights for the variables in x
. Can be missing, in which case all variables have equal weights.
vector listing the asymmetric binary variables in x
.
character string specifying the method to be used for ordinal variables (i.e. ordered
). "podani"
refers to Eqs. 2a-b of Podani (1999), while "metric"
refers to his Eq. 3 (see ‘details’); both options convert ordinal variables to ranks. "classic"
simply treats ordinal variables as continuous variables. Can be abbreviated.
Etienne Laliberté etiennelaliberte@gmail.com https://www.elaliberte.info/, with some help from Philippe Casgrain for the C interface.
gowdis
computes the Gower (1971) similarity coefficient exactly as described by Podani (1999), then converts it to a dissimilarity coefficient by using
Let
where
and where NA
).
For binary variables,
For asymmetric binary variables, same as above except that
For nominal variables,
For continuous variables,
where
For ordinal variables, when ord = "podani"
or ord = "metric"
, all
if ord = "podani"
where
if ord = "metric"
When ord = "classic"
, ordinal variables are simply treated as continuous variables.
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.
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)
Run the code above in your browser using DataLab