Compare two rank orderings

Description

This function compares two rank orderings that have the same elements. For an order of length n there are n choose 2 dyadic relationships implied by that order. For example, the order a, b, c implies that a > b, a > c, and b > c. The dyadic similarity between two orders is the proportion of implied dyadic relationships that are shared by the two orders.

Usage

dyadic_similarity(order1, order2)


Arguments

 order1 The first rank ordering to be compared. Alternatively, this can be supplied as an interaction matrix with identities as the dimension names. All identities in order1 must be in order2. order2 The second rank ordering to be compared. Alternatively, this can be supplied as an interaction matrix with identities as the dimension names. All identities in order2 must be in order1.

Value

The proportion of dyadic relationships that are shared by the two orders. This value is 1 if the orders are identical and 0 if the orders are exact opposites.

Examples

dyadic_similarity(letters[1:20], letters[1:20]) #identical orders