On Nov 12, 2009, at 1:32 PM, David Winsemius wrote:
>
> On Nov 12, 2009, at 1:20 PM, Caio Azevedo wrote:
>
>> Hi all,
>>
>> Does anybody know which distance measure is used when the option
>> ""method="binary" "" is considered in the
"dist" function?
>
> Did you look at the help page?
If you are having problems understanding the dist help page. then
perhaps you can think of the binary distance as the Boolean sum of
XOR() divided by the sum of OR():
> sum( xor(c(1,0,1,0), c(1,1,1,0))+0) / sum( c(1,0,1,0) |
c(1,1,1,0)+0 )
[1] 0.3333333
Or using the example on the help page:
> x <- c(0, 0, 1, 1, 1, 1)
> y <- c(1, 0, 1, 1, 0, 1)
> dist(rbind(x,y), method= "binary")
x
y 0.4
> ## answer 0.4 = 2/5
> sum(xor(x, y)+0)/sum(x | y +0)
[1] 0.4
>
--
David Winsemius, MD
Heritage Laboratories
West Hartford, CT