Message-ID: <3361928689C6934A8EEC66803C59EE9916CD20@EXBK02.personale.dir.unibo.it>
Date: 2004-11-09T10:59:24Z
From: Alessio Boattini
Subject: gdist and gower distance
Dear All,
I would like to ask clarifications on the gower distnce matrix calculated by the function gdistin the library mvpart.
Here is a dummy example:
> library(mvpart)
Loading required package: survival
Loading required package: splines
mvpart package loaded: extends rpart to include
multivariate and distance-based partitioning
> x=matrix(1:6, byrow=T, ncol=2)
> x
[,1] [,2]
[1,] 1 2
[2,] 3 4
[3,] 5 6
> gdist(x, method="euclid")
1 2
2 2.828427
3 5.656854 2.828427
##########################
doing the calculations by hand according to the formula in gdist help page I get the same results. The formula given is:
'euclidean' d[jk] = sqrt(sum (x[ij]-x[ik])^2)
#################################
> sqrt(8)
[1] 2.828427
> gdist(x, method="gower")
1 2
2 0.7071068
3 1.4142136 0.7071068
#######################################
doing the calculations by hand according to the formula in gdist help page cannot reproduce the same results. The formula given is:
'gower' d[jk] = sum (abs(x[ij]-x[ik])/(max(i)-min(i))
##########################################
Could anybody please shed some light?
Regards,
Alessio Boattini