knitr::opts_chunk$set(collapse = TRUE, comment = "#")
library(OpenRepGrid)
options(width=120)
settings(show.scale=FALSE, show.meta=FALSE)

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:

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:

distance(fbb2003)

Distance for elements:

distance(fbb2003, along=2)

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")

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, ]

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, ]

Make sure you are aware of this fact when using distance measures and constructs.



markheckmann/OpenRepGrid documentation built on April 14, 2024, 8:15 a.m.