Computes similarity index between two encodings.

calc_si(a, b)

Arguments

a

encoding (see validate_encoding for more information about the required structure of encoding).

b

encoding to which a should be compared. Must have equal number of groups or less than a. Both a and b must have the the same number of elements.

Value

the value of similarity index.

Details

Briefly, the similarity index is a fraction of elements that have the same pairing in both encodings. Pairing is a binary variable, that has value 1 if two elements are in the same group and 0 if not. For more details, see references.

References

Stephenson, J.D., and Freeland, S.J. (2013). Unearthing the Root of Amino Acid Similarity. J Mol Evol 77, 159-169.

See also

calc_ed: calculate the encoding distance between two encodings.

Examples

# example from Stephenson & Freeland, 2013 (Fig. 6) enc1 <- list(`1` = "A", `2` = c("F", "E"), `3` = c("C", "D", "G")) enc2 <- list(`1` = c("A", "G"), `2` = c("C", "D", "E", "F")) enc3 <- list(`1` = c("D", "G"), `2` = c("E", "F"), `3` = c("A", "C")) calc_si(enc1, enc2)
#> [1] 0.5333333
calc_si(enc2, enc3)
#> Warning: 'a' must be longer than 'b'. Reverting a and b.
#> [1] 0.4666667
calc_si(enc1, enc3)
#> [1] 0.8