Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

# st: Dissimilarity and Gower distance

 From tartifola@gmail.com To statalist@hsphsun2.harvard.edu Subject st: Dissimilarity and Gower distance Date Tue, 28 Aug 2012 11:35:43 +0200

```Dear Stata users,
I'm having an issue with the command -matrix dissimilarity- together
with the Gower dissimilarity measure. I'm using Stata/MP 12.1 for Unix.

Consider a simple dataset

var1 var2 var3
obs1    1   .25    1
obs2    0   .5      0
obs3    0   .25    0

If I run the command

. matrix dissimilarity gd = var*, Gower

dissimilarity measures are calculated by observation and, as expected,
I get

symmetric gd[3,3]
obs1       obs2       obs3
obs1          0
obs2          1          0
obs3  .66666667  .33333333          0

On the contrary, if I run

. matrix dissimilarity gd = var*, Gower var

dissimilarity should be evaluated by variables and the output is

symmetric gd[3,3]
var1       var2       var3
var1          0
var2          1          0
var3          0  .33333333          0

I do not understand where the .3333 comes from, I was expecting a 1
instead. On the top of that, consider also that if I transpose the
dataset in

var1  var2 var3
obs1    1     0     0
obs2    .25  .5    0.25
obs3    1     0      0

and then run the same command I get

. matrix dissimilarity gd = var*, Gower

symmetric gd[3,3]
obs1  obs2  obs3
obs1     0
obs2     1     0
obs3     0     1     0

and

. matrix dissimilarity gd = var*, Gower var

symmetric gd[3,3]
var1       var2       var3
var1          0
var2          1          0
var3  .66666667  .33333333          0

which are in line with my calculations. What am I missing?

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```