Skip to contents

Description

Distances between elements are used as a measure of similarity. For elements, distance measure have the advantage that they are not affected by construct reflection as it is the case for correlations between elements (see elementCor). The following distance measures are available:

  • euclidean: Squared distance between the two vectors (L2 norm)
  • manhattan: Also called city-block-distance, absolute distance between the two vectors (L1 norm).
  • minkowski: The p norm, the pth root of the sum of the pth powers of the differences of the components.
  • maximum: Maximum distance between two components of x and y (supremum norm)
  • canberra: (|xiyi|/|xi+yi|)\sum(|x_i - y_i| / |x_i + y_i|) Terms with zero numerator and denominator are omitted from the sum and treated as if the values were missing. This is intended for non-negative values (e.g. counts).
  • binary: The vectors are regarded as binary bits, so non-zero elements are on and zero elements are off. The distance is the proportion of bits in which only one is on amongst those in which at least one is on.

For most grid purposes, the first two options will suffice.

R-Code

In OpenRepGrid the function distance calculates various types of distances for constructs and for elements (the default is euclidean). The argument along determines if distances for 1) constructs or 2) elements are calculated. The default is to calculate distances for constructs, so we always need to set along=2 to prompt element distances.

distance(fbb2003, along = 2) # along = 2 for elements
# 
# ##########################
# Distances between elements
# ##########################
# 
# Distance method:  euclidean
# Normalized: FALSE
#                                1     2     3     4     5     6     7     8
# (1) self                 1        4.47  8.19  3.87  7.75  9.80  6.78  8.89
# (2) my father            2             10.15  4.36  8.83 11.22  4.00  9.33
# (3) an old flame         3                    7.48  6.56  7.42 10.05  5.48
# (4) an ethical person    4                          6.24  9.11  6.24  6.93
# (5) my mother            5                                9.06  8.83  4.36
# (6) a rejected teacher   6                                     12.65  8.19
# (7) as I would love to b 7                                            8.77
# (8) a pitied person      8

To change the distance measure supply any unambigous string of the available distance methods to the argument dmethod. E.g. for the manhattan distance bewteen constructs:

distance(fbb2003, along = 2, dmethod = "man")
# 
# ##########################
# Distances between elements
# ##########################
# 
# Distance method:  manhattan
# Normalized: FALSE
#                                1     2     3     4     5     6     7     8
# (1) self                 1       10.00 23.00  9.00 20.00 26.00 18.00 23.00
# (2) my father            2             27.00  9.00 24.00 28.00  8.00 27.00
# (3) an old flame         3                   18.00 17.00 17.00 27.00 12.00
# (4) an ethical person    4                         15.00 25.00 15.00 18.00
# (5) my mother            5                               24.00 22.00  9.00
# (6) a rejected teacher   6                                     34.00 21.00
# (7) as I would love to b 7                                           25.00
# (8) a pitied person      8

For other distance metrics:

distance(fbb2003, along = 2, dm = "canb") # canberra distance for constructs
distance(fbb2003, along = 2, dm = "mink", p = 3) # minkowski metric to the power of 3  for constructs

If the distances are calculated for further processing, the printing to the console can be surpressed distance and the results can be saved into an object (here d).

d <- distance(fbb2003)

The object is a matrix. So we can look at the distances for the first element by

d[1, ]
#     (1) clever - not bright  (2) disorganiz - organized    (3) listens - doesn't he (4) no clear v - clear view 
#                    0.000000                   10.392305                    2.449490                    9.539392 
# (5) understand - no underst  (6) ambitious - no ambitio  (7) respected - not respec          (8) distant - warm 
#                    3.741657                    6.782330                    2.828427                    8.185353 
# (9) rather agg - not aggres 
#                    7.681146