Correlation Estimation for Exchangeable/Symmetrical Variables

We implement a new correlation estimator, CorSym, designed for exchangeable variables, where the ordering of the two values in the pair is arbitrary. This kind of data arises frequently in the study of assortative pairing (for example, income in a couple). The standard Pearson estimator is sensitive to such ordering and can be highly biased when the order is biased (when the first value tends to have lower or higher values than the second value). CorSym gives the same estimate deterministically for all orders within each pair, and estimates the desired correlation without bias (variables must be exchangeable). The package also includes utilities to simulate biased orders and test for order bias. Described in Kennedy and Ochoa (2026) .


CorSym: Correlation Estimation For Exchangeable/Symmetrical Variables CorSym

This package implements CorSym, an unbiased estimator of the correlation for exchangeable data, where the values (x,y) in a pair have no inherent order, so replacing with (y,x) randomly in any or all pairs is equally valid. This scenario occurs frequently in the study of assortative pairing, for example, what is the correlation between the two incomes of a couple, or their ancestry proportions? It also provides functions to calculate confidence intervals (CIs) separately, modify variable orders, a statistical test for order bias, and a wrapper around the standard Pearson estimator to illustrate its problematic dependence on data ordering (under the hypothesis that order is actually meaningless).

Installation

You can install the released version of corsym from CRAN with:

install.packages("corsym")

You can install the development version of corsym from GitHub with:

# install.packages("pak")
pak::pak("OchoaLab/corsym")

Example

Suppose you have a matrix X with paired data (two columns), and the order within each pair is arbitrary. For example, the proportion of the genome of each parent that is of a given ancestry, where different rows are different sets of parents. We want to estimate the correlation between values in the pair. The standard Pearson estimator can be biased if the data has an order bias, while CorSym is unbiased and gives the same answer for all orders.

library(corsym)

# Calculate correlations with CIs with both methods.
# If there was an order bias, they will disagree more,
# otherwise they might be close,
# but Pearson gives a different answer for each order!
pearson( X )
corsym( X )

# if your data is in random order, create a version with extreme order
# (every pair starts with the minimum value, ends with the maximum in the pair):
Xe <- partial_order( X )
# and if you suspect your data has a biased order, generate a randomized order version:
Xr <- randomize_order( Xe )

# confirm Pearson gives a very different answer for extremely ordered data
# while CorSym gives exactly the same answer both ways
pearson( Xe )
corsym( Xe )

# Pearson is also sensitive to random order variations, Corsym is not:
pearson( Xr )
corsym( Xr )

# test the data for order bias
# count the number of times the first value was the smaller one of the pair,
# separately for the original, randomized, and extreme order data
data <- data.frame(
    type = c('Original', 'Random', 'Extreme'),
    x = c(
        sum( X[,1] < X[,2] ),
        sum( Xr[,1] < Xr[,2] ),
        sum( Xe[,1] < Xe[,2] )
    ),
    n = n
)
# this function reports the frequency of those cases,
# and p-values under the null hypothesis that the true frequency is 0.5
order_bias_test( data )

Citation

Gabriel Kennedy, Alejandro Ochoa. Estimating the correlation of exchangeable variables in assortative mating. bioRxiv doi:10.64898/2026.08.22.746446 2026-08-26.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("corsym")

1.0.1 by Alejandro Ochoa, a month ago


https://github.com/OchoaLab/corsym


Report a bug at https://github.com/OchoaLab/corsym/issues


Browse source code at https://github.com/cran/corsym


Authors: Alejandro Ochoa [aut, cre] (ORCID: , Gabriel Kennedy [aut]


Documentation:   PDF Manual  


GPL (>= 3) license


Suggests knitr, rmarkdown, testthat, ggplot2


See at CRAN