Distances between constructs and elements
Source:vignettes/web/constructsdistances.Rmd
constructsdistances.Rmd
Description
Distances between constructs are used as a measure of similarity. They have the disadvantage that they are not invariant to construct reflection. The following distance measures are available:

euclidean
: Squared distance between the two vectors (L2 norm) 
manhattan
: Also called cityblockdistance, 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
: $\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 nonnegative values (e.g. counts). 
binary
: The vectors are regarded as binary bits, so nonzero 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.
RCode
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:
distance(fbb2003)
#
# ############################
# Distances between constructs
# ############################
#
# Distance method: euclidean
# Normalized: FALSE
# 1 2 3 4 5 6 7 8 9
# (1) clever  not bright 1 10.39 2.45 9.54 3.74 6.78 2.83 8.19 7.68
# (2) disorganiz  organized 2 9.38 4.58 8.49 7.07 9.27 7.14 8.54
# (3) listens  doesn't he 3 8.89 2.45 7.21 3.46 8.43 8.43
# (4) no clear v  clear view 4 7.81 7.42 8.31 7.35 7.62
# (5) understand  no underst 5 7.07 4.00 7.28 7.28
# (6) ambitious  no ambitio 6 6.32 5.57 6.56
# (7) respected  not respec 7 7.94 6.71
# (8) distant  warm 8 5.10
# (9) rather agg  not aggres 9
Distance for elements:
distance(fbb2003, along = 2)
#
# ##########################
# 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, dmethod = "manhattan")
#
# ############################
# Distances between constructs
# ############################
#
# Distance method: manhattan
# Normalized: FALSE
# 1 2 3 4 5 6 7 8 9
# (1) clever  not bright 1 28.00 4.00 23.00 8.00 16.00 6.00 15.00 17.00
# (2) disorganiz  organized 2 24.00 11.00 22.00 16.00 24.00 19.00 19.00
# (3) listens  doesn't he 3 19.00 6.00 18.00 8.00 17.00 21.00
# (4) no clear v  clear view 4 19.00 19.00 19.00 18.00 18.00
# (5) understand  no underst 5 16.00 8.00 15.00 19.00
# (6) ambitious  no ambitio 6 16.00 13.00 15.00
# (7) respected  not respec 7 17.00 15.00
# (8) distant  warm 8 10.00
# (9) rather agg  not aggres 9
For other distance metrics:
distance(fbb2003, dm = "canb") # canberra distance for constructs
distance(fbb2003, 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 construct only 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
Lack of invariance to construct reflection
Note that when you inverse a construct the distance measure will
change. Reversing the frist consstruct of fbb2003
will
yield different values than before.
x < swapPoles(fbb2003, 1)
d < distance(x)
d[1, ]
# (1) not bright  clever (2) disorganiz  organized (3) listens  doesn't he (4) no clear v  clear view
# 0.000000 3.464102 11.747340 4.795832
# (5) understand  no underst (6) ambitious  no ambitio (7) respected  not respec (8) distant  warm
# 10.677078 8.124038 10.954451 7.937254
# (9) rather agg  not aggres
# 8.426150
Make sure you are aware of this fact when using distance measures and constructs.