ANTOJITOS_gower.utf8.md

The Gower Distance

 

Gower’s General Similarity Coefficient is one of the most popular measures of distance for mixed data sets

 

\[ S_{ij} = \frac{ \sum_{k}^{n} W_{ijk}S_{ijk} }{ \sum_{k}^{n} W_{ijk} } \]

 

  • \(S_{ijk}\) contribution of the kth variable
  • \(W_{ijk}\) 0 or 1 depending on if comparison is valid

For Continuous Variables

 

\[ S_{ijk} = 1 - |x_{ik} - x_{jk}| / r_{k} \]

 

\(r_{k}\) is the range of values for kth variable

 

Thus for identical values \(S_{ijk}\) is 1

And 0 for \(x_{max}-x_{min}\)

Binary Variables

 

Cases
case i \(+\) \(+\) \(-\) \(-\)
case j \(+\) \(-\) \(+\) \(-\)

 

Values
\(S_{ijk}\) 1 0 0 0
\(W_{ijk}\) 1 1 1 0

For Categorical Values

 

If \(k\) is a categorical variable with \(n\) levels

 

ID# A B
1 2 1
2 1 2
3 3 2
4 1 1
5 2 1

 

\(k\) is converted to \(n\) binary variables

 

ID# \(A_{1}\) \(A_{2}\) \(A_{3}\) \(B_{1}\) \(B_{2}\)
1 \(-\) \(+\) \(-\) \(+\) \(-\)
2 \(+\) \(-\) \(-\) \(-\) \(+\)
3 \(-\) \(-\) \(+\) \(-\) \(+\)
4 \(+\) \(-\) \(-\) \(+\) \(-\)
5 \(-\) \(+\) \(-\) \(+\) \(-\)

Putting it all together

## Dissimilarities :
##                 Burrito   Chalupa Chilaquiles Chimichangas Enchilada Entomatadas  Gorditas   Gringas Huaraches    Memela  Molletes   Molotes    Nachos  Pambazos   Panucho Papadzules Pastel azteca Quesadillas  Salbutes Sincronizadas     Tacos   Tamales  Taquitos  Tlacoyos
## Chalupa       0.4000000                                                                                                                                                                                                                                                        
## Chilaquiles   0.8000000 0.8500000                                                                                                                                                                                                                                              
## Chimichangas  0.1666667 0.5200000   0.6666667                                                                                                                                                                                                                                  
## Enchilada     0.4000000 0.4400000   0.4333333    0.3428571                                                                                                                                                                                                                     
## Entomatadas   0.4000000 0.4400000   0.4333333    0.3428571 0.1428571                                                                                                                                                                                                           
## Gorditas      0.2500000 0.1500000   1.0000000    0.4000000 0.4800000   0.4800000                                                                                                                                                                                               
## Gringas       0.5200000 0.5000000   0.6800000    0.6571429 0.5333333   0.5333333 0.6500000                                                                                                                                                                                     
## Huaraches     1.0000000 0.6000000   0.2500000    0.8000000 0.7200000   0.7200000 0.7500000 0.8500000                                                                                                                                                                           
## Memela        1.0000000 0.6000000   0.5000000    0.8000000 0.7200000   0.7200000 0.7500000 0.8500000 0.2500000                                                                                                                                                                 
## Molletes      1.0000000 0.8500000   0.5000000    0.8000000 0.7200000   0.7200000 1.0000000 0.8500000 0.5000000 0.5000000                                                                                                                                                       
## Molotes       0.2500000 0.1500000   1.0000000    0.3333333 0.4800000   0.4800000 0.0000000 0.7200000 0.7500000 0.7500000 1.0000000                                                                                                                                             
## Nachos        1.0000000 0.8500000   0.5000000    0.8000000 0.7200000   0.7200000 1.0000000 0.8500000 0.5000000 0.5000000 0.5000000 1.0000000                                                                                                                                   
## Pambazos      0.4500000 0.3000000   0.8400000    0.5428571 0.5666667   0.5666667 0.4500000 0.6400000 0.8400000 0.8400000 0.6400000 0.3600000 0.8400000                                                                                                                         
## Panucho       0.5000000 0.7200000   0.5000000    0.4285714 0.4857143   0.4857143 0.6000000 0.4333333 0.6000000 0.8000000 0.8000000 0.6000000 0.8000000 0.8000000                                                                                                               
## Papadzules    0.5666667 0.6400000   0.4333333    0.4857143 0.1428571   0.2857143 0.6800000 0.5333333 0.7200000 0.7200000 0.7200000 0.6800000 0.7200000 0.7333333 0.4857143                                                                                                     
## Pastel azteca 0.5600000 0.5500000   0.4400000    0.6857143 0.4000000   0.4000000 0.7000000 0.5333333 0.8000000 0.8000000 0.8000000 0.7600000 0.8000000 0.6000000 0.6333333  0.4000000                                                                                          
## Quesadillas   0.3200000 0.2500000   0.6800000    0.5142857 0.3666667   0.3666667 0.4000000 0.1666667 0.8500000 0.8500000 0.8500000 0.5200000 0.8500000 0.4400000 0.4333333  0.5333333     0.5333333                                                                            
## Salbutes      0.8000000 0.8500000   0.2000000    0.5714286 0.6000000   0.6000000 1.0000000 0.5666667 0.2500000 0.5000000 0.5000000 0.8000000 0.5000000 0.7000000 0.3333333  0.6000000     0.7000000   0.5666667                                                                
## Sincronizadas 0.4666667 0.6400000   0.5333333    0.4750000 0.4857143   0.4857143 0.7600000 0.4571429 0.6400000 0.6400000 0.6400000 0.8000000 0.6400000 0.7142857 0.5428571  0.4857143     0.5714286   0.4571429 0.6000000                                                      
## Tacos         0.3200000 0.2500000   0.6800000    0.4333333 0.3666667   0.3666667 0.4000000 0.2000000 0.8500000 0.8500000 0.8500000 0.4000000 0.8500000 0.3000000 0.4333333  0.5333333     0.4400000   0.0000000 0.4800000     0.5333333                                        
## Tamales       0.2500000 0.1500000   1.0000000    0.5000000 0.4800000   0.4800000 0.0000000 0.7200000 0.7500000 0.7500000 1.0000000 0.2000000 1.0000000 0.5600000 0.6000000  0.6800000     0.7600000   0.5200000 1.0000000     0.8000000 0.4000000                              
## Taquitos      0.4000000 0.4400000   0.4333333    0.1750000 0.1428571   0.1428571 0.4800000 0.6000000 0.7200000 0.7200000 0.7200000 0.4000000 0.7200000 0.4857143 0.4857143  0.2857143     0.4857143   0.4571429 0.5142857     0.5500000 0.3666667 0.5666667                    
## Tlacoyos      0.5000000 0.4000000   1.0000000    0.6000000 0.6800000   0.6800000 0.2500000 0.6500000 0.7500000 0.7500000 1.0000000 0.2500000 1.0000000 0.7000000 0.6000000  0.6800000     0.7000000   0.6500000 1.0000000     0.7600000 0.6500000 0.2500000 0.6800000          
## Tlayudas      0.8000000 0.8500000   0.2000000    0.6666667 0.6000000   0.6000000 1.0000000 0.4800000 0.2500000 0.5000000 0.5000000 1.0000000 0.5000000 0.8400000 0.3333333  0.6000000     0.6400000   0.4800000 0.0000000     0.5333333 0.4800000 1.0000000 0.6000000 1.0000000
## 
## Metric :  mixed ;  Types = N, N, I, A, N, A, N, N 
## Number of objects : 25