dist.binary | R Documentation |
computes for binary data some distance matrice.
dist.binary(df, method = NULL, diag = FALSE, upper = FALSE)
df |
a matrix or a data frame with positive or null numeric values. Used with |
method |
an integer between 1 and 10 . If NULL the choice is made with a console message. See details |
diag |
a logical value indicating whether the diagonal of the distance matrix should be printed by ‘print.dist’ |
upper |
a logical value indicating whether the upper triangle of the distance matrix should be printed by ‘print.dist’ |
Let be the contingency table of binary data such as n_{11} = a
, n_{10} = b
, n_{01} = c
and n_{00} = d
. All these distances are of type d=\sqrt{1-s}
with s a similarity coefficient.
S3 coefficient of Gower & Legendre s_1 = \frac{a}{a+b+c}
S4 coefficient of Gower & Legendre s_2 =\frac{a+d}{a+b+c+d}
S5 coefficient of Gower & Legendre s_3 =\frac{a}{a+2(b+c)}
S6 coefficient of Gower & Legendre s_4 =\frac{a+d}{(a+2(b+c)+d)}
S7 coefficient of Gower & Legendre s_5 =\frac{2a}{2a+b+c}
S9 index of Gower & Legendre (1986) s_6 =\frac{a-(b+c)+d}{a+b+c+d}
S12 coefficient of Gower & Legendre s_7 =\frac{a}{\sqrt{(a+b)(a+c)}}
S13 coefficient of Gower & Legendre s_8 =\frac{ad}{\sqrt{(a+b)(a+c)(d+b)(d+c)}}
S14 coefficient of Gower & Legendre s_9 =\frac{ad-bc}{\sqrt{(a+b)(a+c)(b+d)(d+c)}}
s_1 = \frac{a}{a+b+c+d}
returns a distance matrix of class dist
between the rows of the data frame
Daniel Chessel
Stéphane Dray stephane.dray@univ-lyon1.fr
Gower, J.C. and Legendre, P. (1986) Metric and Euclidean properties of dissimilarity coefficients. Journal of Classification, 3, 5–48.
data(aviurba)
for (i in 1:10) {
d <- dist.binary(aviurba$fau, method = i)
cat(attr(d, "method"), is.euclid(d), "\n")}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.